Commit 53cb7e5f authored by gdeepti's avatar gdeepti Committed by Commit bot

Populate relocation information correctly for RelocatableInt32Constants.

BUG=v8:5304
R=ahaas@chromium.org, titzer@chromium.org

Review-Url: https://codereview.chromium.org/2277443009
Cr-Commit-Position: refs/heads/master@{#39112}
parent ce8fab76
......@@ -2458,7 +2458,11 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
if (value == 0) {
__ xorl(dst, dst);
} else {
__ movl(dst, Immediate(value));
if (src.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE) {
__ movl(dst, Immediate(value, src.rmode()));
} else {
__ movl(dst, Immediate(value));
}
}
}
break;
......
......@@ -200,9 +200,17 @@ TEST(Run_WasmModule_Serialization) {
ZoneBuffer buffer(&zone);
builder->WriteTo(buffer);
Isolate* isolate = CcTest::InitIsolateOnce();
ErrorThrower thrower(isolate, "");
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
CcTest::InitIsolateOnce()->array_buffer_allocator();
v8::Isolate* v8_isolate = v8::Isolate::New(create_params);
Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
v8::HandleScope new_scope(v8_isolate);
v8::Local<v8::Context> new_ctx = v8::Context::New(v8_isolate);
new_ctx->Enter();
ErrorThrower thrower(isolate, "");
v8::WasmCompiledModule::SerializedModule data;
{
HandleScope scope(isolate);
......@@ -225,10 +233,8 @@ TEST(Run_WasmModule_Serialization) {
data = v8_compiled_module->Serialize();
}
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = isolate->array_buffer_allocator();
v8::Isolate* v8_isolate = v8::Isolate::New(create_params);
isolate = reinterpret_cast<Isolate*>(v8_isolate);
{
v8::Isolate::Scope isolate_scope(v8_isolate);
......@@ -257,6 +263,24 @@ TEST(Run_WasmModule_Serialization) {
}
}
TEST(Run_WasmModule_MemSize_GrowMem) {
static const int kPageSize = 0x10000;
// Initial memory size = 16 + GrowMemory(10)
static const int kExpectedValue = kPageSize * 26;
TestSignatures sigs;
v8::base::AccountingAllocator allocator;
Zone zone(&allocator);
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
uint16_t f_index = builder->AddFunction();
WasmFunctionBuilder* f = builder->FunctionAt(f_index);
f->SetSignature(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_GROW_MEMORY(WASM_I8(10)), WASM_MEMORY_SIZE};
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kExpectedValue);
}
TEST(Run_WasmModule_GrowMemoryInIf) {
TestSignatures sigs;
v8::base::AccountingAllocator allocator;
......
......@@ -128,3 +128,19 @@ function testGrowMemoryTrapsWithNonSmiInput() {
};
testGrowMemoryTrapsWithNonSmiInput();
function testGrowMemoryCurrentMemory() {
var builder = genGrowMemoryBuilder();
builder.addMemory(1, 1, false);
builder.addFunction("memory_size", kSig_i_v)
.addBody([kExprMemorySize])
.exportFunc();
var module = builder.instantiate();
function growMem(pages) { return module.exports.grow_memory(pages); }
function MemSize() { return module.exports.memory_size(); }
assertEquals(65536, MemSize());
assertEquals(1, growMem(1));
assertEquals(131072, MemSize());
}
testGrowMemoryCurrentMemory();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment