Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 17792341eac5a9955ec497dae1023bab46a3c31d..b46c0edbb1111c6916c5f469e6f3b445b2882951 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -2568,17 +2568,56 @@ Local<StackTrace> StackTrace::CurrentStackTrace( |
| // --- S t a c k F r a m e --- |
| +#define STACKFRAME_PROPERTY_HELPER(obj, propertyName, MAKE_SCOPE) \ |
|
titzer
2016/04/22 12:16:25
As tempting as this is, let's not macro-ify this c
Clemens Hammacher
2016/04/26 14:00:10
Hm, OK.
|
| + i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate(); \ |
| + ENTER_V8(isolate); \ |
| + MAKE_SCOPE(scope, isolate); \ |
| + i::Handle<i::JSObject> self = Utils::OpenHandle(f); \ |
| + i::Handle<i::Object> obj = \ |
| + i::JSReceiver::GetProperty(isolate, self, propertyName) \ |
| + .ToHandleChecked(); |
| +#define MAKE_STD_SCOPE(name, isolate) i::HandleScope name(isolate) |
| +#define STACKFRAME_PROPERTY(obj, propertyName) \ |
| + STACKFRAME_PROPERTY_HELPER(obj, propertyName, MAKE_STD_SCOPE) |
| +#define MAKE_ESCAPABLE_SCOPE(name, isolate) \ |
| + EscapableHandleScope name(reinterpret_cast<Isolate*>(isolate)) |
| +#define STACKFRAME_ESCAPABLE_PROPERTY(obj, propertyName) \ |
| + STACKFRAME_PROPERTY_HELPER(obj, propertyName, MAKE_ESCAPABLE_SCOPE) |
| + |
| static int getIntProperty(const StackFrame* f, const char* propertyName, |
| int defaultValue) { |
| - i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate(); |
| - ENTER_V8(isolate); |
| - i::HandleScope scope(isolate); |
| - i::Handle<i::JSObject> self = Utils::OpenHandle(f); |
| - i::Handle<i::Object> obj = |
| - i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked(); |
| + STACKFRAME_PROPERTY(obj, propertyName) |
| return obj->IsSmi() ? i::Smi::cast(*obj)->value() : defaultValue; |
| } |
| +static uint32_t getUintProperty(const StackFrame* f, const char* propertyName, |
| + uint32_t defaultValue) { |
| + STACKFRAME_PROPERTY(obj, propertyName) |
| + uint32_t val = defaultValue; |
| + obj->ToUint32(&val); |
| + return val; |
| +} |
| + |
| +static Local<String> getStringProperty(const StackFrame* f, |
| + const char* propertyName) { |
| + STACKFRAME_ESCAPABLE_PROPERTY(obj, propertyName) |
| + return obj->IsString() |
| + ? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj))) |
| + : Local<String>(); |
| +} |
| + |
| +static Local<Object> getObjectProperty(const StackFrame* f, |
| + const char* propertyName) { |
| + STACKFRAME_ESCAPABLE_PROPERTY(obj, propertyName); |
| + return obj->IsObject() |
| + ? scope.Escape(Local<Object>::Cast(Utils::ToLocal(obj))) |
| + : Local<Object>(); |
| +} |
| + |
| +static bool getBoolProperty(const StackFrame* f, const char* propertyName) { |
| + STACKFRAME_PROPERTY(obj, propertyName); |
| + return obj->IsTrue(); |
| +} |
| int StackFrame::GetLineNumber() const { |
| return getIntProperty(this, "lineNumber", Message::kNoLineNumberInfo); |
| @@ -2594,21 +2633,6 @@ int StackFrame::GetScriptId() const { |
| return getIntProperty(this, "scriptId", Message::kNoScriptIdInfo); |
| } |
| - |
| -static Local<String> getStringProperty(const StackFrame* f, |
| - const char* propertyName) { |
| - i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate(); |
| - ENTER_V8(isolate); |
| - EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| - i::Handle<i::JSObject> self = Utils::OpenHandle(f); |
| - i::Handle<i::Object> obj = |
| - i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked(); |
| - return obj->IsString() |
| - ? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj))) |
| - : Local<String>(); |
| -} |
| - |
| - |
| Local<String> StackFrame::GetScriptName() const { |
| return getStringProperty(this, "scriptName"); |
| } |
| @@ -2623,17 +2647,6 @@ Local<String> StackFrame::GetFunctionName() const { |
| return getStringProperty(this, "functionName"); |
| } |
| - |
| -static bool getBoolProperty(const StackFrame* f, const char* propertyName) { |
| - i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate(); |
| - ENTER_V8(isolate); |
| - i::HandleScope scope(isolate); |
| - i::Handle<i::JSObject> self = Utils::OpenHandle(f); |
| - i::Handle<i::Object> obj = |
| - i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked(); |
| - return obj->IsTrue(); |
| -} |
| - |
| bool StackFrame::IsEval() const { return getBoolProperty(this, "isEval"); } |
| @@ -2641,6 +2654,16 @@ bool StackFrame::IsConstructor() const { |
| return getBoolProperty(this, "isConstructor"); |
| } |
| +bool StackFrame::IsWasm() const { return getBoolProperty(this, "isWasm"); } |
| + |
| +Local<Object> StackFrame::GetWasmObject() const { |
| + return getObjectProperty(this, "wasmObject"); |
| +} |
| + |
| +uint32_t StackFrame::GetWasmByteOffset() const { |
| + return getUintProperty(this, "wasmByteOffset", |
| + Message::kNoWasmByteOffsetInfo); |
| +} |
| // --- N a t i v e W e a k M a p --- |