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

Side by Side Diff: src/asmjs/asm-js.cc

Issue 2664493002: [wasm][asm.js] Make asm.js->wasm return a regular object. (Closed)
Patch Set: fix Created 3 years, 10 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 | src/wasm/wasm-module.cc » ('j') | src/wasm/wasm-module.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/asmjs/asm-js.h" 5 #include "src/asmjs/asm-js.h"
6 6
7 #include "src/api-natives.h" 7 #include "src/api-natives.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/asmjs/asm-typer.h" 9 #include "src/asmjs/asm-typer.h"
10 #include "src/asmjs/asm-wasm-builder.h" 10 #include "src/asmjs/asm-wasm-builder.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // Create the ffi object for foreign functions {"": foreign}. 266 // Create the ffi object for foreign functions {"": foreign}.
267 Handle<JSObject> ffi_object; 267 Handle<JSObject> ffi_object;
268 if (!foreign.is_null()) { 268 if (!foreign.is_null()) {
269 Handle<JSFunction> object_function = Handle<JSFunction>( 269 Handle<JSFunction> object_function = Handle<JSFunction>(
270 isolate->native_context()->object_function(), isolate); 270 isolate->native_context()->object_function(), isolate);
271 ffi_object = isolate->factory()->NewJSObject(object_function); 271 ffi_object = isolate->factory()->NewJSObject(object_function);
272 JSObject::AddProperty(ffi_object, isolate->factory()->empty_string(), 272 JSObject::AddProperty(ffi_object, isolate->factory()->empty_string(),
273 foreign, NONE); 273 foreign, NONE);
274 } 274 }
275 275
276 i::MaybeHandle<i::JSObject> maybe_module_object = 276 i::MaybeHandle<i::Object> maybe_module_object =
277 i::wasm::WasmModule::Instantiate(isolate, &thrower, module, ffi_object, 277 i::wasm::WasmModule::Instantiate(isolate, &thrower, module, ffi_object,
278 memory); 278 memory);
279 if (maybe_module_object.is_null()) { 279 if (maybe_module_object.is_null()) {
280 return MaybeHandle<Object>(); 280 return MaybeHandle<Object>();
281 } 281 }
282 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked();
282 283
283 i::Handle<i::Name> init_name(isolate->factory()->InternalizeUtf8String( 284 i::Handle<i::Name> init_name(isolate->factory()->InternalizeUtf8String(
284 wasm::AsmWasmBuilder::foreign_init_name)); 285 wasm::AsmWasmBuilder::foreign_init_name));
286 i::Handle<i::Object> init =
287 i::Object::GetProperty(module_object, init_name).ToHandleChecked();
285 288
286 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked();
287 i::MaybeHandle<i::Object> maybe_init =
288 i::Object::GetProperty(module_object, init_name);
289 DCHECK(!maybe_init.is_null());
290
291 i::Handle<i::Object> init = maybe_init.ToHandleChecked();
292 i::Handle<i::Object> undefined(isolate->heap()->undefined_value(), isolate); 289 i::Handle<i::Object> undefined(isolate->heap()->undefined_value(), isolate);
293 i::Handle<i::Object>* foreign_args_array = 290 i::Handle<i::Object>* foreign_args_array =
294 new i::Handle<i::Object>[foreign_globals->length()]; 291 new i::Handle<i::Object>[foreign_globals->length()];
295 for (int j = 0; j < foreign_globals->length(); j++) { 292 for (int j = 0; j < foreign_globals->length(); j++) {
296 if (!foreign.is_null()) { 293 if (!foreign.is_null()) {
297 i::MaybeHandle<i::Name> name = i::Object::ToName( 294 i::MaybeHandle<i::Name> name = i::Object::ToName(
298 isolate, i::Handle<i::Object>(foreign_globals->get(j), isolate)); 295 isolate, i::Handle<i::Object>(foreign_globals->get(j), isolate));
299 if (!name.is_null()) { 296 if (!name.is_null()) {
300 i::MaybeHandle<i::Object> val = 297 i::MaybeHandle<i::Object> val =
301 i::Object::GetProperty(foreign, name.ToHandleChecked()); 298 i::Object::GetProperty(foreign, name.ToHandleChecked());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 USE(length); 337 USE(length);
341 Handle<String> stext(isolate->factory()->InternalizeUtf8String(text)); 338 Handle<String> stext(isolate->factory()->InternalizeUtf8String(text));
342 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( 339 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject(
343 isolate, MessageTemplate::kAsmJsInstantiated, &location, stext, 340 isolate, MessageTemplate::kAsmJsInstantiated, &location, stext,
344 Handle<JSArray>::null()); 341 Handle<JSArray>::null());
345 message->set_error_level(v8::Isolate::kMessageInfo); 342 message->set_error_level(v8::Isolate::kMessageInfo);
346 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { 343 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) {
347 MessageHandler::ReportMessage(isolate, &location, message); 344 MessageHandler::ReportMessage(isolate, &location, message);
348 } 345 }
349 346
350 return module_object; 347 Handle<String> exports_name =
348 isolate->factory()->InternalizeUtf8String("exports");
349 return i::Object::GetProperty(module_object, exports_name);
351 } 350 }
352 351
353 } // namespace internal 352 } // namespace internal
354 } // namespace v8 353 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/wasm-module.cc » ('j') | src/wasm/wasm-module.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698