| 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/assert-scope.h" | 7 #include "src/assert-scope.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/execution.h" | 9 #include "src/execution.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 DCHECK_IMPLIES(length, start != nullptr); | 115 DCHECK_IMPLIES(length, start != nullptr); |
| 116 if (length == 0) { | 116 if (length == 0) { |
| 117 thrower->CompileError("BufferSource argument is empty"); | 117 thrower->CompileError("BufferSource argument is empty"); |
| 118 } | 118 } |
| 119 if (length > i::wasm::kV8MaxWasmModuleSize) { | 119 if (length > i::wasm::kV8MaxWasmModuleSize) { |
| 120 thrower->RangeError("buffer source exceeds maximum size of %zu (is %zu)", | 120 thrower->RangeError("buffer source exceeds maximum size of %zu (is %zu)", |
| 121 i::wasm::kV8MaxWasmModuleSize, length); | 121 i::wasm::kV8MaxWasmModuleSize, length); |
| 122 } | 122 } |
| 123 if (thrower->error()) return i::wasm::ModuleWireBytes(nullptr, nullptr); | 123 if (thrower->error()) return i::wasm::ModuleWireBytes(nullptr, nullptr); |
| 124 // TODO(titzer): use the handle as well? | |
| 125 return i::wasm::ModuleWireBytes(start, start + length); | 124 return i::wasm::ModuleWireBytes(start, start + length); |
| 126 } | 125 } |
| 127 | 126 |
| 128 i::MaybeHandle<i::JSReceiver> GetValueAsImports(Local<Value> arg, | 127 i::MaybeHandle<i::JSReceiver> GetValueAsImports(Local<Value> arg, |
| 129 ErrorThrower* thrower) { | 128 ErrorThrower* thrower) { |
| 130 if (arg->IsUndefined()) return {}; | 129 if (arg->IsUndefined()) return {}; |
| 131 | 130 |
| 132 if (!arg->IsObject()) { | 131 if (!arg->IsObject()) { |
| 133 thrower->TypeError("Argument 1 must be an object"); | 132 thrower->TypeError("Argument 1 must be an object"); |
| 134 return {}; | 133 return {}; |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 static_cast<v8::PropertyAttribute>(v8::DontEnum); | 831 static_cast<v8::PropertyAttribute>(v8::DontEnum); |
| 833 Utils::ToLocal(object)->SetAccessorProperty(Utils::ToLocal(name), | 832 Utils::ToLocal(object)->SetAccessorProperty(Utils::ToLocal(name), |
| 834 Utils::ToLocal(function), | 833 Utils::ToLocal(function), |
| 835 Local<Function>(), attributes); | 834 Local<Function>(), attributes); |
| 836 return function; | 835 return function; |
| 837 } | 836 } |
| 838 | 837 |
| 839 void WasmJs::Install(Isolate* isolate) { | 838 void WasmJs::Install(Isolate* isolate) { |
| 840 Handle<JSGlobalObject> global = isolate->global_object(); | 839 Handle<JSGlobalObject> global = isolate->global_object(); |
| 841 Handle<Context> context(global->native_context(), isolate); | 840 Handle<Context> context(global->native_context(), isolate); |
| 842 // TODO(titzer): once FLAG_expose_wasm is gone, this should become a DCHECK. | 841 // Check if the map is already installed and do nothing otherwise. |
| 843 if (context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) return; | 842 if (context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) return; |
| 844 | 843 |
| 845 // Install Maps. | 844 // Install Maps. |
| 846 | |
| 847 // TODO(titzer): Also make one for strict mode functions? | |
| 848 Handle<Map> prev_map = Handle<Map>(context->sloppy_function_map(), isolate); | 845 Handle<Map> prev_map = Handle<Map>(context->sloppy_function_map(), isolate); |
| 849 | 846 |
| 850 InstanceType instance_type = prev_map->instance_type(); | 847 InstanceType instance_type = prev_map->instance_type(); |
| 851 int embedder_fields = JSObject::GetEmbedderFieldCount(*prev_map); | 848 int embedder_fields = JSObject::GetEmbedderFieldCount(*prev_map); |
| 852 CHECK_EQ(0, embedder_fields); | 849 CHECK_EQ(0, embedder_fields); |
| 853 int pre_allocated = | 850 int pre_allocated = |
| 854 prev_map->GetInObjectProperties() - prev_map->unused_property_fields(); | 851 prev_map->GetInObjectProperties() - prev_map->unused_property_fields(); |
| 855 int instance_size = 0; | 852 int instance_size = 0; |
| 856 int in_object_properties = 0; | 853 int in_object_properties = 0; |
| 857 int wasm_embedder_fields = embedder_fields + 1 // module instance object | 854 int wasm_embedder_fields = embedder_fields + 1 // module instance object |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); | 998 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); |
| 1002 return HasBrand(value, symbol); | 999 return HasBrand(value, symbol); |
| 1003 } | 1000 } |
| 1004 | 1001 |
| 1005 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { | 1002 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { |
| 1006 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); | 1003 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); |
| 1007 return HasBrand(value, symbol); | 1004 return HasBrand(value, symbol); |
| 1008 } | 1005 } |
| 1009 } // namespace internal | 1006 } // namespace internal |
| 1010 } // namespace v8 | 1007 } // namespace v8 |
| OLD | NEW |