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/macro-assembler.h" | 5 #include "src/macro-assembler.h" |
6 #include "src/objects.h" | 6 #include "src/objects.h" |
7 #include "src/property-descriptor.h" | 7 #include "src/property-descriptor.h" |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/simulator.h" | 10 #include "src/simulator.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 function_name.length(), function_name.start(), error); | 346 function_name.length(), function_name.start(), error); |
347 } else { | 347 } else { |
348 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, | 348 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, |
349 module_name.length(), module_name.start(), error); | 349 module_name.length(), module_name.start(), error); |
350 } | 350 } |
351 thrower.Error("Import "); | 351 thrower.Error("Import "); |
352 return MaybeHandle<JSFunction>(); | 352 return MaybeHandle<JSFunction>(); |
353 } | 353 } |
354 | 354 |
355 static MaybeHandle<JSFunction> LookupFunction( | 355 static MaybeHandle<JSFunction> LookupFunction( |
356 ErrorThrower& thrower, Factory* factory, Handle<JSObject> ffi, | 356 ErrorThrower& thrower, Factory* factory, Handle<JSReceiver> ffi, |
357 uint32_t index, wasm::WasmName module_name, wasm::WasmName function_name) { | 357 uint32_t index, wasm::WasmName module_name, wasm::WasmName function_name) { |
358 if (ffi.is_null()) { | 358 if (ffi.is_null()) { |
359 return ReportFFIError(thrower, "FFI is not an object", index, module_name, | 359 return ReportFFIError(thrower, "FFI is not an object", index, module_name, |
360 function_name); | 360 function_name); |
361 } | 361 } |
362 | 362 |
363 // Look up the module first. | 363 // Look up the module first. |
364 Handle<String> name = factory->InternalizeUtf8String(module_name); | 364 Handle<String> name = factory->InternalizeUtf8String(module_name); |
365 MaybeHandle<Object> result = Object::GetProperty(ffi, name); | 365 MaybeHandle<Object> result = Object::GetProperty(ffi, name); |
366 if (result.is_null()) { | 366 if (result.is_null()) { |
(...skipping 30 matching lines...) Expand all Loading... |
397 | 397 |
398 return Handle<JSFunction>::cast(function); | 398 return Handle<JSFunction>::cast(function); |
399 } | 399 } |
400 | 400 |
401 // Instantiates a wasm module as a JSObject. | 401 // Instantiates a wasm module as a JSObject. |
402 // * allocates a backing store of {mem_size} bytes. | 402 // * allocates a backing store of {mem_size} bytes. |
403 // * installs a named property "memory" for that buffer if exported | 403 // * installs a named property "memory" for that buffer if exported |
404 // * installs named properties on the object for exported functions | 404 // * installs named properties on the object for exported functions |
405 // * compiles wasm code to machine code | 405 // * compiles wasm code to machine code |
406 MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, | 406 MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, |
407 Handle<JSObject> ffi, | 407 Handle<JSReceiver> ffi, |
408 Handle<JSArrayBuffer> memory) { | 408 Handle<JSArrayBuffer> memory) { |
409 HistogramTimerScope wasm_instantiate_module_time_scope( | 409 HistogramTimerScope wasm_instantiate_module_time_scope( |
410 isolate->counters()->wasm_instantiate_module_time()); | 410 isolate->counters()->wasm_instantiate_module_time()); |
411 this->shared_isolate = isolate; // TODO(titzer): have a real shared isolate. | 411 this->shared_isolate = isolate; // TODO(titzer): have a real shared isolate. |
412 ErrorThrower thrower(isolate, "WasmModule::Instantiate()"); | 412 ErrorThrower thrower(isolate, "WasmModule::Instantiate()"); |
413 Factory* factory = isolate->factory(); | 413 Factory* factory = isolate->factory(); |
414 | 414 |
415 PropertyDescriptor desc; | 415 PropertyDescriptor desc; |
416 desc.set_writable(false); | 416 desc.set_writable(false); |
417 | 417 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); | 815 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); |
816 if (func_names_arr_obj->IsUndefined()) | 816 if (func_names_arr_obj->IsUndefined()) |
817 return func_names_arr_obj; // Return undefined. | 817 return func_names_arr_obj; // Return undefined. |
818 return GetWasmFunctionNameFromTable( | 818 return GetWasmFunctionNameFromTable( |
819 Handle<ByteArray>::cast(func_names_arr_obj), func_index); | 819 Handle<ByteArray>::cast(func_names_arr_obj), func_index); |
820 } | 820 } |
821 | 821 |
822 } // namespace wasm | 822 } // namespace wasm |
823 } // namespace internal | 823 } // namespace internal |
824 } // namespace v8 | 824 } // namespace v8 |
OLD | NEW |