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

Side by Side Diff: src/api.cc

Issue 2490663002: [wasm] Move all heap-allocated WASM structures into wasm-objects.h. (Closed)
Patch Set: Created 4 years, 1 month 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "src/snapshot/snapshot.h" 66 #include "src/snapshot/snapshot.h"
67 #include "src/startup-data-util.h" 67 #include "src/startup-data-util.h"
68 #include "src/tracing/trace-event.h" 68 #include "src/tracing/trace-event.h"
69 #include "src/unicode-inl.h" 69 #include "src/unicode-inl.h"
70 #include "src/v8.h" 70 #include "src/v8.h"
71 #include "src/v8threads.h" 71 #include "src/v8threads.h"
72 #include "src/value-serializer.h" 72 #include "src/value-serializer.h"
73 #include "src/version.h" 73 #include "src/version.h"
74 #include "src/vm-state-inl.h" 74 #include "src/vm-state-inl.h"
75 #include "src/wasm/wasm-module.h" 75 #include "src/wasm/wasm-module.h"
76 #include "src/wasm/wasm-objects.h"
76 #include "src/wasm/wasm-result.h" 77 #include "src/wasm/wasm-result.h"
77 78
78 namespace v8 { 79 namespace v8 {
79 80
80 #define LOG_API(isolate, class_name, function_name) \ 81 #define LOG_API(isolate, class_name, function_name) \
81 i::RuntimeCallTimerScope _runtime_timer( \ 82 i::RuntimeCallTimerScope _runtime_timer( \
82 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \ 83 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \
83 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name)) 84 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name))
84 85
85 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) 86 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
(...skipping 7145 matching lines...) Expand 10 before | Expand all | Expand 10 after
7231 Local<Proxy> result; 7232 Local<Proxy> result;
7232 has_pending_exception = 7233 has_pending_exception =
7233 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); 7234 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result);
7234 RETURN_ON_FAILED_EXECUTION(Proxy); 7235 RETURN_ON_FAILED_EXECUTION(Proxy);
7235 RETURN_ESCAPED(result); 7236 RETURN_ESCAPED(result);
7236 } 7237 }
7237 7238
7238 Local<String> WasmCompiledModule::GetWasmWireBytes() { 7239 Local<String> WasmCompiledModule::GetWasmWireBytes() {
7239 i::Handle<i::JSObject> obj = 7240 i::Handle<i::JSObject> obj =
7240 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 7241 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
7241 i::Handle<i::wasm::WasmCompiledModule> compiled_part = 7242 i::Handle<i::WasmCompiledModule> compiled_part =
7242 i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0))); 7243 i::handle(i::WasmCompiledModule::cast(obj->GetInternalField(0)));
7243 i::Handle<i::String> wire_bytes = compiled_part->module_bytes(); 7244 i::Handle<i::String> wire_bytes = compiled_part->module_bytes();
7244 return Local<String>::Cast(Utils::ToLocal(wire_bytes)); 7245 return Local<String>::Cast(Utils::ToLocal(wire_bytes));
7245 } 7246 }
7246 7247
7247 WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() { 7248 WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() {
7248 i::Handle<i::JSObject> obj = 7249 i::Handle<i::JSObject> obj =
7249 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 7250 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
7250 i::Handle<i::wasm::WasmCompiledModule> compiled_part = 7251 i::Handle<i::WasmCompiledModule> compiled_part =
7251 i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0))); 7252 i::handle(i::WasmCompiledModule::cast(obj->GetInternalField(0)));
7252 7253
7253 std::unique_ptr<i::ScriptData> script_data = 7254 std::unique_ptr<i::ScriptData> script_data =
7254 i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(), 7255 i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(),
7255 compiled_part); 7256 compiled_part);
7256 script_data->ReleaseDataOwnership(); 7257 script_data->ReleaseDataOwnership();
7257 7258
7258 size_t size = static_cast<size_t>(script_data->length()); 7259 size_t size = static_cast<size_t>(script_data->length());
7259 return {std::unique_ptr<const uint8_t[]>(script_data->data()), size}; 7260 return {std::unique_ptr<const uint8_t[]>(script_data->data()), size};
7260 } 7261 }
7261 7262
7262 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize( 7263 MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
7263 Isolate* isolate, 7264 Isolate* isolate,
7264 const WasmCompiledModule::CallerOwnedBuffer& serialized_module, 7265 const WasmCompiledModule::CallerOwnedBuffer& serialized_module,
7265 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) { 7266 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) {
7266 int size = static_cast<int>(serialized_module.second); 7267 int size = static_cast<int>(serialized_module.second);
7267 i::ScriptData sc(serialized_module.first, size); 7268 i::ScriptData sc(serialized_module.first, size);
7268 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7269 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7269 i::MaybeHandle<i::FixedArray> maybe_compiled_part = 7270 i::MaybeHandle<i::FixedArray> maybe_compiled_part =
7270 i::WasmCompiledModuleSerializer::DeserializeWasmModule( 7271 i::WasmCompiledModuleSerializer::DeserializeWasmModule(
7271 i_isolate, &sc, 7272 i_isolate, &sc,
7272 {wire_bytes.first, static_cast<int>(wire_bytes.second)}); 7273 {wire_bytes.first, static_cast<int>(wire_bytes.second)});
7273 i::Handle<i::FixedArray> compiled_part; 7274 i::Handle<i::FixedArray> compiled_part;
7274 if (!maybe_compiled_part.ToHandle(&compiled_part)) { 7275 if (!maybe_compiled_part.ToHandle(&compiled_part)) {
7275 return MaybeLocal<WasmCompiledModule>(); 7276 return MaybeLocal<WasmCompiledModule>();
7276 } 7277 }
7277 i::Handle<i::wasm::WasmCompiledModule> compiled_module = 7278 i::Handle<i::WasmCompiledModule> compiled_module =
7278 handle(i::wasm::WasmCompiledModule::cast(*compiled_part)); 7279 handle(i::WasmCompiledModule::cast(*compiled_part));
7279 return Local<WasmCompiledModule>::Cast( 7280 return Local<WasmCompiledModule>::Cast(
7280 Utils::ToLocal(i::wasm::CreateWasmModuleObject( 7281 Utils::ToLocal(i::wasm::CreateWasmModuleObject(
7281 i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin))); 7282 i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin)));
7282 } 7283 }
7283 7284
7284 MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile( 7285 MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
7285 Isolate* isolate, 7286 Isolate* isolate,
7286 const WasmCompiledModule::CallerOwnedBuffer& serialized_module, 7287 const WasmCompiledModule::CallerOwnedBuffer& serialized_module,
7287 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) { 7288 const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) {
7288 MaybeLocal<WasmCompiledModule> ret = 7289 MaybeLocal<WasmCompiledModule> ret =
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after
9771 Address callback_address = 9772 Address callback_address =
9772 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9773 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9773 VMState<EXTERNAL> state(isolate); 9774 VMState<EXTERNAL> state(isolate);
9774 ExternalCallbackScope call_scope(isolate, callback_address); 9775 ExternalCallbackScope call_scope(isolate, callback_address);
9775 callback(info); 9776 callback(info);
9776 } 9777 }
9777 9778
9778 9779
9779 } // namespace internal 9780 } // namespace internal
9780 } // namespace v8 9781 } // namespace v8
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/asmjs/asm-js.cc » ('j') | src/wasm/wasm-module.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698