Index: src/wasm/wasm-module.cc |
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc |
index fff7dd9621a79762e53565c79038f496eb998603..802415b3f11c766fb968c38858625d371fb8708f 100644 |
--- a/src/wasm/wasm-module.cc |
+++ b/src/wasm/wasm-module.cc |
@@ -57,10 +57,7 @@ enum WasmInstanceObjectFields { |
kWasmGlobalsArrayBuffer, |
// TODO(clemensh): Remove function name array, extract names from module |
// bytes. |
- kWasmFunctionNamesArray, |
- kWasmModuleBytesString, |
kWasmDebugInfo, |
- kWasmNumImportedFunctions, |
kWasmModuleInternalFieldCount |
}; |
@@ -989,9 +986,10 @@ Object* GetOwningWasmInstance(Code* code) { |
} |
uint32_t GetNumImportedFunctions(Handle<JSObject> wasm_object) { |
- return static_cast<uint32_t>( |
- Smi::cast(wasm_object->GetInternalField(kWasmNumImportedFunctions)) |
- ->value()); |
+ DCHECK(IsWasmObject(*wasm_object)); |
+ WasmCompiledModule* compiled_module = WasmCompiledModule::cast( |
+ wasm_object->GetInternalField(kWasmCompiledModule)); |
+ return static_cast<uint32_t>(compiled_module->ptr_to_import_data()->length()); |
titzer
2016/10/06 15:55:09
That won't work in my latest patch; the number of
Clemens Hammacher
2016/10/06 18:46:50
Fixed as discussed.
|
} |
WasmModule::WasmModule(byte* module_start) |
@@ -1344,26 +1342,6 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, |
} |
//-------------------------------------------------------------------------- |
- // Set up the debug support for the new instance. |
- //-------------------------------------------------------------------------- |
- // TODO(clemensh): avoid referencing this stuff from the instance, use it off |
- // the compiled module instead. See the following 3 assignments: |
- if (compiled_module->has_module_bytes()) { |
- instance->SetInternalField(kWasmModuleBytesString, |
- compiled_module->ptr_to_module_bytes()); |
- } |
- |
- if (compiled_module->has_function_names()) { |
- instance->SetInternalField(kWasmFunctionNamesArray, |
- compiled_module->ptr_to_function_names()); |
- } |
- |
- { |
- Handle<Object> handle = factory->NewNumber(num_imported_functions); |
- instance->SetInternalField(kWasmNumImportedFunctions, *handle); |
- } |
- |
- //-------------------------------------------------------------------------- |
// Set up the runtime support for the new instance. |
//-------------------------------------------------------------------------- |
Handle<WeakCell> weak_link = isolate->factory()->NewWeakCell(instance); |
@@ -1621,10 +1599,11 @@ void WasmCompiledModule::PrintInstancesChain() { |
Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm, |
uint32_t func_index) { |
if (!wasm->IsUndefined(isolate)) { |
+ DCHECK(IsWasmObject(*wasm)); |
+ WasmCompiledModule* compiled_module = WasmCompiledModule::cast( |
+ Handle<JSObject>::cast(wasm)->GetInternalField(kWasmCompiledModule)); |
Handle<ByteArray> func_names_arr_obj( |
- ByteArray::cast(Handle<JSObject>::cast(wasm)->GetInternalField( |
- kWasmFunctionNamesArray)), |
- isolate); |
+ compiled_module->ptr_to_function_names(), isolate); |
Mircea Trofin
2016/10/06 15:43:21
wouldn't compiled_module->function_names() give yo
Clemens Hammacher
2016/10/06 18:46:50
Good catch, fixed.
|
// TODO(clemens): Extract this from the module bytes; skip whole function |
// name table. |
Handle<Object> name; |
@@ -1658,7 +1637,6 @@ bool IsWasmObject(Object* object) { |
Object* mem = obj->GetInternalField(kWasmMemArrayBuffer); |
if (!obj->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() || |
!(mem->IsUndefined(isolate) || mem->IsJSArrayBuffer()) || |
- !obj->GetInternalField(kWasmFunctionNamesArray)->IsByteArray() || |
!WasmCompiledModule::IsWasmCompiledModule( |
obj->GetInternalField(kWasmCompiledModule))) { |
return false; |
@@ -1669,7 +1647,10 @@ bool IsWasmObject(Object* object) { |
} |
SeqOneByteString* GetWasmBytes(JSObject* wasm) { |
titzer
2016/10/06 15:55:09
Please return a handle instead of a raw pointer he
Clemens Hammacher
2016/10/06 18:46:50
Done.
|
- return SeqOneByteString::cast(wasm->GetInternalField(kWasmModuleBytesString)); |
+ DCHECK(IsWasmObject(wasm)); |
+ WasmCompiledModule* compiled_module = |
+ WasmCompiledModule::cast(wasm->GetInternalField(kWasmCompiledModule)); |
+ return compiled_module->ptr_to_module_bytes(); |
} |
Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm) { |
@@ -1749,9 +1730,12 @@ void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size, |
} |
int GetNumberOfFunctions(JSObject* wasm) { |
- Object* func_names_obj = wasm->GetInternalField(kWasmFunctionNamesArray); |
+ DCHECK(IsWasmObject(wasm)); |
+ WasmCompiledModule* compiled_module = |
+ WasmCompiledModule::cast(wasm->GetInternalField(kWasmCompiledModule)); |
+ ByteArray* func_names_arr = compiled_module->ptr_to_function_names(); |
// TODO(clemensh): this looks inside an array constructed elsewhere. Refactor. |
- return ByteArray::cast(func_names_obj)->get_int(0); |
+ return func_names_arr->get_int(0); |
} |
Handle<JSObject> CreateCompiledModuleObject(Isolate* isolate, |