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 "src/api-natives.h" | 5 #include "src/api-natives.h" |
6 #include "src/api.h" | 6 #include "src/api.h" |
7 #include "src/asmjs/asm-wasm-builder.h" | 7 #include "src/asmjs/asm-wasm-builder.h" |
8 #include "src/asmjs/typing-asm.h" | 8 #include "src/asmjs/typing-asm.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 Handle<FunctionTemplateInfo> temp = NewTemplate(isolate, func); | 408 Handle<FunctionTemplateInfo> temp = NewTemplate(isolate, func); |
409 Handle<JSFunction> function = | 409 Handle<JSFunction> function = |
410 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); | 410 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); |
411 PropertyAttributes attributes = | 411 PropertyAttributes attributes = |
412 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | 412 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); |
413 JSObject::AddProperty(object, name, function, attributes); | 413 JSObject::AddProperty(object, name, function, attributes); |
414 return function; | 414 return function; |
415 } | 415 } |
416 | 416 |
417 void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) { | 417 void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) { |
| 418 if (!FLAG_expose_wasm && !FLAG_validate_asm) { |
| 419 return; |
| 420 } |
| 421 |
418 Factory* factory = isolate->factory(); | 422 Factory* factory = isolate->factory(); |
419 | 423 |
420 // Setup wasm function map. | 424 // Setup wasm function map. |
421 Handle<Context> context(global->native_context(), isolate); | 425 Handle<Context> context(global->native_context(), isolate); |
422 InstallWasmFunctionMap(isolate, context); | 426 InstallWasmFunctionMap(isolate, context); |
423 | 427 |
| 428 if (!FLAG_expose_wasm) { |
| 429 return; |
| 430 } |
| 431 |
424 // Bind the experimental WASM object. | 432 // Bind the experimental WASM object. |
425 // TODO(rossberg, titzer): remove once it's no longer needed. | 433 // TODO(rossberg, titzer): remove once it's no longer needed. |
426 { | 434 { |
427 Handle<String> name = v8_str(isolate, "Wasm"); | 435 Handle<String> name = v8_str(isolate, "Wasm"); |
428 Handle<JSFunction> cons = factory->NewFunction(name); | 436 Handle<JSFunction> cons = factory->NewFunction(name); |
429 JSFunction::SetInstancePrototype( | 437 JSFunction::SetInstancePrototype( |
430 cons, Handle<Object>(context->initial_object_prototype(), isolate)); | 438 cons, Handle<Object>(context->initial_object_prototype(), isolate)); |
431 cons->shared()->set_instance_class_name(*name); | 439 cons->shared()->set_instance_class_name(*name); |
432 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED); | 440 Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED); |
433 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM); | 441 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 int unused_property_fields = in_object_properties - pre_allocated; | 505 int unused_property_fields = in_object_properties - pre_allocated; |
498 Handle<Map> map = Map::CopyInitialMap( | 506 Handle<Map> map = Map::CopyInitialMap( |
499 prev_map, instance_size, in_object_properties, unused_property_fields); | 507 prev_map, instance_size, in_object_properties, unused_property_fields); |
500 | 508 |
501 context->set_wasm_function_map(*map); | 509 context->set_wasm_function_map(*map); |
502 } | 510 } |
503 } | 511 } |
504 | 512 |
505 } // namespace internal | 513 } // namespace internal |
506 } // namespace v8 | 514 } // namespace v8 |
OLD | NEW |