Commit a80d4d03 authored by clemensh's avatar clemensh Committed by Commit bot

[wasm] Remove two obsolete functions

With the new wasm object types, the GetCompiledModule and GetWasmBytes
functions are not needed any more. The same functions are already
public on the wasm objects.
In order to use them properly, I changed a few more locations to make
use of the new types.

R=ahaas@chromium.org, titzer@chromium.org

Review-Url: https://codereview.chromium.org/2503403005
Cr-Commit-Position: refs/heads/master@{#41085}
parent b46bdcd5
......@@ -551,10 +551,11 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
details->set(kFrameDetailsFrameIdIndex, *frame_id);
// Add the function name.
Handle<Object> wasm_instance(it.wasm_frame()->wasm_instance(), isolate);
Handle<Object> wasm_instance_or_undef(it.wasm_frame()->wasm_instance(),
isolate);
int func_index = it.wasm_frame()->function_index();
Handle<String> func_name =
wasm::GetWasmFunctionName(isolate, wasm_instance, func_index);
wasm::GetWasmFunctionName(isolate, wasm_instance_or_undef, func_index);
details->set(kFrameDetailsFunctionIndex, *func_name);
// Add the script wrapper
......@@ -573,11 +574,14 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
// position, such that together with the script it uniquely identifies the
// position.
Handle<Object> positionValue;
if (position != kNoSourcePosition) {
if (position != kNoSourcePosition &&
!wasm_instance_or_undef->IsUndefined(isolate)) {
int translated_position = position;
if (!wasm::WasmIsAsmJs(*wasm_instance, isolate)) {
if (!wasm::WasmIsAsmJs(*wasm_instance_or_undef, isolate)) {
Handle<WasmCompiledModule> compiled_module(
wasm::GetCompiledModule(JSObject::cast(*wasm_instance)), isolate);
WasmInstanceObject::cast(*wasm_instance_or_undef)
->get_compiled_module(),
isolate);
translated_position +=
wasm::GetFunctionCodeOffset(compiled_module, func_index);
}
......
......@@ -30,9 +30,10 @@ FixedArray *GetAsmJsOffsetTables(Handle<WasmDebugInfo> debug_info,
return FixedArray::cast(offset_tables);
}
Handle<JSObject> wasm_instance(debug_info->wasm_instance(), isolate);
Handle<WasmCompiledModule> compiled_module(GetCompiledModule(*wasm_instance),
isolate);
Handle<WasmInstanceObject> wasm_instance(debug_info->wasm_instance(),
isolate);
Handle<WasmCompiledModule> compiled_module(
wasm_instance->get_compiled_module(), isolate);
DCHECK(compiled_module->has_asm_js_offset_tables());
AsmJsOffsetsResult asm_offsets;
......@@ -76,14 +77,15 @@ FixedArray *GetAsmJsOffsetTables(Handle<WasmDebugInfo> debug_info,
}
} // namespace
Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<JSObject> wasm) {
Isolate *isolate = wasm->GetIsolate();
Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<WasmInstanceObject> instance) {
Isolate *isolate = instance->GetIsolate();
Factory *factory = isolate->factory();
Handle<FixedArray> arr =
factory->NewFixedArray(kWasmDebugInfoNumEntries, TENURED);
arr->set(kWasmDebugInfoWasmObj, *wasm);
arr->set(kWasmDebugInfoWasmObj, *instance);
int hash = 0;
Handle<SeqOneByteString> wasm_bytes = GetWasmBytes(wasm);
Handle<SeqOneByteString> wasm_bytes =
instance->get_compiled_module()->module_bytes();
{
DisallowHeapAllocation no_gc;
hash = StringHasher::HashSequentialString(
......@@ -108,17 +110,17 @@ WasmDebugInfo *WasmDebugInfo::cast(Object *object) {
return reinterpret_cast<WasmDebugInfo *>(object);
}
JSObject *WasmDebugInfo::wasm_instance() {
return JSObject::cast(get(kWasmDebugInfoWasmObj));
WasmInstanceObject *WasmDebugInfo::wasm_instance() {
return WasmInstanceObject::cast(get(kWasmDebugInfoWasmObj));
}
int WasmDebugInfo::GetAsmJsSourcePosition(Handle<WasmDebugInfo> debug_info,
int func_index, int byte_offset) {
Isolate *isolate = debug_info->GetIsolate();
Handle<JSObject> instance(debug_info->wasm_instance(), isolate);
Handle<WasmInstanceObject> instance(debug_info->wasm_instance(), isolate);
FixedArray *offset_tables = GetAsmJsOffsetTables(debug_info, isolate);
WasmCompiledModule *compiled_module = wasm::GetCompiledModule(*instance);
WasmCompiledModule *compiled_module = instance->get_compiled_module();
int num_imported_functions =
compiled_module->module()->num_imported_functions;
DCHECK_LE(num_imported_functions, func_index);
......
......@@ -1870,23 +1870,19 @@ bool wasm::IsWasmInstance(Object* object) {
return WasmInstanceObject::IsWasmInstanceObject(object);
}
WasmCompiledModule* wasm::GetCompiledModule(Object* object) {
return WasmInstanceObject::cast(object)->get_compiled_module();
}
bool wasm::WasmIsAsmJs(Object* instance, Isolate* isolate) {
if (instance->IsUndefined(isolate)) return false;
DCHECK(IsWasmInstance(instance));
WasmCompiledModule* compiled_module =
GetCompiledModule(JSObject::cast(instance));
WasmInstanceObject::cast(instance)->get_compiled_module();
DCHECK_EQ(compiled_module->has_asm_js_offset_tables(),
compiled_module->script()->type() == Script::TYPE_NORMAL);
return compiled_module->has_asm_js_offset_tables();
}
Handle<Script> wasm::GetScript(Handle<JSObject> instance) {
DCHECK(IsWasmInstance(*instance));
WasmCompiledModule* compiled_module = GetCompiledModule(*instance);
WasmCompiledModule* compiled_module =
WasmInstanceObject::cast(*instance)->get_compiled_module();
DCHECK(compiled_module->has_script());
return compiled_module->script();
}
......@@ -1917,12 +1913,6 @@ int wasm::GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index,
func_index, byte_offset);
}
Handle<SeqOneByteString> wasm::GetWasmBytes(Handle<JSObject> object) {
return Handle<WasmInstanceObject>::cast(object)
->get_compiled_module()
->module_bytes();
}
Handle<WasmDebugInfo> wasm::GetDebugInfo(Handle<JSObject> object) {
auto instance = Handle<WasmInstanceObject>::cast(object);
if (instance->has_debug_info()) {
......
......@@ -359,9 +359,6 @@ std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name);
Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> instance,
uint32_t func_index);
// Return the binary source bytes of a wasm module.
Handle<SeqOneByteString> GetWasmBytes(Handle<JSObject> wasm);
// Get the debug info associated with the given wasm object.
// If no debug info exists yet, it is created automatically.
Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm);
......@@ -376,9 +373,6 @@ int GetNumberOfFunctions(Handle<JSObject> wasm);
// else.
bool IsWasmInstance(Object* instance);
// Return the compiled module object for this WASM instance.
WasmCompiledModule* GetCompiledModule(Object* wasm_instance);
// Check whether the wasm module was generated from asm.js code.
bool WasmIsAsmJs(Object* instance, Isolate* isolate);
......
......@@ -275,12 +275,12 @@ class WasmDebugInfo : public FixedArray {
public:
enum class Fields { kFieldCount };
static Handle<WasmDebugInfo> New(Handle<JSObject> wasm);
static Handle<WasmDebugInfo> New(Handle<WasmInstanceObject> instance);
static bool IsDebugInfo(Object* object);
static WasmDebugInfo* cast(Object* object);
JSObject* wasm_instance();
WasmInstanceObject* wasm_instance();
bool SetBreakPoint(int byte_offset);
......
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