Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: Remove API changes Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 683 }
684 } 684 }
685 } 685 }
686 686
687 // weak_wasm_module may have been cleared, meaning the module object 687 // weak_wasm_module may have been cleared, meaning the module object
688 // was GC-ed. In that case, there won't be any new instances created, 688 // was GC-ed. In that case, there won't be any new instances created,
689 // and we don't need to maintain the links between instances. 689 // and we don't need to maintain the links between instances.
690 if (!weak_wasm_module->cleared()) { 690 if (!weak_wasm_module->cleared()) {
691 JSObject* wasm_module = JSObject::cast(weak_wasm_module->value()); 691 JSObject* wasm_module = JSObject::cast(weak_wasm_module->value());
692 WasmCompiledModule* current_template = 692 WasmCompiledModule* current_template =
693 WasmCompiledModule::cast(wasm_module->GetInternalField(0)); 693 WasmCompiledModule::cast(wasm_module->GetEmbedderField(0));
694 694
695 TRACE("chain before {\n"); 695 TRACE("chain before {\n");
696 TRACE_CHAIN(current_template); 696 TRACE_CHAIN(current_template);
697 TRACE("}\n"); 697 TRACE("}\n");
698 698
699 DCHECK(!current_template->has_weak_prev_instance()); 699 DCHECK(!current_template->has_weak_prev_instance());
700 WeakCell* next = compiled_module->maybe_ptr_to_weak_next_instance(); 700 WeakCell* next = compiled_module->maybe_ptr_to_weak_next_instance();
701 WeakCell* prev = compiled_module->maybe_ptr_to_weak_prev_instance(); 701 WeakCell* prev = compiled_module->maybe_ptr_to_weak_prev_instance();
702 702
703 if (current_template == compiled_module) { 703 if (current_template == compiled_module) {
704 if (next == nullptr) { 704 if (next == nullptr) {
705 ResetCompiledModule(isolate, owner, compiled_module); 705 ResetCompiledModule(isolate, owner, compiled_module);
706 } else { 706 } else {
707 DCHECK(next->value()->IsFixedArray()); 707 DCHECK(next->value()->IsFixedArray());
708 wasm_module->SetInternalField(0, next->value()); 708 wasm_module->SetEmbedderField(0, next->value());
709 DCHECK_NULL(prev); 709 DCHECK_NULL(prev);
710 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance(); 710 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance();
711 } 711 }
712 } else { 712 } else {
713 DCHECK(!(prev == nullptr && next == nullptr)); 713 DCHECK(!(prev == nullptr && next == nullptr));
714 // the only reason prev or next would be cleared is if the 714 // the only reason prev or next would be cleared is if the
715 // respective objects got collected, but if that happened, 715 // respective objects got collected, but if that happened,
716 // we would have relinked the list. 716 // we would have relinked the list.
717 if (prev != nullptr) { 717 if (prev != nullptr) {
718 DCHECK(!prev->cleared()); 718 DCHECK(!prev->cleared());
719 if (next == nullptr) { 719 if (next == nullptr) {
720 WasmCompiledModule::cast(prev->value())->reset_weak_next_instance(); 720 WasmCompiledModule::cast(prev->value())->reset_weak_next_instance();
721 } else { 721 } else {
722 WasmCompiledModule::cast(prev->value()) 722 WasmCompiledModule::cast(prev->value())
723 ->set_ptr_to_weak_next_instance(next); 723 ->set_ptr_to_weak_next_instance(next);
724 } 724 }
725 } 725 }
726 if (next != nullptr) { 726 if (next != nullptr) {
727 DCHECK(!next->cleared()); 727 DCHECK(!next->cleared());
728 if (prev == nullptr) { 728 if (prev == nullptr) {
729 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance(); 729 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance();
730 } else { 730 } else {
731 WasmCompiledModule::cast(next->value()) 731 WasmCompiledModule::cast(next->value())
732 ->set_ptr_to_weak_prev_instance(prev); 732 ->set_ptr_to_weak_prev_instance(prev);
733 } 733 }
734 } 734 }
735 } 735 }
736 TRACE("chain after {\n"); 736 TRACE("chain after {\n");
737 TRACE_CHAIN(WasmCompiledModule::cast(wasm_module->GetInternalField(0))); 737 TRACE_CHAIN(WasmCompiledModule::cast(wasm_module->GetEmbedderField(0)));
738 TRACE("}\n"); 738 TRACE("}\n");
739 } 739 }
740 compiled_module->reset_weak_owning_instance(); 740 compiled_module->reset_weak_owning_instance();
741 GlobalHandles::Destroy(reinterpret_cast<Object**>(p)); 741 GlobalHandles::Destroy(reinterpret_cast<Object**>(p));
742 TRACE("}\n"); 742 TRACE("}\n");
743 } 743 }
744 744
745 std::pair<int, int> GetFunctionOffsetAndLength( 745 std::pair<int, int> GetFunctionOffsetAndLength(
746 Handle<WasmCompiledModule> compiled_module, int func_index) { 746 Handle<WasmCompiledModule> compiled_module, int func_index) {
747 WasmModule* module = compiled_module->module(); 747 WasmModule* module = compiled_module->module();
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 // Publish the new instance to the instances chain. 1298 // Publish the new instance to the instances chain.
1299 { 1299 {
1300 DisallowHeapAllocation no_gc; 1300 DisallowHeapAllocation no_gc;
1301 if (!link_to_original.is_null()) { 1301 if (!link_to_original.is_null()) {
1302 compiled_module_->set_weak_next_instance( 1302 compiled_module_->set_weak_next_instance(
1303 link_to_original.ToHandleChecked()); 1303 link_to_original.ToHandleChecked());
1304 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone); 1304 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone);
1305 compiled_module_->set_weak_wasm_module( 1305 compiled_module_->set_weak_wasm_module(
1306 original.ToHandleChecked()->weak_wasm_module()); 1306 original.ToHandleChecked()->weak_wasm_module());
1307 } 1307 }
1308 module_object_->SetInternalField(0, *compiled_module_); 1308 module_object_->SetEmbedderField(0, *compiled_module_);
1309 compiled_module_->set_weak_owning_instance(link_to_owning_instance); 1309 compiled_module_->set_weak_owning_instance(link_to_owning_instance);
1310 GlobalHandles::MakeWeak(global_handle.location(), 1310 GlobalHandles::MakeWeak(global_handle.location(),
1311 global_handle.location(), &InstanceFinalizer, 1311 global_handle.location(), &InstanceFinalizer,
1312 v8::WeakCallbackType::kFinalizer); 1312 v8::WeakCallbackType::kFinalizer);
1313 } 1313 }
1314 } 1314 }
1315 1315
1316 //-------------------------------------------------------------------------- 1316 //--------------------------------------------------------------------------
1317 // Debugging support. 1317 // Debugging support.
1318 //-------------------------------------------------------------------------- 1318 //--------------------------------------------------------------------------
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2753 Handle<String> module_property_name = 2753 Handle<String> module_property_name =
2754 isolate->factory()->InternalizeUtf8String("module"); 2754 isolate->factory()->InternalizeUtf8String("module");
2755 Handle<String> instance_property_name = 2755 Handle<String> instance_property_name =
2756 isolate->factory()->InternalizeUtf8String("instance"); 2756 isolate->factory()->InternalizeUtf8String("instance");
2757 JSObject::AddProperty(ret, module_property_name, module, NONE); 2757 JSObject::AddProperty(ret, module_property_name, module, NONE);
2758 JSObject::AddProperty(ret, instance_property_name, 2758 JSObject::AddProperty(ret, instance_property_name,
2759 instance_object.ToHandleChecked(), NONE); 2759 instance_object.ToHandleChecked(), NONE);
2760 2760
2761 ResolvePromise(isolate, promise, ret); 2761 ResolvePromise(isolate, promise, ret);
2762 } 2762 }
OLDNEW
« src/objects.h ('K') | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698