OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3177 // Check that the function is really a JavaScript function. | 3177 // Check that the function is really a JavaScript function. |
3178 // a1: pushed function (to be verified) | 3178 // a1: pushed function (to be verified) |
3179 __ JumpIfSmi(a1, &non_function); | 3179 __ JumpIfSmi(a1, &non_function); |
3180 | 3180 |
3181 // Goto slow case if we do not have a function. | 3181 // Goto slow case if we do not have a function. |
3182 __ GetObjectType(a1, t0, t0); | 3182 __ GetObjectType(a1, t0, t0); |
3183 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); | 3183 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); |
3184 | 3184 |
3185 if (RecordCallTarget()) { | 3185 if (RecordCallTarget()) { |
3186 GenerateRecordCallTarget(masm); | 3186 GenerateRecordCallTarget(masm); |
| 3187 // Type information was updated. Because we may call Array, which |
| 3188 // expects either undefined or an AllocationSite in a2 we need |
| 3189 // to set a2 to undefined. |
| 3190 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
3187 } | 3191 } |
3188 } | 3192 } |
3189 | 3193 |
3190 // Fast-case: Invoke the function now. | 3194 // Fast-case: Invoke the function now. |
3191 // a1: pushed function | 3195 // a1: pushed function |
3192 ParameterCount actual(argc_); | 3196 ParameterCount actual(argc_); |
3193 | 3197 |
3194 if (CallAsMethod()) { | 3198 if (CallAsMethod()) { |
3195 if (NeedsChecks()) { | 3199 if (NeedsChecks()) { |
3196 // Do not transform the receiver for strict mode functions and natives. | 3200 // Do not transform the receiver for strict mode functions and natives. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3277 // a3 : (only if a2 is not undefined) slot in feedback vector (Smi) | 3281 // a3 : (only if a2 is not undefined) slot in feedback vector (Smi) |
3278 Label slow, non_function_call; | 3282 Label slow, non_function_call; |
3279 | 3283 |
3280 // Check that the function is not a smi. | 3284 // Check that the function is not a smi. |
3281 __ JumpIfSmi(a1, &non_function_call); | 3285 __ JumpIfSmi(a1, &non_function_call); |
3282 // Check that the function is a JSFunction. | 3286 // Check that the function is a JSFunction. |
3283 __ GetObjectType(a1, t0, t0); | 3287 __ GetObjectType(a1, t0, t0); |
3284 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); | 3288 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); |
3285 | 3289 |
3286 if (RecordCallTarget()) { | 3290 if (RecordCallTarget()) { |
| 3291 Label feedback_register_initialized; |
3287 GenerateRecordCallTarget(masm); | 3292 GenerateRecordCallTarget(masm); |
| 3293 |
| 3294 // Put the AllocationSite from the feedback vector into a2, or undefined. |
| 3295 __ sll(at, a3, kPointerSizeLog2 - kSmiTagSize); |
| 3296 __ Addu(t1, a2, at); |
| 3297 __ lw(a2, FieldMemOperand(t1, FixedArray::kHeaderSize)); |
| 3298 __ lw(t1, FieldMemOperand(a2, AllocationSite::kMapOffset)); |
| 3299 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); |
| 3300 __ Branch(&feedback_register_initialized, eq, t1, Operand(at)); |
| 3301 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 3302 __ bind(&feedback_register_initialized); |
| 3303 __ AssertUndefinedOrAllocationSite(a2, t1); |
3288 } | 3304 } |
3289 | 3305 |
3290 // Jump to the function-specific construct stub. | 3306 // Jump to the function-specific construct stub. |
3291 Register jmp_reg = t0; | 3307 Register jmp_reg = t0; |
3292 __ lw(jmp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 3308 __ lw(jmp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
3293 __ lw(jmp_reg, FieldMemOperand(jmp_reg, | 3309 __ lw(jmp_reg, FieldMemOperand(jmp_reg, |
3294 SharedFunctionInfo::kConstructStubOffset)); | 3310 SharedFunctionInfo::kConstructStubOffset)); |
3295 __ Addu(at, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); | 3311 __ Addu(at, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
3296 __ Jump(at); | 3312 __ Jump(at); |
3297 | 3313 |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5390 } else { | 5406 } else { |
5391 UNREACHABLE(); | 5407 UNREACHABLE(); |
5392 } | 5408 } |
5393 } | 5409 } |
5394 | 5410 |
5395 | 5411 |
5396 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 5412 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
5397 // ----------- S t a t e ------------- | 5413 // ----------- S t a t e ------------- |
5398 // -- a0 : argc (only if argument_count_ == ANY) | 5414 // -- a0 : argc (only if argument_count_ == ANY) |
5399 // -- a1 : constructor | 5415 // -- a1 : constructor |
5400 // -- a2 : feedback vector (fixed array or megamorphic symbol) | 5416 // -- a2 : AllocationSite or undefined |
5401 // -- a3 : slot index (if a2 is fixed array) | |
5402 // -- sp[0] : return address | 5417 // -- sp[0] : return address |
5403 // -- sp[4] : last argument | 5418 // -- sp[4] : last argument |
5404 // ----------------------------------- | 5419 // ----------------------------------- |
5405 | 5420 |
5406 ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()), | |
5407 masm->isolate()->heap()->megamorphic_symbol()); | |
5408 | |
5409 if (FLAG_debug_code) { | 5421 if (FLAG_debug_code) { |
5410 // The array construct code is only set for the global and natives | 5422 // The array construct code is only set for the global and natives |
5411 // builtin Array functions which always have maps. | 5423 // builtin Array functions which always have maps. |
5412 | 5424 |
5413 // Initial map for the builtin Array function should be a map. | 5425 // Initial map for the builtin Array function should be a map. |
5414 __ lw(t0, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); | 5426 __ lw(t0, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
5415 // Will both indicate a NULL and a Smi. | 5427 // Will both indicate a NULL and a Smi. |
5416 __ SmiTst(t0, at); | 5428 __ SmiTst(t0, at); |
5417 __ Assert(ne, kUnexpectedInitialMapForArrayFunction, | 5429 __ Assert(ne, kUnexpectedInitialMapForArrayFunction, |
5418 at, Operand(zero_reg)); | 5430 at, Operand(zero_reg)); |
5419 __ GetObjectType(t0, t0, t1); | 5431 __ GetObjectType(t0, t0, t1); |
5420 __ Assert(eq, kUnexpectedInitialMapForArrayFunction, | 5432 __ Assert(eq, kUnexpectedInitialMapForArrayFunction, |
5421 t1, Operand(MAP_TYPE)); | 5433 t1, Operand(MAP_TYPE)); |
5422 | 5434 |
5423 // We should either have the megamorphic symbol in a2 or a valid | 5435 // We should either have undefined in a2 or a valid AllocationSite |
5424 // fixed array. | 5436 __ AssertUndefinedOrAllocationSite(a2, t0); |
5425 Label okay_here; | |
5426 Handle<Map> fixed_array_map = masm->isolate()->factory()->fixed_array_map(); | |
5427 __ LoadRoot(at, Heap::kMegamorphicSymbolRootIndex); | |
5428 __ Branch(&okay_here, eq, a2, Operand(at)); | |
5429 __ lw(t0, FieldMemOperand(a2, 0)); | |
5430 __ Assert(eq, kExpectedFixedArrayInRegisterA2, | |
5431 t0, Operand(fixed_array_map)); | |
5432 | |
5433 // a3 should be a smi if we don't have undefined in a2 | |
5434 __ AssertSmi(a3); | |
5435 | |
5436 __ bind(&okay_here); | |
5437 } | 5437 } |
5438 | 5438 |
5439 Label no_info; | 5439 Label no_info; |
5440 // Get the elements kind and case on that. | 5440 // Get the elements kind and case on that. |
5441 __ LoadRoot(at, Heap::kMegamorphicSymbolRootIndex); | 5441 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
5442 __ Branch(&no_info, eq, a2, Operand(at)); | 5442 __ Branch(&no_info, eq, a2, Operand(at)); |
5443 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); | |
5444 __ Addu(a2, a2, Operand(t0)); | |
5445 __ lw(a2, FieldMemOperand(a2, FixedArray::kHeaderSize)); | |
5446 | |
5447 // If the feedback vector is undefined, or contains anything other than an | |
5448 // AllocationSite, call an array constructor that doesn't use AllocationSites. | |
5449 __ lw(t0, FieldMemOperand(a2, 0)); | |
5450 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); | |
5451 __ Branch(&no_info, ne, t0, Operand(at)); | |
5452 | 5443 |
5453 __ lw(a3, FieldMemOperand(a2, AllocationSite::kTransitionInfoOffset)); | 5444 __ lw(a3, FieldMemOperand(a2, AllocationSite::kTransitionInfoOffset)); |
5454 __ SmiUntag(a3); | 5445 __ SmiUntag(a3); |
5455 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 5446 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
5456 __ And(a3, a3, Operand(AllocationSite::ElementsKindBits::kMask)); | 5447 __ And(a3, a3, Operand(AllocationSite::ElementsKindBits::kMask)); |
5457 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); | 5448 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); |
5458 | 5449 |
5459 __ bind(&no_info); | 5450 __ bind(&no_info); |
5460 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); | 5451 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); |
5461 } | 5452 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5676 MemOperand(fp, 6 * kPointerSize), | 5667 MemOperand(fp, 6 * kPointerSize), |
5677 NULL); | 5668 NULL); |
5678 } | 5669 } |
5679 | 5670 |
5680 | 5671 |
5681 #undef __ | 5672 #undef __ |
5682 | 5673 |
5683 } } // namespace v8::internal | 5674 } } // namespace v8::internal |
5684 | 5675 |
5685 #endif // V8_TARGET_ARCH_MIPS | 5676 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |