OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
| 8 #include "src/snapshot/code-serializer.h" |
8 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
9 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
10 #include "src/wasm/wasm-module-builder.h" | 11 #include "src/wasm/wasm-module-builder.h" |
11 #include "src/wasm/wasm-module.h" | 12 #include "src/wasm/wasm-module.h" |
12 #include "src/wasm/wasm-opcodes.h" | 13 #include "src/wasm/wasm-opcodes.h" |
13 | 14 |
14 #include "test/cctest/cctest.h" | 15 #include "test/cctest/cctest.h" |
15 #include "test/common/wasm/test-signatures.h" | 16 #include "test/common/wasm/test-signatures.h" |
16 #include "test/common/wasm/wasm-module-runner.h" | 17 #include "test/common/wasm/wasm-module-runner.h" |
17 | 18 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 222 |
222 v8::WasmCompiledModule::CallerOwnedBuffer wire_bytes = { | 223 v8::WasmCompiledModule::CallerOwnedBuffer wire_bytes = { |
223 const_cast<const uint8_t*>(bytes), bytes_size}; | 224 const_cast<const uint8_t*>(bytes), bytes_size}; |
224 | 225 |
225 v8::WasmCompiledModule::CallerOwnedBuffer serialized_bytes = { | 226 v8::WasmCompiledModule::CallerOwnedBuffer serialized_bytes = { |
226 data.first.get(), data.second}; | 227 data.first.get(), data.second}; |
227 v8::Isolate::CreateParams create_params; | 228 v8::Isolate::CreateParams create_params; |
228 create_params.array_buffer_allocator = | 229 create_params.array_buffer_allocator = |
229 CcTest::InitIsolateOnce()->array_buffer_allocator(); | 230 CcTest::InitIsolateOnce()->array_buffer_allocator(); |
230 | 231 |
231 for (int i = 0; i < 2; ++i) { | 232 for (int i = 0; i < 3; ++i) { |
232 v8::Isolate* v8_isolate = v8::Isolate::New(create_params); | 233 v8::Isolate* v8_isolate = v8::Isolate::New(create_params); |
233 if (i == 1) { | 234 if (i == 1) { |
| 235 // Invalidate the header by providing a mismatched version |
| 236 SerializedCodeData::InvalidateVersionForTest( |
| 237 const_cast<uint8_t*>(serialized_bytes.first), |
| 238 serialized_bytes.second); |
| 239 } |
| 240 |
| 241 if (i == 2) { |
234 // Provide no serialized data to force recompilation. | 242 // Provide no serialized data to force recompilation. |
235 serialized_bytes.first = nullptr; | 243 serialized_bytes.first = nullptr; |
236 serialized_bytes.second = 0; | 244 serialized_bytes.second = 0; |
237 } | 245 } |
238 { | 246 { |
239 v8::Isolate::Scope isolate_scope(v8_isolate); | 247 v8::Isolate::Scope isolate_scope(v8_isolate); |
240 v8::HandleScope new_scope(v8_isolate); | 248 v8::HandleScope new_scope(v8_isolate); |
241 v8::Local<v8::Context> new_ctx = v8::Context::New(v8_isolate); | 249 v8::Local<v8::Context> new_ctx = v8::Context::New(v8_isolate); |
242 new_ctx->Enter(); | 250 new_ctx->Enter(); |
243 isolate = reinterpret_cast<Isolate*>(v8_isolate); | 251 isolate = reinterpret_cast<Isolate*>(v8_isolate); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 533 |
526 TEST(Run_WasmModule_Global_f32) { | 534 TEST(Run_WasmModule_Global_f32) { |
527 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f); | 535 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f); |
528 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f); | 536 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f); |
529 } | 537 } |
530 | 538 |
531 TEST(Run_WasmModule_Global_f64) { | 539 TEST(Run_WasmModule_Global_f64) { |
532 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9); | 540 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9); |
533 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25); | 541 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25); |
534 } | 542 } |
OLD | NEW |