Merge V8 5.3.332.45.  DO NOT MERGE

Test: Manual

FPIIM-449

Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/test/cctest/wasm/test-run-wasm-asmjs.cc b/test/cctest/wasm/test-run-wasm-asmjs.cc
index c597fc8..4d39dd6 100644
--- a/test/cctest/wasm/test-run-wasm-asmjs.cc
+++ b/test/cctest/wasm/test-run-wasm-asmjs.cc
@@ -26,8 +26,20 @@
 #define RET(x) x, kExprReturn, 1
 #define RET_I8(x) kExprI8Const, x, kExprReturn, 1
 
+namespace {
+uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) {
+  int filter = 1 << rmode;
+  uint32_t ret = 0;
+  for (RelocIterator it(*code, filter); !it.done(); it.next()) {
+    ++ret;
+  }
+  return ret;
+}
+}
+
 WASM_EXEC_TEST(Int32AsmjsDivS) {
-  WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
+  WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
+                        MachineType::Int32());
   BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
   const int32_t kMin = std::numeric_limits<int32_t>::min();
   CHECK_EQ(0, r.Call(0, 100));
@@ -38,7 +50,8 @@
 }
 
 WASM_EXEC_TEST(Int32AsmjsRemS) {
-  WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
+  WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
+                        MachineType::Int32());
   BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
   const int32_t kMin = std::numeric_limits<int32_t>::min();
   CHECK_EQ(33, r.Call(133, 100));
@@ -49,7 +62,8 @@
 }
 
 WASM_EXEC_TEST(Int32AsmjsDivU) {
-  WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
+  WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
+                        MachineType::Int32());
   BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
   const int32_t kMin = std::numeric_limits<int32_t>::min();
   CHECK_EQ(0, r.Call(0, 100));
@@ -60,7 +74,8 @@
 }
 
 WASM_EXEC_TEST(Int32AsmjsRemU) {
-  WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
+  WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
+                        MachineType::Int32());
   BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
   const int32_t kMin = std::numeric_limits<int32_t>::min();
   CHECK_EQ(17, r.Call(217, 100));
