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 2944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { | 2955 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { |
2956 Register global = ToRegister(instr->global()); | 2956 Register global = ToRegister(instr->global()); |
2957 Register result = ToRegister(instr->result()); | 2957 Register result = ToRegister(instr->result()); |
2958 __ ldr(result, FieldMemOperand(global, GlobalObject::kGlobalReceiverOffset)); | 2958 __ ldr(result, FieldMemOperand(global, GlobalObject::kGlobalReceiverOffset)); |
2959 } | 2959 } |
2960 | 2960 |
2961 | 2961 |
2962 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 2962 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
2963 int arity, | 2963 int arity, |
2964 LInstruction* instr, | 2964 LInstruction* instr, |
2965 CallKind call_kind) { | 2965 CallKind call_kind, |
| 2966 R1State r1_state) { |
2966 bool can_invoke_directly = !function->NeedsArgumentsAdaption() || | 2967 bool can_invoke_directly = !function->NeedsArgumentsAdaption() || |
2967 function->shared()->formal_parameter_count() == arity; | 2968 function->shared()->formal_parameter_count() == arity; |
2968 | 2969 |
2969 LPointerMap* pointers = instr->pointer_map(); | 2970 LPointerMap* pointers = instr->pointer_map(); |
2970 RecordPosition(pointers->position()); | 2971 RecordPosition(pointers->position()); |
2971 | 2972 |
2972 if (can_invoke_directly) { | 2973 if (can_invoke_directly) { |
2973 __ LoadHeapObject(r1, function); | 2974 if (r1_state == R1_UNINITIALIZED) { |
| 2975 __ LoadHeapObject(r1, function); |
| 2976 } |
| 2977 |
2974 // Change context if needed. | 2978 // Change context if needed. |
2975 bool change_context = | 2979 bool change_context = |
2976 (info()->closure()->context() != function->context()) || | 2980 (info()->closure()->context() != function->context()) || |
2977 scope()->contains_with() || | 2981 scope()->contains_with() || |
2978 (scope()->num_heap_slots() > 0); | 2982 (scope()->num_heap_slots() > 0); |
2979 if (change_context) { | 2983 if (change_context) { |
2980 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 2984 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
2981 } | 2985 } |
2982 | 2986 |
2983 // Set r0 to arguments count if adaption is not needed. Assumes that r0 | 2987 // Set r0 to arguments count if adaption is not needed. Assumes that r0 |
(...skipping 18 matching lines...) Expand all Loading... |
3002 // Restore context. | 3006 // Restore context. |
3003 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3007 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
3004 } | 3008 } |
3005 | 3009 |
3006 | 3010 |
3007 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 3011 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
3008 ASSERT(ToRegister(instr->result()).is(r0)); | 3012 ASSERT(ToRegister(instr->result()).is(r0)); |
3009 CallKnownFunction(instr->function(), | 3013 CallKnownFunction(instr->function(), |
3010 instr->arity(), | 3014 instr->arity(), |
3011 instr, | 3015 instr, |
3012 CALL_AS_METHOD); | 3016 CALL_AS_METHOD, |
| 3017 R1_UNINITIALIZED); |
3013 } | 3018 } |
3014 | 3019 |
3015 | 3020 |
3016 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { | 3021 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
3017 Register input = ToRegister(instr->InputAt(0)); | 3022 Register input = ToRegister(instr->InputAt(0)); |
3018 Register result = ToRegister(instr->result()); | 3023 Register result = ToRegister(instr->result()); |
3019 Register scratch = scratch0(); | 3024 Register scratch = scratch0(); |
3020 | 3025 |
3021 // Deoptimize if not a heap number. | 3026 // Deoptimize if not a heap number. |
3022 __ ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); | 3027 __ ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3427 Abort("Unimplemented type of LUnaryMathOperation."); | 3432 Abort("Unimplemented type of LUnaryMathOperation."); |
3428 UNREACHABLE(); | 3433 UNREACHABLE(); |
3429 } | 3434 } |
3430 } | 3435 } |
3431 | 3436 |
3432 | 3437 |
3433 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3438 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
3434 ASSERT(ToRegister(instr->function()).is(r1)); | 3439 ASSERT(ToRegister(instr->function()).is(r1)); |
3435 ASSERT(instr->HasPointerMap()); | 3440 ASSERT(instr->HasPointerMap()); |
3436 ASSERT(instr->HasDeoptimizationEnvironment()); | 3441 ASSERT(instr->HasDeoptimizationEnvironment()); |
3437 LPointerMap* pointers = instr->pointer_map(); | 3442 |
3438 RecordPosition(pointers->position()); | 3443 if (instr->known_function().is_null()) { |
3439 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3444 LPointerMap* pointers = instr->pointer_map(); |
3440 ParameterCount count(instr->arity()); | 3445 RecordPosition(pointers->position()); |
3441 __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); | 3446 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
3442 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3447 ParameterCount count(instr->arity()); |
| 3448 __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
| 3449 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3450 } else { |
| 3451 CallKnownFunction(instr->known_function(), |
| 3452 instr->arity(), |
| 3453 instr, |
| 3454 CALL_AS_METHOD, |
| 3455 R1_CONTAINS_TARGET); |
| 3456 } |
3443 } | 3457 } |
3444 | 3458 |
3445 | 3459 |
3446 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 3460 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
3447 ASSERT(ToRegister(instr->result()).is(r0)); | 3461 ASSERT(ToRegister(instr->result()).is(r0)); |
3448 | 3462 |
3449 int arity = instr->arity(); | 3463 int arity = instr->arity(); |
3450 Handle<Code> ic = | 3464 Handle<Code> ic = |
3451 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); | 3465 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); |
3452 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3466 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3487 Handle<Code> ic = | 3501 Handle<Code> ic = |
3488 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); | 3502 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); |
3489 __ mov(r2, Operand(instr->name())); | 3503 __ mov(r2, Operand(instr->name())); |
3490 CallCode(ic, mode, instr); | 3504 CallCode(ic, mode, instr); |
3491 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3505 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
3492 } | 3506 } |
3493 | 3507 |
3494 | 3508 |
3495 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { | 3509 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { |
3496 ASSERT(ToRegister(instr->result()).is(r0)); | 3510 ASSERT(ToRegister(instr->result()).is(r0)); |
3497 CallKnownFunction(instr->target(), instr->arity(), instr, CALL_AS_FUNCTION); | 3511 CallKnownFunction(instr->target(), |
| 3512 instr->arity(), |
| 3513 instr, |
| 3514 CALL_AS_FUNCTION, |
| 3515 R1_UNINITIALIZED); |
3498 } | 3516 } |
3499 | 3517 |
3500 | 3518 |
3501 void LCodeGen::DoCallNew(LCallNew* instr) { | 3519 void LCodeGen::DoCallNew(LCallNew* instr) { |
3502 ASSERT(ToRegister(instr->InputAt(0)).is(r1)); | 3520 ASSERT(ToRegister(instr->InputAt(0)).is(r1)); |
3503 ASSERT(ToRegister(instr->result()).is(r0)); | 3521 ASSERT(ToRegister(instr->result()).is(r0)); |
3504 | 3522 |
3505 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); | 3523 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
3506 __ mov(r0, Operand(instr->arity())); | 3524 __ mov(r0, Operand(instr->arity())); |
3507 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); | 3525 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5156 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 5174 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
5157 __ ldr(result, FieldMemOperand(scratch, | 5175 __ ldr(result, FieldMemOperand(scratch, |
5158 FixedArray::kHeaderSize - kPointerSize)); | 5176 FixedArray::kHeaderSize - kPointerSize)); |
5159 __ bind(&done); | 5177 __ bind(&done); |
5160 } | 5178 } |
5161 | 5179 |
5162 | 5180 |
5163 #undef __ | 5181 #undef __ |
5164 | 5182 |
5165 } } // namespace v8::internal | 5183 } } // namespace v8::internal |
OLD | NEW |