Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index 4bc61b8f6b1d4374ff5d8f85b43baf5c86f13429..261c58317fb7fd3084dcb56b7741bb3bce282132 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -283,17 +283,10 @@ static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( |
} |
-MUST_USE_RESULT static Object* CallJsBuiltin( |
- Isolate* isolate, |
- const char* name, |
+MUST_USE_RESULT static Object* CallJsIntrinsic( |
+ Isolate* isolate, Handle<JSFunction> function, |
BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { |
HandleScope handleScope(isolate); |
- |
- Handle<Object> js_builtin = Object::GetProperty( |
- isolate, |
- handle(isolate->native_context()->builtins(), isolate), |
- name).ToHandleChecked(); |
- Handle<JSFunction> function = Handle<JSFunction>::cast(js_builtin); |
int argc = args.length() - 1; |
ScopedVector<Handle<Object> > argv(argc); |
for (int i = 0; i < argc; ++i) { |
@@ -318,7 +311,7 @@ BUILTIN(ArrayPush) { |
EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1); |
Handle<FixedArrayBase> elms_obj; |
if (!maybe_elms_obj.ToHandle(&elms_obj)) { |
- return CallJsBuiltin(isolate, "$arrayPush", args); |
+ return CallJsIntrinsic(isolate, isolate->array_push(), args); |
} |
// Fast Elements Path |
int push_size = args.length() - 1; |
@@ -329,7 +322,7 @@ BUILTIN(ArrayPush) { |
} |
if (push_size > 0 && |
JSArray::WouldChangeReadOnlyLength(array, len + push_size)) { |
- return CallJsBuiltin(isolate, "$arrayPush", args); |
+ return CallJsIntrinsic(isolate, isolate->array_push(), args); |
} |
DCHECK(!array->map()->is_observed()); |
ElementsAccessor* accessor = array->GetElementsAccessor(); |
@@ -346,7 +339,7 @@ BUILTIN(ArrayPop) { |
EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); |
Handle<FixedArrayBase> elms_obj; |
if (!maybe_elms_obj.ToHandle(&elms_obj)) { |
- return CallJsBuiltin(isolate, "$arrayPop", args); |
+ return CallJsIntrinsic(isolate, isolate->array_pop(), args); |
} |
Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
@@ -356,7 +349,7 @@ BUILTIN(ArrayPop) { |
if (len == 0) return isolate->heap()->undefined_value(); |
if (JSArray::HasReadOnlyLength(array)) { |
- return CallJsBuiltin(isolate, "$arrayPop", args); |
+ return CallJsIntrinsic(isolate, isolate->array_pop(), args); |
} |
uint32_t new_length = len - 1; |
@@ -378,7 +371,7 @@ BUILTIN(ArrayShift) { |
Handle<FixedArrayBase> elms_obj; |
if (!maybe_elms_obj.ToHandle(&elms_obj) || |
!IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) { |
- return CallJsBuiltin(isolate, "$arrayShift", args); |
+ return CallJsIntrinsic(isolate, isolate->array_shift(), args); |
} |
Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
DCHECK(!array->map()->is_observed()); |
@@ -387,7 +380,7 @@ BUILTIN(ArrayShift) { |
if (len == 0) return heap->undefined_value(); |
if (JSArray::HasReadOnlyLength(array)) { |
- return CallJsBuiltin(isolate, "$arrayShift", args); |
+ return CallJsIntrinsic(isolate, isolate->array_shift(), args); |
} |
// Get first element |
@@ -425,12 +418,12 @@ BUILTIN(ArrayUnshift) { |
EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1); |
Handle<FixedArrayBase> elms_obj; |
if (!maybe_elms_obj.ToHandle(&elms_obj)) { |
- return CallJsBuiltin(isolate, "$arrayUnshift", args); |
+ return CallJsIntrinsic(isolate, isolate->array_unshift(), args); |
} |
Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
DCHECK(!array->map()->is_observed()); |
if (!array->HasFastSmiOrObjectElements()) { |
- return CallJsBuiltin(isolate, "$arrayUnshift", args); |
+ return CallJsIntrinsic(isolate, isolate->array_unshift(), args); |
} |
int len = Smi::cast(array->length())->value(); |
int to_add = args.length() - 1; |
@@ -440,7 +433,7 @@ BUILTIN(ArrayUnshift) { |
DCHECK(to_add <= (Smi::kMaxValue - len)); |
if (to_add > 0 && JSArray::WouldChangeReadOnlyLength(array, len + to_add)) { |
- return CallJsBuiltin(isolate, "$arrayUnshift", args); |
+ return CallJsIntrinsic(isolate, isolate->array_unshift(), args); |
} |
Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); |
@@ -490,12 +483,12 @@ BUILTIN(ArraySlice) { |
JSArray* array = JSArray::cast(*receiver); |
if (!IsJSArrayFastElementMovingAllowed(isolate, array)) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
if (!array->HasFastElements()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
len = Smi::cast(array->length())->value(); |
@@ -510,24 +503,24 @@ BUILTIN(ArraySlice) { |
JSObject::cast(*receiver)->map() == arguments_map; |
if (!is_arguments_object_with_fast_elements) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
JSObject* object = JSObject::cast(*receiver); |
if (!object->HasFastElements()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
Object* len_obj = object->InObjectPropertyAt(Heap::kArgumentsLengthIndex); |
if (!len_obj->IsSmi()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
len = Smi::cast(len_obj)->value(); |
if (len > object->elements()->length()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
} |
@@ -547,12 +540,12 @@ BUILTIN(ArraySlice) { |
double start = HeapNumber::cast(arg1)->value(); |
if (start < kMinInt || start > kMaxInt) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
relative_start = std::isnan(start) ? 0 : static_cast<int>(start); |
} else if (!arg1->IsUndefined()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
if (n_arguments > 1) { |
Object* arg2 = args[2]; |
@@ -562,12 +555,12 @@ BUILTIN(ArraySlice) { |
double end = HeapNumber::cast(arg2)->value(); |
if (end < kMinInt || end > kMaxInt) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
relative_end = std::isnan(end) ? 0 : static_cast<int>(end); |
} else if (!arg2->IsUndefined()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
} |
} |
@@ -602,7 +595,7 @@ BUILTIN(ArraySlice) { |
kind = GetPackedElementsKind(kind); |
} else if (!receiver->IsJSArray()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySlice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
} |
@@ -627,7 +620,7 @@ BUILTIN(ArraySplice) { |
EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3); |
Handle<FixedArrayBase> elms_obj; |
if (!maybe_elms_obj.ToHandle(&elms_obj)) { |
- return CallJsBuiltin(isolate, "$arraySplice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
DCHECK(!array->map()->is_observed()); |
@@ -646,12 +639,12 @@ BUILTIN(ArraySplice) { |
double start = HeapNumber::cast(arg1)->value(); |
if (start < kMinInt || start > kMaxInt) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySplice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
relative_start = std::isnan(start) ? 0 : static_cast<int>(start); |
} else if (!arg1->IsUndefined()) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySplice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
} |
int actual_start = (relative_start < 0) ? Max(len + relative_start, 0) |
@@ -675,7 +668,7 @@ BUILTIN(ArraySplice) { |
value = Smi::cast(arg2)->value(); |
} else { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySplice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
} |
actual_delete_count = Min(Max(value, 0), len - actual_start); |
@@ -688,12 +681,12 @@ BUILTIN(ArraySplice) { |
// For double mode we do not support changing the length. |
if (new_length > len && IsFastDoubleElementsKind(elements_kind)) { |
- return CallJsBuiltin(isolate, "$arraySplice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
if (new_length != len && JSArray::HasReadOnlyLength(array)) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arraySplice", args); |
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
if (new_length == 0) { |
@@ -853,7 +846,7 @@ BUILTIN(ArrayConcat) { |
PrototypeIterator::START_AT_RECEIVER); |
if (!ArrayPrototypeHasNoElements(&iter)) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arrayConcat", args); |
+ return CallJsIntrinsic(isolate, isolate->array_concat(), args); |
} |
// Iterate through all the arguments performing checks |
@@ -865,7 +858,7 @@ BUILTIN(ArrayConcat) { |
if (!arg->IsJSArray() || !JSArray::cast(arg)->HasFastElements() || |
iter.GetCurrent() != array_proto) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arrayConcat", args); |
+ return CallJsIntrinsic(isolate, isolate->array_concat(), args); |
} |
int len = Smi::cast(JSArray::cast(arg)->length())->value(); |
@@ -878,7 +871,7 @@ BUILTIN(ArrayConcat) { |
if (result_len > FixedDoubleArray::kMaxLength) { |
AllowHeapAllocation allow_allocation; |
- return CallJsBuiltin(isolate, "$arrayConcat", args); |
+ return CallJsIntrinsic(isolate, isolate->array_concat(), args); |
} |
ElementsKind arg_kind = JSArray::cast(arg)->map()->elements_kind(); |