Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/api.cc

Issue 2420373002: [wasm] Test deserialized module still has bytes, + negative test (Closed)
Patch Set: [wasm] Test deserialized module still has bytes, + negative test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 7229 matching lines...) Expand 10 before | Expand all | Expand 10 after
7240 return Local<WasmCompiledModule>::Cast( 7240 return Local<WasmCompiledModule>::Cast(
7241 Utils::ToLocal(i::wasm::CreateCompiledModuleObject( 7241 Utils::ToLocal(i::wasm::CreateCompiledModuleObject(
7242 i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin))); 7242 i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin)));
7243 } 7243 }
7244 7244
7245 MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile( 7245 MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
7246 Isolate* isolate, 7246 Isolate* isolate,
7247 const WasmCompiledModule::CallerOwnedBuffer& serialized_module, 7247 const WasmCompiledModule::CallerOwnedBuffer& serialized_module,
7248 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) { 7248 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) {
7249 MaybeLocal<WasmCompiledModule> ret = Deserialize(isolate, serialized_module); 7249 MaybeLocal<WasmCompiledModule> ret = Deserialize(isolate, serialized_module);
7250 if (!ret.IsEmpty()) return ret; 7250 if (!ret.IsEmpty()) {
7251 // TODO(mtrofin): once we stop taking a dependency on Deserialize,
7252 // clean this up to avoid the back and forth between internal
7253 // and external representations.
7254 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7255 i::Vector<const uint8_t> str(wire_bytes.first,
7256 static_cast<int>(wire_bytes.second));
7257 i::Handle<i::SeqOneByteString> wire_bytes_as_string(
7258 i::SeqOneByteString::cast(
7259 *i_isolate->factory()->NewStringFromOneByte(str).ToHandleChecked()),
7260 i_isolate);
7261
7262 i::Handle<i::JSObject> obj =
7263 i::Handle<i::JSObject>::cast(Utils::OpenHandle(*ret.ToLocalChecked()));
7264 i::Handle<i::wasm::WasmCompiledModule> compiled_part =
7265 i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0)));
7266 compiled_part->set_module_bytes(wire_bytes_as_string);
7267 return ret;
7268 }
7251 return Compile(isolate, wire_bytes.first, wire_bytes.second); 7269 return Compile(isolate, wire_bytes.first, wire_bytes.second);
7252 } 7270 }
7253 7271
7254 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate, 7272 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate,
7255 const uint8_t* start, 7273 const uint8_t* start,
7256 size_t length) { 7274 size_t length) {
7257 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7275 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7258 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()"); 7276 i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()");
7259 i::MaybeHandle<i::JSObject> maybe_compiled = 7277 i::MaybeHandle<i::JSObject> maybe_compiled =
7260 i::wasm::CreateModuleObjectFromBytes( 7278 i::wasm::CreateModuleObjectFromBytes(
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
9428 Address callback_address = 9446 Address callback_address =
9429 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9447 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9430 VMState<EXTERNAL> state(isolate); 9448 VMState<EXTERNAL> state(isolate);
9431 ExternalCallbackScope call_scope(isolate, callback_address); 9449 ExternalCallbackScope call_scope(isolate, callback_address);
9432 callback(info); 9450 callback(info);
9433 } 9451 }
9434 9452
9435 9453
9436 } // namespace internal 9454 } // namespace internal
9437 } // namespace v8 9455 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698