Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 469d9c6336327f20b6b231c17e704d165c93aafa..46cac758f08ba3c75a0bc0767554f7bb431ea426 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2275,15 +2275,31 @@ |
} |
+MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
+ i::Isolate* isolate, const char* name, i::Handle<i::Object> recv, int argc, |
+ i::Handle<i::Object> argv[]) { |
+ i::Handle<i::Object> object_fun = |
+ i::Object::GetProperty( |
+ isolate, isolate->js_builtins_object(), name).ToHandleChecked(); |
+ i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); |
+ return i::Execution::Call(isolate, fun, recv, argc, argv); |
+} |
+ |
+ |
+MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
+ i::Isolate* isolate, const char* name, i::Handle<i::Object> data) { |
+ i::Handle<i::Object> argv[] = { data }; |
+ return CallV8HeapFunction(isolate, name, isolate->js_builtins_object(), |
+ arraysize(argv), argv); |
+} |
+ |
+ |
Maybe<int> Message::GetLineNumber(Local<Context> context) const { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetLineNumber()", int); |
- i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
i::Handle<i::Object> result; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
+ !CallV8HeapFunction(isolate, "$messageGetLineNumber", |
+ Utils::OpenHandle(this)).ToHandle(&result); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
return Just(static_cast<int>(result->Number())); |
} |
@@ -2310,15 +2326,13 @@ |
Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetStartColumn()", |
int); |
- i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
- i::Handle<i::Object> result; |
+ auto self = Utils::OpenHandle(this); |
+ i::Handle<i::Object> start_col_obj; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
+ !CallV8HeapFunction(isolate, "$messageGetPositionInLine", self) |
+ .ToHandle(&start_col_obj); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
- return Just(static_cast<int>(result->Number())); |
+ return Just(static_cast<int>(start_col_obj->Number())); |
} |
@@ -2330,19 +2344,16 @@ |
Maybe<int> Message::GetEndColumn(Local<Context> context) const { |
+ PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int); |
auto self = Utils::OpenHandle(this); |
- PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int); |
- i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {self}; |
- i::Handle<i::Object> result; |
+ i::Handle<i::Object> start_col_obj; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
+ !CallV8HeapFunction(isolate, "$messageGetPositionInLine", self) |
+ .ToHandle(&start_col_obj); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
int start = self->start_position(); |
int end = self->end_position(); |
- return Just(static_cast<int>(result->Number()) + (end - start)); |
+ return Just(static_cast<int>(start_col_obj->Number()) + (end - start)); |
} |
@@ -2376,13 +2387,10 @@ |
MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); |
- i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
i::Handle<i::Object> result; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
+ !CallV8HeapFunction(isolate, "$messageGetSourceLine", |
+ Utils::OpenHandle(this)).ToHandle(&result); |
RETURN_ON_FAILED_EXECUTION(String); |
Local<String> str; |
if (result->IsString()) { |
@@ -3372,11 +3380,9 @@ |
} |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Value::Equals()", bool); |
i::Handle<i::Object> args[] = { other }; |
- i::Handle<i::JSFunction> fun(i::JSFunction::cast( |
- isolate->js_builtins_object()->javascript_builtin(i::Builtins::EQUALS))); |
i::Handle<i::Object> result; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, self, arraysize(args), args) |
+ !CallV8HeapFunction(isolate, "EQUALS", self, arraysize(args), args) |
.ToHandle(&result); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return Just(*result == i::Smi::FromInt(i::EQUAL)); |
@@ -3506,12 +3512,11 @@ |
i::Handle<i::JSArray> desc_array = |
isolate->factory()->NewJSArrayWithElements(desc, i::FAST_ELEMENTS, 3); |
i::Handle<i::Object> args[] = {self, key_obj, value_obj, desc_array}; |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::JSFunction> fun = isolate->object_define_own_property(); |
i::Handle<i::Object> result; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
+ !CallV8HeapFunction(isolate, "$objectDefineOwnProperty", |
+ isolate->factory()->undefined_value(), |
+ arraysize(args), args).ToHandle(&result); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
return Just(result->BooleanValue()); |
} |
@@ -3643,12 +3648,11 @@ |
auto obj = Utils::OpenHandle(this); |
auto key_name = Utils::OpenHandle(*key); |
i::Handle<i::Object> args[] = { obj, key_name }; |
- i::Handle<i::JSFunction> fun = isolate->object_get_own_property_descriptor(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
i::Handle<i::Object> result; |
has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
+ !CallV8HeapFunction(isolate, "$objectGetOwnPropertyDescriptor", |
+ isolate->factory()->undefined_value(), |
+ arraysize(args), args).ToHandle(&result); |
RETURN_ON_FAILED_EXECUTION(Value); |
RETURN_ESCAPED(Utils::ToLocal(result)); |
} |