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

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

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: DEPRECATE_SOON(GetInternalField) 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 TRACE("Finalizing %d {\n", compiled_module->instance_id()); 670 TRACE("Finalizing %d {\n", compiled_module->instance_id());
671 DCHECK(compiled_module->has_weak_wasm_module()); 671 DCHECK(compiled_module->has_weak_wasm_module());
672 WeakCell* weak_wasm_module = compiled_module->ptr_to_weak_wasm_module(); 672 WeakCell* weak_wasm_module = compiled_module->ptr_to_weak_wasm_module();
673 673
674 // weak_wasm_module may have been cleared, meaning the module object 674 // weak_wasm_module may have been cleared, meaning the module object
675 // was GC-ed. In that case, there won't be any new instances created, 675 // was GC-ed. In that case, there won't be any new instances created,
676 // and we don't need to maintain the links between instances. 676 // and we don't need to maintain the links between instances.
677 if (!weak_wasm_module->cleared()) { 677 if (!weak_wasm_module->cleared()) {
678 JSObject* wasm_module = JSObject::cast(weak_wasm_module->value()); 678 JSObject* wasm_module = JSObject::cast(weak_wasm_module->value());
679 WasmCompiledModule* current_template = 679 WasmCompiledModule* current_template =
680 WasmCompiledModule::cast(wasm_module->GetInternalField(0)); 680 WasmCompiledModule::cast(wasm_module->GetEmbedderField(0));
681 681
682 TRACE("chain before {\n"); 682 TRACE("chain before {\n");
683 TRACE_CHAIN(current_template); 683 TRACE_CHAIN(current_template);
684 TRACE("}\n"); 684 TRACE("}\n");
685 685
686 DCHECK(!current_template->has_weak_prev_instance()); 686 DCHECK(!current_template->has_weak_prev_instance());
687 WeakCell* next = compiled_module->maybe_ptr_to_weak_next_instance(); 687 WeakCell* next = compiled_module->maybe_ptr_to_weak_next_instance();
688 WeakCell* prev = compiled_module->maybe_ptr_to_weak_prev_instance(); 688 WeakCell* prev = compiled_module->maybe_ptr_to_weak_prev_instance();
689 689
690 if (current_template == compiled_module) { 690 if (current_template == compiled_module) {
691 if (next == nullptr) { 691 if (next == nullptr) {
692 ResetCompiledModule(isolate, owner, compiled_module); 692 ResetCompiledModule(isolate, owner, compiled_module);
693 } else { 693 } else {
694 DCHECK(next->value()->IsFixedArray()); 694 DCHECK(next->value()->IsFixedArray());
695 wasm_module->SetInternalField(0, next->value()); 695 wasm_module->SetEmbedderField(0, next->value());
696 DCHECK_NULL(prev); 696 DCHECK_NULL(prev);
697 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance(); 697 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance();
698 } 698 }
699 } else { 699 } else {
700 DCHECK(!(prev == nullptr && next == nullptr)); 700 DCHECK(!(prev == nullptr && next == nullptr));
701 // the only reason prev or next would be cleared is if the 701 // the only reason prev or next would be cleared is if the
702 // respective objects got collected, but if that happened, 702 // respective objects got collected, but if that happened,
703 // we would have relinked the list. 703 // we would have relinked the list.
704 if (prev != nullptr) { 704 if (prev != nullptr) {
705 DCHECK(!prev->cleared()); 705 DCHECK(!prev->cleared());
706 if (next == nullptr) { 706 if (next == nullptr) {
707 WasmCompiledModule::cast(prev->value())->reset_weak_next_instance(); 707 WasmCompiledModule::cast(prev->value())->reset_weak_next_instance();
708 } else { 708 } else {
709 WasmCompiledModule::cast(prev->value()) 709 WasmCompiledModule::cast(prev->value())
710 ->set_ptr_to_weak_next_instance(next); 710 ->set_ptr_to_weak_next_instance(next);
711 } 711 }
712 } 712 }
713 if (next != nullptr) { 713 if (next != nullptr) {
714 DCHECK(!next->cleared()); 714 DCHECK(!next->cleared());
715 if (prev == nullptr) { 715 if (prev == nullptr) {
716 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance(); 716 WasmCompiledModule::cast(next->value())->reset_weak_prev_instance();
717 } else { 717 } else {
718 WasmCompiledModule::cast(next->value()) 718 WasmCompiledModule::cast(next->value())
719 ->set_ptr_to_weak_prev_instance(prev); 719 ->set_ptr_to_weak_prev_instance(prev);
720 } 720 }
721 } 721 }
722 } 722 }
723 TRACE("chain after {\n"); 723 TRACE("chain after {\n");
724 TRACE_CHAIN(WasmCompiledModule::cast(wasm_module->GetInternalField(0))); 724 TRACE_CHAIN(WasmCompiledModule::cast(wasm_module->GetEmbedderField(0)));
725 TRACE("}\n"); 725 TRACE("}\n");
726 } 726 }
727 compiled_module->reset_weak_owning_instance(); 727 compiled_module->reset_weak_owning_instance();
728 GlobalHandles::Destroy(reinterpret_cast<Object**>(p)); 728 GlobalHandles::Destroy(reinterpret_cast<Object**>(p));
729 TRACE("}\n"); 729 TRACE("}\n");
730 } 730 }
731 731
732 std::pair<int, int> GetFunctionOffsetAndLength( 732 std::pair<int, int> GetFunctionOffsetAndLength(
733 Handle<WasmCompiledModule> compiled_module, int func_index) { 733 Handle<WasmCompiledModule> compiled_module, int func_index) {
734 WasmModule* module = compiled_module->module(); 734 WasmModule* module = compiled_module->module();
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 // Publish the new instance to the instances chain. 1278 // Publish the new instance to the instances chain.
1279 { 1279 {
1280 DisallowHeapAllocation no_gc; 1280 DisallowHeapAllocation no_gc;
1281 if (!link_to_original.is_null()) { 1281 if (!link_to_original.is_null()) {
1282 compiled_module_->set_weak_next_instance( 1282 compiled_module_->set_weak_next_instance(
1283 link_to_original.ToHandleChecked()); 1283 link_to_original.ToHandleChecked());
1284 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone); 1284 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone);
1285 compiled_module_->set_weak_wasm_module( 1285 compiled_module_->set_weak_wasm_module(
1286 original.ToHandleChecked()->weak_wasm_module()); 1286 original.ToHandleChecked()->weak_wasm_module());
1287 } 1287 }
1288 module_object_->SetInternalField(0, *compiled_module_); 1288 module_object_->SetEmbedderField(0, *compiled_module_);
1289 compiled_module_->set_weak_owning_instance(link_to_owning_instance); 1289 compiled_module_->set_weak_owning_instance(link_to_owning_instance);
1290 GlobalHandles::MakeWeak(global_handle.location(), 1290 GlobalHandles::MakeWeak(global_handle.location(),
1291 global_handle.location(), &InstanceFinalizer, 1291 global_handle.location(), &InstanceFinalizer,
1292 v8::WeakCallbackType::kFinalizer); 1292 v8::WeakCallbackType::kFinalizer);
1293 } 1293 }
1294 } 1294 }
1295 1295
1296 //-------------------------------------------------------------------------- 1296 //--------------------------------------------------------------------------
1297 // Set all breakpoints that were set on the shared module. 1297 // Set all breakpoints that were set on the shared module.
1298 //-------------------------------------------------------------------------- 1298 //--------------------------------------------------------------------------
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 Handle<String> module_property_name = 2721 Handle<String> module_property_name =
2722 isolate->factory()->InternalizeUtf8String("module"); 2722 isolate->factory()->InternalizeUtf8String("module");
2723 Handle<String> instance_property_name = 2723 Handle<String> instance_property_name =
2724 isolate->factory()->InternalizeUtf8String("instance"); 2724 isolate->factory()->InternalizeUtf8String("instance");
2725 JSObject::AddProperty(ret, module_property_name, module, NONE); 2725 JSObject::AddProperty(ret, module_property_name, module, NONE);
2726 JSObject::AddProperty(ret, instance_property_name, 2726 JSObject::AddProperty(ret, instance_property_name,
2727 instance_object.ToHandleChecked(), NONE); 2727 instance_object.ToHandleChecked(), NONE);
2728 2728
2729 ResolvePromise(isolate, promise, ret); 2729 ResolvePromise(isolate, promise, ret);
2730 } 2730 }
OLDNEW
« include/v8-experimental.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