Commit ece8eb0f authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [cleanup] Use correct type more consistently

For more static type safety: Avoid passing wasm objects as Object and
casting them before use. Use the correct type right away.

R=ahaas@chromium.org
BUG=v8:6474

Change-Id: Id0c486560115dd1a7bd9b6a12d2fb938e06520ef
Reviewed-on: https://chromium-review.googlesource.com/530744Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45838}
parent 0e65c1e9
......@@ -653,15 +653,15 @@ void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
offset_ = array->Offset(frame_ix)->value();
}
Handle<Object> WasmStackFrame::GetReceiver() const { return wasm_instance_; }
Handle<Object> WasmStackFrame::GetFunction() const {
Handle<Object> obj(Smi::FromInt(wasm_func_index_), isolate_);
return obj;
return handle(Smi::FromInt(wasm_func_index_), isolate_);
}
Handle<Object> WasmStackFrame::GetFunctionName() {
Handle<Object> name;
Handle<WasmCompiledModule> compiled_module(
Handle<WasmInstanceObject>::cast(wasm_instance_)->compiled_module(),
Handle<WasmCompiledModule> compiled_module(wasm_instance_->compiled_module(),
isolate_);
if (!WasmCompiledModule::GetFunctionNameOrNull(isolate_, compiled_module,
wasm_func_index_)
......
......@@ -25,6 +25,7 @@ class JSMessageObject;
class LookupIterator;
class SharedFunctionInfo;
class SourceInfo;
class WasmInstanceObject;
class MessageLocation {
public:
......@@ -132,7 +133,7 @@ class WasmStackFrame : public StackFrameBase {
public:
virtual ~WasmStackFrame() {}
Handle<Object> GetReceiver() const override { return wasm_instance_; }
Handle<Object> GetReceiver() const override;
Handle<Object> GetFunction() const override;
Handle<Object> GetFileName() override { return Null(); }
......@@ -159,8 +160,7 @@ class WasmStackFrame : public StackFrameBase {
bool HasScript() const override;
Handle<Script> GetScript() const override;
// TODO(wasm): Use proper typing.
Handle<Object> wasm_instance_;
Handle<WasmInstanceObject> wasm_instance_;
uint32_t wasm_func_index_;
Handle<AbstractCode> code_; // null handle for interpreted frames.
int offset_;
......
......@@ -10117,11 +10117,9 @@ Handle<FrameArray> FrameArray::AppendJSFrame(Handle<FrameArray> in,
}
// static
Handle<FrameArray> FrameArray::AppendWasmFrame(Handle<FrameArray> in,
Handle<Object> wasm_instance,
int wasm_function_index,
Handle<AbstractCode> code,
int offset, int flags) {
Handle<FrameArray> FrameArray::AppendWasmFrame(
Handle<FrameArray> in, Handle<WasmInstanceObject> wasm_instance,
int wasm_function_index, Handle<AbstractCode> code, int offset, int flags) {
const int frame_count = in->FrameCount();
const int new_length = LengthFor(frame_count + 1);
Handle<FrameArray> array = EnsureSpace(in, new_length);
......
......@@ -6,6 +6,7 @@
#define V8_OBJECTS_FRAME_ARRAY_H_
#include "src/objects.h"
#include "src/wasm/wasm-objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -17,7 +18,7 @@ template <typename T>
class Handle;
#define FRAME_ARRAY_FIELD_LIST(V) \
V(WasmInstance, Object) \
V(WasmInstance, WasmInstanceObject) \
V(WasmFunctionIndex, Smi) \
V(Receiver, Object) \
V(Function, JSFunction) \
......@@ -56,11 +57,10 @@ class FrameArray : public FixedArray {
Handle<JSFunction> function,
Handle<AbstractCode> code, int offset,
int flags);
static Handle<FrameArray> AppendWasmFrame(Handle<FrameArray> in,
Handle<Object> wasm_instance,
int wasm_function_index,
Handle<AbstractCode> code,
int offset, int flags);
static Handle<FrameArray> AppendWasmFrame(
Handle<FrameArray> in, Handle<WasmInstanceObject> wasm_instance,
int wasm_function_index, Handle<AbstractCode> code, int offset,
int flags);
DECLARE_CAST(FrameArray)
......
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