@@ -71,7 +86,7 @@
 }
 
 WASM_EXEC_TEST(I32AsmjsSConvertF32) {
-  WasmRunner<int32_t> r(MachineType::Float32());
+  WasmRunner<int32_t> r(execution_mode, MachineType::Float32());
   BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
 
   FOR_FLOAT32_INPUTS(i) {
@@ -81,7 +96,7 @@
 }
 
 WASM_EXEC_TEST(I32AsmjsSConvertF64) {
-  WasmRunner<int32_t> r(MachineType::Float64());
+  WasmRunner<int32_t> r(execution_mode, MachineType::Float64());
   BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
 
   FOR_FLOAT64_INPUTS(i) {
@@ -91,7 +106,7 @@
 }
 
 WASM_EXEC_TEST(I32AsmjsUConvertF32) {
-  WasmRunner<uint32_t> r(MachineType::Float32());
+  WasmRunner<uint32_t> r(execution_mode, MachineType::Float32());
   BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
 
   FOR_FLOAT32_INPUTS(i) {
@@ -101,7 +116,7 @@
 }
 
 WASM_EXEC_TEST(I32AsmjsUConvertF64) {
-  WasmRunner<uint32_t> r(MachineType::Float64());
+  WasmRunner<uint32_t> r(execution_mode, MachineType::Float64());
   BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
 
   FOR_FLOAT64_INPUTS(i) {
@@ -111,7 +126,7 @@
 }
 
 WASM_EXEC_TEST(LoadMemI32_oob_asm) {
-  TestingModule module;
+  TestingModule module(execution_mode);
   int32_t* memory = module.AddMemoryElems<int32_t>(8);
   WasmRunner<int32_t> r(&module, MachineType::Uint32());
   module.RandomizeMemory(1112);
@@ -131,7 +146,7 @@
 }
 
 WASM_EXEC_TEST(LoadMemF32_oob_asm) {
-  TestingModule module;
+  TestingModule module(execution_mode);
   float* memory = module.AddMemoryElems<float>(8);
   WasmRunner<float> r(&module, MachineType::Uint32());
   module.RandomizeMemory(1112);
@@ -151,7 +166,7 @@
 }
 
 WASM_EXEC_TEST(LoadMemF64_oob_asm) {
-  TestingModule module;
+  TestingModule module(execution_mode);
   double* memory = module.AddMemoryElems<double>(8);
   WasmRunner<double> r(&module, MachineType::Uint32());
   module.RandomizeMemory(1112);
@@ -173,7 +188,7 @@
 }
 
 WASM_EXEC_TEST(StoreMemI32_oob_asm) {
-  TestingModule module;
+  TestingModule module(execution_mode);
   int32_t* memory = module.AddMemoryElems<int32_t>(8);
   WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32());
   module.RandomizeMemory(1112);
@@ -193,3 +208,90 @@
     CHECK_EQ(7777, r.Call(offset, 7777));
   }
 }
+
+#define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \
+  TEST_BODY(kExprI32AsmjsLoadMem8S)            \
+  TEST_BODY(kExprI32AsmjsLoadMem8U)            \
+  TEST_BODY(kExprI32AsmjsLoadMem16S)           \
+  TEST_BODY(kExprI32AsmjsLoadMem16U)           \
+  TEST_BODY(kExprI32AsmjsLoadMem)
+
+#define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \
+  TEST_BODY(kExprI32AsmjsStoreMem8)             \
+  TEST_BODY(kExprI32AsmjsStoreMem16)            \
+  TEST_BODY(kExprI32AsmjsStoreMem)
+
+#define INT_LOAD_TEST(OP_TYPE)                                                \
+  TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) {                                \
+    TestingModule module(kExecuteCompiled);                                   \
+    WasmRunner<int32_t> r(&module, MachineType::Uint32());                    \
+    BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0)));                          \
+    CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],  \
+                                          RelocInfo::WASM_MEMORY_REFERENCE)); \
+    CHECK_NE(                                                                 \
+        0, GetMatchingRelocInfoCount(module.instance->function_code[0],       \
+                                     RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
+  }
+
+FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
+
+#define INT_STORE_TEST(OP_TYPE)                                               \
+  TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) {                                \
+    TestingModule module(kExecuteCompiled);                                   \
+    WasmRunner<int32_t> r(&module, MachineType::Uint32(),                     \
+                          MachineType::Uint32());                             \
+    BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));      \
+    CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],  \
+                                          RelocInfo::WASM_MEMORY_REFERENCE)); \
+    CHECK_NE(                                                                 \
+        0, GetMatchingRelocInfoCount(module.instance->function_code[0],       \
+                                     RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
+  }
+
+FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
+
+TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
+  TestingModule module(kExecuteCompiled);
+  WasmRunner<float> r(&module, MachineType::Uint32());
+  BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
+
+  CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_REFERENCE));
+  CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
+}
+
+TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
+  TestingModule module(kExecuteCompiled);
+  WasmRunner<float> r(&module, MachineType::Uint32(), MachineType::Float32());
+  BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0),
+                      WASM_GET_LOCAL(1)));
+
+  CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_REFERENCE));
+  CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
+}
+
+TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
+  TestingModule module(kExecuteCompiled);
+  WasmRunner<double> r(&module, MachineType::Uint32());
+  BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
+
+  CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_REFERENCE));
+  CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
+}
+
+TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
+  TestingModule module(kExecuteCompiled);
+  WasmRunner<double> r(&module, MachineType::Uint32(), MachineType::Float64());
+  BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0),
+                      WASM_GET_LOCAL(1)));
+
+  CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_REFERENCE));
+  CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
+                                        RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
+}