1
// Copyright 2011 the V8 project authors. All rights reserved.
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
340
// Setup pointer to last argument.
340
// Set up pointer to last argument.
341
341
__ lea(rbx, Operand(rbp, StandardFrameConstants::kCallerSPOffset));
343
343
// Copy arguments and receiver to the expression stack.
1198
1198
// Both registers are preserved by this code so no need to differentiate between
1199
1199
// a construct call and a normal call.
1200
1200
static void ArrayNativeCode(MacroAssembler* masm,
1201
Label *call_generic_code) {
1202
Label argc_one_or_more, argc_two_or_more, empty_array, not_empty_array;
1201
Label* call_generic_code) {
1202
Label argc_one_or_more, argc_two_or_more, empty_array, not_empty_array,
1203
has_non_smi_element;
1204
1205
// Check for array construction with zero arguments.
1205
1206
__ testq(rax, rax);
1305
1306
__ jmp(&entry);
1306
1307
__ bind(&loop);
1307
1308
__ movq(kScratchRegister, Operand(r9, rcx, times_pointer_size, 0));
1309
if (FLAG_smi_only_arrays) {
1310
__ JumpIfNotSmi(kScratchRegister, &has_non_smi_element);
1308
1312
__ movq(Operand(rdx, 0), kScratchRegister);
1309
1313
__ addq(rdx, Immediate(kPointerSize));
1310
1314
__ bind(&entry);
1322
1326
__ movq(rax, rbx);
1329
__ bind(&has_non_smi_element);
1330
__ UndoAllocationInNewSpace(rbx);
1331
__ jmp(call_generic_code);
1335
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
1336
// ----------- S t a t e -------------
1338
// -- rsp[0] : return address
1339
// -- rsp[8] : last argument
1340
// -----------------------------------
1341
Label generic_array_code;
1343
// Get the InternalArray function.
1344
__ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, rdi);
1346
if (FLAG_debug_code) {
1347
// Initial map for the builtin InternalArray functions should be maps.
1348
__ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
1349
// Will both indicate a NULL and a Smi.
1350
STATIC_ASSERT(kSmiTag == 0);
1351
Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
1352
__ Check(not_smi, "Unexpected initial map for InternalArray function");
1353
__ CmpObjectType(rbx, MAP_TYPE, rcx);
1354
__ Check(equal, "Unexpected initial map for InternalArray function");
1357
// Run the native code for the InternalArray function called as a normal
1359
ArrayNativeCode(masm, &generic_array_code);
1361
// Jump to the generic array code in case the specialized code cannot handle
1362
// the construction.
1363
__ bind(&generic_array_code);
1364
Handle<Code> array_code =
1365
masm->isolate()->builtins()->InternalArrayCodeGeneric();
1366
__ Jump(array_code, RelocInfo::CODE_TARGET);