| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
| 8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
| 9 #include "src/base/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| 11 #include "src/compiler/wasm-compiler.h" | 11 #include "src/compiler/wasm-compiler.h" |
| 12 #include "src/debug/interface-types.h" | 12 #include "src/debug/interface-types.h" |
| 13 #include "src/objects.h" | 13 #include "src/objects.h" |
| 14 #include "src/property-descriptor.h" | 14 #include "src/property-descriptor.h" |
| 15 #include "src/simulator.h" | 15 #include "src/simulator.h" |
| 16 #include "src/snapshot/snapshot.h" | 16 #include "src/snapshot/snapshot.h" |
| 17 #include "src/v8.h" | 17 #include "src/v8.h" |
| 18 | 18 |
| 19 #include "src/asmjs/asm-wasm-builder.h" |
| 20 |
| 19 #include "src/wasm/function-body-decoder.h" | 21 #include "src/wasm/function-body-decoder.h" |
| 20 #include "src/wasm/module-decoder.h" | 22 #include "src/wasm/module-decoder.h" |
| 21 #include "src/wasm/wasm-js.h" | 23 #include "src/wasm/wasm-js.h" |
| 22 #include "src/wasm/wasm-limits.h" | 24 #include "src/wasm/wasm-limits.h" |
| 23 #include "src/wasm/wasm-module.h" | 25 #include "src/wasm/wasm-module.h" |
| 24 #include "src/wasm/wasm-objects.h" | 26 #include "src/wasm/wasm-objects.h" |
| 25 #include "src/wasm/wasm-result.h" | 27 #include "src/wasm/wasm-result.h" |
| 26 | 28 |
| 27 using namespace v8::internal; | 29 using namespace v8::internal; |
| 28 using namespace v8::internal::wasm; | 30 using namespace v8::internal::wasm; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 672 |
| 671 DCHECK(!current_template->has_weak_prev_instance()); | 673 DCHECK(!current_template->has_weak_prev_instance()); |
| 672 WeakCell* next = compiled_module->maybe_ptr_to_weak_next_instance(); | 674 WeakCell* next = compiled_module->maybe_ptr_to_weak_next_instance(); |
| 673 WeakCell* prev = compiled_module->maybe_ptr_to_weak_prev_instance(); | 675 WeakCell* prev = compiled_module->maybe_ptr_to_weak_prev_instance(); |
| 674 | 676 |
| 675 if (current_template == compiled_module) { | 677 if (current_template == compiled_module) { |
| 676 if (next == nullptr) { | 678 if (next == nullptr) { |
| 677 ResetCompiledModule(isolate, owner, compiled_module); | 679 ResetCompiledModule(isolate, owner, compiled_module); |
| 678 } else { | 680 } else { |
| 679 DCHECK(next->value()->IsFixedArray()); | 681 DCHECK(next->value()->IsFixedArray()); |
| 680 wasm_module->SetInternalField(0, next->value()); | 682 wasm_module->SetInternalField(WasmModuleObject::kCompiledModule, |
| 683 next->value()); |
| 681 DCHECK_NULL(prev); | 684 DCHECK_NULL(prev); |
| 682 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance(); | 685 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance(); |
| 683 } | 686 } |
| 684 } else { | 687 } else { |
| 685 DCHECK(!(prev == nullptr && next == nullptr)); | 688 DCHECK(!(prev == nullptr && next == nullptr)); |
| 686 // the only reason prev or next would be cleared is if the | 689 // the only reason prev or next would be cleared is if the |
| 687 // respective objects got collected, but if that happened, | 690 // respective objects got collected, but if that happened, |
| 688 // we would have relinked the list. | 691 // we would have relinked the list. |
| 689 if (prev != nullptr) { | 692 if (prev != nullptr) { |
| 690 DCHECK(!prev->cleared()); | 693 DCHECK(!prev->cleared()); |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 // Publish the new instance to the instances chain. | 1419 // Publish the new instance to the instances chain. |
| 1417 { | 1420 { |
| 1418 DisallowHeapAllocation no_gc; | 1421 DisallowHeapAllocation no_gc; |
| 1419 if (!link_to_original.is_null()) { | 1422 if (!link_to_original.is_null()) { |
| 1420 compiled_module_->set_weak_next_instance( | 1423 compiled_module_->set_weak_next_instance( |
| 1421 link_to_original.ToHandleChecked()); | 1424 link_to_original.ToHandleChecked()); |
| 1422 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone); | 1425 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone); |
| 1423 compiled_module_->set_weak_wasm_module( | 1426 compiled_module_->set_weak_wasm_module( |
| 1424 original.ToHandleChecked()->weak_wasm_module()); | 1427 original.ToHandleChecked()->weak_wasm_module()); |
| 1425 } | 1428 } |
| 1426 module_object_->SetInternalField(0, *compiled_module_); | 1429 module_object_->SetInternalField(WasmModuleObject::kCompiledModule, |
| 1430 *compiled_module_); |
| 1427 compiled_module_->set_weak_owning_instance(link_to_owning_instance); | 1431 compiled_module_->set_weak_owning_instance(link_to_owning_instance); |
| 1428 GlobalHandles::MakeWeak(global_handle.location(), | 1432 GlobalHandles::MakeWeak(global_handle.location(), |
| 1429 global_handle.location(), &InstanceFinalizer, | 1433 global_handle.location(), &InstanceFinalizer, |
| 1430 v8::WeakCallbackType::kFinalizer); | 1434 v8::WeakCallbackType::kFinalizer); |
| 1431 } | 1435 } |
| 1432 } | 1436 } |
| 1433 //-------------------------------------------------------------------------- | 1437 //-------------------------------------------------------------------------- |
| 1434 // Run the start function if one was specified. | 1438 // Run the start function if one was specified. |
| 1435 //-------------------------------------------------------------------------- | 1439 //-------------------------------------------------------------------------- |
| 1436 if (module_->start_function_index >= 0) { | 1440 if (module_->start_function_index >= 0) { |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 } | 1964 } |
| 1961 | 1965 |
| 1962 // Skip duplicates for asm.js. | 1966 // Skip duplicates for asm.js. |
| 1963 if (module_->origin == kAsmJsOrigin) { | 1967 if (module_->origin == kAsmJsOrigin) { |
| 1964 v8::Maybe<bool> status = | 1968 v8::Maybe<bool> status = |
| 1965 JSReceiver::HasOwnProperty(exports_object, name); | 1969 JSReceiver::HasOwnProperty(exports_object, name); |
| 1966 if (status.FromMaybe(false)) { | 1970 if (status.FromMaybe(false)) { |
| 1967 continue; | 1971 continue; |
| 1968 } | 1972 } |
| 1969 } | 1973 } |
| 1974 // Put special asm.js functions on internal fields. |
| 1975 if (module_->origin == kAsmJsOrigin) { |
| 1976 Handle<String> foreign_init(isolate_->factory()->InternalizeUtf8String( |
| 1977 AsmWasmBuilder::foreign_init_name)); |
| 1978 if (String::Equals(foreign_init, name)) { |
| 1979 module_object_->SetInternalField(WasmModuleObject::kAsmForeignInit, |
| 1980 *desc.value()); |
| 1981 continue; |
| 1982 } |
| 1983 } |
| 1970 v8::Maybe<bool> status = JSReceiver::DefineOwnProperty( | 1984 v8::Maybe<bool> status = JSReceiver::DefineOwnProperty( |
| 1971 isolate_, exports_object, name, &desc, Object::THROW_ON_ERROR); | 1985 isolate_, exports_object, name, &desc, Object::THROW_ON_ERROR); |
| 1972 if (!status.IsJust()) { | 1986 if (!status.IsJust()) { |
| 1973 thrower_->LinkError("export of %.*s failed.", name->length(), | 1987 thrower_->LinkError("export of %.*s failed.", name->length(), |
| 1974 name->ToCString().get()); | 1988 name->ToCString().get()); |
| 1975 return; | 1989 return; |
| 1976 } | 1990 } |
| 1977 } | 1991 } |
| 1978 | 1992 |
| 1979 if (module_->origin == kWasmOrigin) { | 1993 if (module_->origin == kWasmOrigin) { |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2564 | 2578 |
| 2565 JSObject::AddProperty(entry, name_string, export_name.ToHandleChecked(), | 2579 JSObject::AddProperty(entry, name_string, export_name.ToHandleChecked(), |
| 2566 NONE); | 2580 NONE); |
| 2567 JSObject::AddProperty(entry, kind_string, export_kind, NONE); | 2581 JSObject::AddProperty(entry, kind_string, export_kind, NONE); |
| 2568 | 2582 |
| 2569 storage->set(index, *entry); | 2583 storage->set(index, *entry); |
| 2570 } | 2584 } |
| 2571 | 2585 |
| 2572 return array_object; | 2586 return array_object; |
| 2573 } | 2587 } |
| OLD | NEW |