Commit fa7171c5 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove obsolete {weak_exported_functions} field.

R=clemensh@chromium.org

Change-Id: I51e4210334a50ebb9ed7172c112083d6c3d784d9
Reviewed-on: https://chromium-review.googlesource.com/1000776Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52477}
parent e6c4e6d1
...@@ -1504,7 +1504,6 @@ void WasmCompiledModule::WasmCompiledModuleVerify() { ...@@ -1504,7 +1504,6 @@ void WasmCompiledModule::WasmCompiledModuleVerify() {
VerifyObjectField(kSharedOffset); VerifyObjectField(kSharedOffset);
VerifyObjectField(kNativeContextOffset); VerifyObjectField(kNativeContextOffset);
VerifyObjectField(kExportWrappersOffset); VerifyObjectField(kExportWrappersOffset);
VerifyObjectField(kWeakExportedFunctionsOffset);
VerifyObjectField(kNextInstanceOffset); VerifyObjectField(kNextInstanceOffset);
VerifyObjectField(kPrevInstanceOffset); VerifyObjectField(kPrevInstanceOffset);
VerifyObjectField(kOwningInstanceOffset); VerifyObjectField(kOwningInstanceOffset);
......
...@@ -2165,22 +2165,8 @@ void InstanceBuilder::ProcessExports( ...@@ -2165,22 +2165,8 @@ void InstanceBuilder::ProcessExports(
desc.set_enumerable(true); desc.set_enumerable(true);
desc.set_configurable(module_->is_asm_js()); desc.set_configurable(module_->is_asm_js());
// Store weak references to all exported functions.
Handle<FixedArray> weak_exported_functions;
if (compiled_module->has_weak_exported_functions()) {
weak_exported_functions =
handle(compiled_module->weak_exported_functions(), isolate_);
} else {
int export_count = 0;
for (WasmExport& exp : module_->export_table) {
if (exp.kind == kExternalFunction) ++export_count;
}
weak_exported_functions = isolate_->factory()->NewFixedArray(export_count);
compiled_module->set_weak_exported_functions(*weak_exported_functions);
}
// Process each export in the export table. // Process each export in the export table.
int export_index = 0; // Index into {weak_exported_functions}. int export_index = 0; // Index into {export_wrappers}.
for (WasmExport& exp : module_->export_table) { for (WasmExport& exp : module_->export_table) {
Handle<String> name = Handle<String> name =
WasmSharedModuleData::ExtractUtf8StringFromModuleBytes( WasmSharedModuleData::ExtractUtf8StringFromModuleBytes(
...@@ -2221,10 +2207,6 @@ void InstanceBuilder::ProcessExports( ...@@ -2221,10 +2207,6 @@ void InstanceBuilder::ProcessExports(
js_wrappers_[exp.index] = js_function; js_wrappers_[exp.index] = js_function;
} }
desc.set_value(js_function); desc.set_value(js_function);
Handle<WeakCell> weak_export =
isolate_->factory()->NewWeakCell(js_function);
DCHECK_GT(weak_exported_functions->length(), export_index);
weak_exported_functions->set(export_index, *weak_export);
export_index++; export_index++;
break; break;
} }
...@@ -2289,7 +2271,7 @@ void InstanceBuilder::ProcessExports( ...@@ -2289,7 +2271,7 @@ void InstanceBuilder::ProcessExports(
return; return;
} }
} }
DCHECK_EQ(export_index, weak_exported_functions->length()); DCHECK_EQ(export_index, export_wrappers->length());
if (module_->is_wasm()) { if (module_->is_wasm()) {
v8::Maybe<bool> success = v8::Maybe<bool> success =
......
...@@ -612,12 +612,9 @@ void RedirectCallsitesInInstance(Isolate* isolate, WasmInstanceObject* instance, ...@@ -612,12 +612,9 @@ void RedirectCallsitesInInstance(Isolate* isolate, WasmInstanceObject* instance,
// TODO(6668): Find instances that imported our code and also patch those. // TODO(6668): Find instances that imported our code and also patch those.
// Redirect all calls in exported functions. // Redirect all calls in exported functions.
FixedArray* weak_exported_functions = FixedArray* export_wrapper = instance->compiled_module()->export_wrappers();
instance->compiled_module()->weak_exported_functions(); for (int i = 0, e = export_wrapper->length(); i != e; ++i) {
for (int i = 0, e = weak_exported_functions->length(); i != e; ++i) { Code* code = Code::cast(export_wrapper->get(i));
WeakCell* weak_function = WeakCell::cast(weak_exported_functions->get(i));
if (weak_function->cleared()) continue;
Code* code = JSFunction::cast(weak_function->value())->code();
RedirectCallsitesInJSWrapperCode(isolate, code, map); RedirectCallsitesInJSWrapperCode(isolate, code, map);
} }
} }
......
...@@ -170,7 +170,6 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>, ...@@ -170,7 +170,6 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>,
WCM_OBJECT(WasmSharedModuleData, shared, kSharedOffset) WCM_OBJECT(WasmSharedModuleData, shared, kSharedOffset)
WCM_WEAK_LINK(Context, native_context, kNativeContextOffset) WCM_WEAK_LINK(Context, native_context, kNativeContextOffset)
WCM_OBJECT(FixedArray, export_wrappers, kExportWrappersOffset) WCM_OBJECT(FixedArray, export_wrappers, kExportWrappersOffset)
WCM_OBJECT(FixedArray, weak_exported_functions, kWeakExportedFunctionsOffset)
WCM_OBJECT(WasmCompiledModule, next_instance, kNextInstanceOffset) WCM_OBJECT(WasmCompiledModule, next_instance, kNextInstanceOffset)
WCM_OBJECT(WasmCompiledModule, prev_instance, kPrevInstanceOffset) WCM_OBJECT(WasmCompiledModule, prev_instance, kPrevInstanceOffset)
WCM_WEAK_LINK(WasmInstanceObject, owning_instance, kOwningInstanceOffset) WCM_WEAK_LINK(WasmInstanceObject, owning_instance, kOwningInstanceOffset)
......
...@@ -473,7 +473,6 @@ class WasmCompiledModule : public Struct { ...@@ -473,7 +473,6 @@ class WasmCompiledModule : public Struct {
V(kSharedOffset, kPointerSize) \ V(kSharedOffset, kPointerSize) \
V(kNativeContextOffset, kPointerSize) \ V(kNativeContextOffset, kPointerSize) \
V(kExportWrappersOffset, kPointerSize) \ V(kExportWrappersOffset, kPointerSize) \
V(kWeakExportedFunctionsOffset, kPointerSize) \
V(kNextInstanceOffset, kPointerSize) \ V(kNextInstanceOffset, kPointerSize) \
V(kPrevInstanceOffset, kPointerSize) \ V(kPrevInstanceOffset, kPointerSize) \
V(kOwningInstanceOffset, kPointerSize) \ V(kOwningInstanceOffset, kPointerSize) \
...@@ -520,8 +519,7 @@ class WasmCompiledModule : public Struct { ...@@ -520,8 +519,7 @@ class WasmCompiledModule : public Struct {
// we embed the generated code with a value, then we track that value here. // we embed the generated code with a value, then we track that value here.
WCM_OBJECT(WasmSharedModuleData, shared) WCM_OBJECT(WasmSharedModuleData, shared)
WCM_WEAK_LINK(Context, native_context) WCM_WEAK_LINK(Context, native_context)
WCM_CONST_OBJECT(FixedArray, export_wrappers) WCM_OBJECT(FixedArray, export_wrappers)
WCM_OBJECT(FixedArray, weak_exported_functions)
WCM_CONST_OBJECT(WasmCompiledModule, next_instance) WCM_CONST_OBJECT(WasmCompiledModule, next_instance)
WCM_CONST_OBJECT(WasmCompiledModule, prev_instance) WCM_CONST_OBJECT(WasmCompiledModule, prev_instance)
WCM_WEAK_LINK(WasmInstanceObject, owning_instance) WCM_WEAK_LINK(WasmInstanceObject, owning_instance)
......
...@@ -133,15 +133,13 @@ Handle<JSFunction> TestingModuleBuilder::WrapCode(uint32_t index) { ...@@ -133,15 +133,13 @@ Handle<JSFunction> TestingModuleBuilder::WrapCode(uint32_t index) {
static_cast<int>(test_module_.functions[index].sig->parameter_count()), static_cast<int>(test_module_.functions[index].sig->parameter_count()),
ret_code); ret_code);
// Add weak reference to exported functions. // Add reference to the exported wrapper code.
Handle<FixedArray> old_arr(compiled_module->weak_exported_functions(), Handle<FixedArray> old_arr(compiled_module->export_wrappers(), isolate_);
isolate_);
Handle<FixedArray> new_arr = Handle<FixedArray> new_arr =
isolate_->factory()->NewFixedArray(old_arr->length() + 1); isolate_->factory()->NewFixedArray(old_arr->length() + 1);
old_arr->CopyTo(0, *new_arr, 0, old_arr->length()); old_arr->CopyTo(0, *new_arr, 0, old_arr->length());
Handle<WeakCell> weak_fn = isolate_->factory()->NewWeakCell(ret); new_arr->set(old_arr->length(), *ret_code);
new_arr->set(old_arr->length(), *weak_fn); compiled_module->set_export_wrappers(*new_arr);
compiled_module->set_weak_exported_functions(*new_arr);
return ret; return ret;
} }
...@@ -232,8 +230,6 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { ...@@ -232,8 +230,6 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
// interpreter when we get a memory. We do have globals, though. // interpreter when we get a memory. We do have globals, though.
native_module_ = compiled_module->GetNativeModule(); native_module_ = compiled_module->GetNativeModule();
Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0);
compiled_module->set_weak_exported_functions(*weak_exported);
DCHECK(compiled_module->IsWasmCompiledModule()); DCHECK(compiled_module->IsWasmCompiledModule());
script->set_wasm_compiled_module(*compiled_module); script->set_wasm_compiled_module(*compiled_module);
auto instance = WasmInstanceObject::New(isolate_, compiled_module); auto instance = WasmInstanceObject::New(isolate_, compiled_module);
......
...@@ -1803,13 +1803,6 @@ class WasmModuleCustomSectionTest : public TestWithIsolateAndZone { ...@@ -1803,13 +1803,6 @@ class WasmModuleCustomSectionTest : public TestWithIsolateAndZone {
public: public:
void CheckSections(const byte* module_start, const byte* module_end, void CheckSections(const byte* module_start, const byte* module_end,
const CustomSectionOffset* expected, size_t num_expected) { const CustomSectionOffset* expected, size_t num_expected) {
// Add the WASM magic and version number automatically.
size_t size = static_cast<size_t>(module_end - module_start);
byte header[] = {WASM_MODULE_HEADER};
size_t total = sizeof(header) + size;
auto temp = new byte[total];
memcpy(temp, header, sizeof(header));
memcpy(temp + sizeof(header), module_start, size);
std::vector<CustomSectionOffset> custom_sections = std::vector<CustomSectionOffset> custom_sections =
DecodeCustomSections(module_start, module_end); DecodeCustomSections(module_start, module_end);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment