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" |
| 9 #include "src/version.h" |
8 #include "src/wasm/module-decoder.h" | 10 #include "src/wasm/module-decoder.h" |
9 #include "src/wasm/wasm-macro-gen.h" | 11 #include "src/wasm/wasm-macro-gen.h" |
10 #include "src/wasm/wasm-module-builder.h" | 12 #include "src/wasm/wasm-module-builder.h" |
11 #include "src/wasm/wasm-module.h" | 13 #include "src/wasm/wasm-module.h" |
12 #include "src/wasm/wasm-opcodes.h" | 14 #include "src/wasm/wasm-opcodes.h" |
13 | 15 |
14 #include "test/cctest/cctest.h" | 16 #include "test/cctest/cctest.h" |
15 #include "test/common/wasm/test-signatures.h" | 17 #include "test/common/wasm/test-signatures.h" |
16 #include "test/common/wasm/wasm-module-runner.h" | 18 #include "test/common/wasm/wasm-module-runner.h" |
17 | 19 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 223 |
222 v8::WasmCompiledModule::CallerOwnedBuffer wire_bytes = { | 224 v8::WasmCompiledModule::CallerOwnedBuffer wire_bytes = { |
223 const_cast<const uint8_t*>(bytes), bytes_size}; | 225 const_cast<const uint8_t*>(bytes), bytes_size}; |
224 | 226 |
225 v8::WasmCompiledModule::CallerOwnedBuffer serialized_bytes = { | 227 v8::WasmCompiledModule::CallerOwnedBuffer serialized_bytes = { |
226 data.first.get(), data.second}; | 228 data.first.get(), data.second}; |
227 v8::Isolate::CreateParams create_params; | 229 v8::Isolate::CreateParams create_params; |
228 create_params.array_buffer_allocator = | 230 create_params.array_buffer_allocator = |
229 CcTest::InitIsolateOnce()->array_buffer_allocator(); | 231 CcTest::InitIsolateOnce()->array_buffer_allocator(); |
230 | 232 |
231 for (int i = 0; i < 2; ++i) { | 233 for (int i = 0; i < 3; ++i) { |
232 v8::Isolate* v8_isolate = v8::Isolate::New(create_params); | 234 v8::Isolate* v8_isolate = v8::Isolate::New(create_params); |
233 if (i == 1) { | 235 if (i == 1) { |
| 236 // Invalidate the header by providing a mismatched version |
| 237 uint32_t* buffer = reinterpret_cast<uint32_t*>( |
| 238 const_cast<uint8_t*>(serialized_bytes.first)); |
| 239 buffer[SerializedCodeData::kVersionHashOffset] = Version::Hash() + 1; |
| 240 } |
| 241 |
| 242 if (i == 2) { |
234 // Provide no serialized data to force recompilation. | 243 // Provide no serialized data to force recompilation. |
235 serialized_bytes.first = nullptr; | 244 serialized_bytes.first = nullptr; |
236 serialized_bytes.second = 0; | 245 serialized_bytes.second = 0; |
237 } | 246 } |
238 { | 247 { |
239 v8::Isolate::Scope isolate_scope(v8_isolate); | 248 v8::Isolate::Scope isolate_scope(v8_isolate); |
240 v8::HandleScope new_scope(v8_isolate); | 249 v8::HandleScope new_scope(v8_isolate); |
241 v8::Local<v8::Context> new_ctx = v8::Context::New(v8_isolate); | 250 v8::Local<v8::Context> new_ctx = v8::Context::New(v8_isolate); |
242 new_ctx->Enter(); | 251 new_ctx->Enter(); |
243 isolate = reinterpret_cast<Isolate*>(v8_isolate); | 252 isolate = reinterpret_cast<Isolate*>(v8_isolate); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 534 |
526 TEST(Run_WasmModule_Global_f32) { | 535 TEST(Run_WasmModule_Global_f32) { |
527 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f); | 536 RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f); |
528 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f); | 537 RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f); |
529 } | 538 } |
530 | 539 |
531 TEST(Run_WasmModule_Global_f64) { | 540 TEST(Run_WasmModule_Global_f64) { |
532 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9); | 541 RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9); |
533 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25); | 542 RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25); |
534 } | 543 } |
OLD | NEW |