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-js.h" | 7 #include "src/asmjs/asm-js.h" |
8 #include "src/asmjs/asm-typer.h" | 8 #include "src/asmjs/asm-typer.h" |
9 #include "src/asmjs/asm-wasm-builder.h" | 9 #include "src/asmjs/asm-wasm-builder.h" |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 } | 572 } |
573 | 573 |
574 namespace internal { | 574 namespace internal { |
575 | 575 |
576 Handle<JSFunction> InstallFunc(Isolate* isolate, Handle<JSObject> object, | 576 Handle<JSFunction> InstallFunc(Isolate* isolate, Handle<JSObject> object, |
577 const char* str, FunctionCallback func) { | 577 const char* str, FunctionCallback func) { |
578 Handle<String> name = v8_str(isolate, str); | 578 Handle<String> name = v8_str(isolate, str); |
579 Handle<FunctionTemplateInfo> temp = NewTemplate(isolate, func); | 579 Handle<FunctionTemplateInfo> temp = NewTemplate(isolate, func); |
580 Handle<JSFunction> function = | 580 Handle<JSFunction> function = |
581 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); | 581 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); |
582 PropertyAttributes attributes = | 582 PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM); |
583 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | |
584 JSObject::AddProperty(object, name, function, attributes); | 583 JSObject::AddProperty(object, name, function, attributes); |
585 return function; | 584 return function; |
586 } | 585 } |
587 | 586 |
588 Handle<JSFunction> InstallGetter(Isolate* isolate, Handle<JSObject> object, | 587 Handle<JSFunction> InstallGetter(Isolate* isolate, Handle<JSObject> object, |
589 const char* str, FunctionCallback func) { | 588 const char* str, FunctionCallback func) { |
590 Handle<String> name = v8_str(isolate, str); | 589 Handle<String> name = v8_str(isolate, str); |
591 Handle<FunctionTemplateInfo> temp = NewTemplate(isolate, func); | 590 Handle<FunctionTemplateInfo> temp = NewTemplate(isolate, func); |
592 Handle<JSFunction> function = | 591 Handle<JSFunction> function = |
593 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); | 592 ApiNatives::InstantiateFunction(temp).ToHandleChecked(); |
594 v8::PropertyAttribute attributes = | 593 v8::PropertyAttribute attributes = |
595 static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly); | 594 static_cast<v8::PropertyAttribute>(v8::DontEnum); |
596 Utils::ToLocal(object)->SetAccessorProperty(Utils::ToLocal(name), | 595 Utils::ToLocal(object)->SetAccessorProperty(Utils::ToLocal(name), |
597 Utils::ToLocal(function), | 596 Utils::ToLocal(function), |
598 Local<Function>(), attributes); | 597 Local<Function>(), attributes); |
599 return function; | 598 return function; |
600 } | 599 } |
601 | 600 |
602 void WasmJs::InstallWasmModuleSymbolIfNeeded(Isolate* isolate, | 601 void WasmJs::InstallWasmModuleSymbolIfNeeded(Isolate* isolate, |
603 Handle<JSGlobalObject> global, | 602 Handle<JSGlobalObject> global, |
604 Handle<Context> context) { | 603 Handle<Context> context) { |
605 if (!context->get(Context::WASM_MODULE_SYM_INDEX)->IsSymbol() || | 604 if (!context->get(Context::WASM_MODULE_SYM_INDEX)->IsSymbol() || |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 map = isolate->factory()->NewMap( | 686 map = isolate->factory()->NewMap( |
688 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize + | 687 i::JS_OBJECT_TYPE, i::JSObject::kHeaderSize + |
689 WasmMemoryObject::kFieldCount * i::kPointerSize); | 688 WasmMemoryObject::kFieldCount * i::kPointerSize); |
690 JSFunction::SetInitialMap(memory_constructor, map, memory_proto); | 689 JSFunction::SetInitialMap(memory_constructor, map, memory_proto); |
691 JSObject::AddProperty(memory_proto, isolate->factory()->constructor_string(), | 690 JSObject::AddProperty(memory_proto, isolate->factory()->constructor_string(), |
692 memory_constructor, DONT_ENUM); | 691 memory_constructor, DONT_ENUM); |
693 InstallFunc(isolate, memory_proto, "grow", WebAssemblyMemoryGrow); | 692 InstallFunc(isolate, memory_proto, "grow", WebAssemblyMemoryGrow); |
694 InstallGetter(isolate, memory_proto, "buffer", WebAssemblyMemoryGetBuffer); | 693 InstallGetter(isolate, memory_proto, "buffer", WebAssemblyMemoryGetBuffer); |
695 | 694 |
696 // Setup errors | 695 // Setup errors |
697 attributes = static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | 696 attributes = static_cast<PropertyAttributes>(DONT_ENUM); |
698 Handle<JSFunction> compile_error( | 697 Handle<JSFunction> compile_error( |
699 isolate->native_context()->wasm_compile_error_function()); | 698 isolate->native_context()->wasm_compile_error_function()); |
700 JSObject::AddProperty(webassembly, isolate->factory()->CompileError_string(), | 699 JSObject::AddProperty(webassembly, isolate->factory()->CompileError_string(), |
701 compile_error, attributes); | 700 compile_error, attributes); |
702 Handle<JSFunction> link_error( | 701 Handle<JSFunction> link_error( |
703 isolate->native_context()->wasm_link_error_function()); | 702 isolate->native_context()->wasm_link_error_function()); |
704 JSObject::AddProperty(webassembly, isolate->factory()->LinkError_string(), | 703 JSObject::AddProperty(webassembly, isolate->factory()->LinkError_string(), |
705 link_error, attributes); | 704 link_error, attributes); |
706 Handle<JSFunction> runtime_error( | 705 Handle<JSFunction> runtime_error( |
707 isolate->native_context()->wasm_runtime_error_function()); | 706 isolate->native_context()->wasm_runtime_error_function()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); | 765 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); |
767 return HasBrand(value, symbol); | 766 return HasBrand(value, symbol); |
768 } | 767 } |
769 | 768 |
770 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { | 769 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { |
771 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); | 770 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); |
772 return HasBrand(value, symbol); | 771 return HasBrand(value, symbol); |
773 } | 772 } |
774 } // namespace internal | 773 } // namespace internal |
775 } // namespace v8 | 774 } // namespace v8 |
OLD | NEW |