}
-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) {
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;
}
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();
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);
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;
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());
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
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;
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);
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();
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);
}
}
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];
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);
}
}
}
kind = GetPackedElementsKind(kind);
} else if (!receiver->IsJSArray()) {
AllowHeapAllocation allow_allocation;
- return CallJsBuiltin(isolate, "$arraySlice", args);
+ return CallJsIntrinsic(isolate, isolate->array_slice(), args);
}
}
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());
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)
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);
// 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) {
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
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();
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();