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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 __ sub(sp, sp, Operand(slots * kPointerSize)); | 252 __ sub(sp, sp, Operand(slots * kPointerSize)); |
253 } | 253 } |
254 | 254 |
255 | 255 |
256 bool LCodeGen::GenerateDeferredCode() { | 256 bool LCodeGen::GenerateDeferredCode() { |
257 ASSERT(is_generating()); | 257 ASSERT(is_generating()); |
258 if (deferred_.length() > 0) { | 258 if (deferred_.length() > 0) { |
259 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 259 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
260 LDeferredCode* code = deferred_[i]; | 260 LDeferredCode* code = deferred_[i]; |
261 | 261 |
262 int pos = instructions_->at(code->instruction_index())->position(); | 262 HValue* value = |
263 RecordAndUpdatePosition(pos); | 263 instructions_->at(code->instruction_index())->hydrogen_value(); |
| 264 RecordAndWritePosition(value->position()); |
264 | 265 |
265 Comment(";;; <@%d,#%d> " | 266 Comment(";;; <@%d,#%d> " |
266 "-------------------- Deferred %s --------------------", | 267 "-------------------- Deferred %s --------------------", |
267 code->instruction_index(), | 268 code->instruction_index(), |
268 code->instr()->hydrogen_value()->id(), | 269 code->instr()->hydrogen_value()->id(), |
269 code->instr()->Mnemonic()); | 270 code->instr()->Mnemonic()); |
270 __ bind(code->entry()); | 271 __ bind(code->entry()); |
271 if (NeedsDeferredFrame()) { | 272 if (NeedsDeferredFrame()) { |
272 Comment(";;; Build frame"); | 273 Comment(";;; Build frame"); |
273 ASSERT(!frame_is_built_); | 274 ASSERT(!frame_is_built_); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 void LCodeGen::CallCodeGeneric(Handle<Code> code, | 679 void LCodeGen::CallCodeGeneric(Handle<Code> code, |
679 RelocInfo::Mode mode, | 680 RelocInfo::Mode mode, |
680 LInstruction* instr, | 681 LInstruction* instr, |
681 SafepointMode safepoint_mode, | 682 SafepointMode safepoint_mode, |
682 TargetAddressStorageMode storage_mode) { | 683 TargetAddressStorageMode storage_mode) { |
683 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); | 684 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); |
684 ASSERT(instr != NULL); | 685 ASSERT(instr != NULL); |
685 // Block literal pool emission to ensure nop indicating no inlined smi code | 686 // Block literal pool emission to ensure nop indicating no inlined smi code |
686 // is in the correct position. | 687 // is in the correct position. |
687 Assembler::BlockConstPoolScope block_const_pool(masm()); | 688 Assembler::BlockConstPoolScope block_const_pool(masm()); |
688 LPointerMap* pointers = instr->pointer_map(); | |
689 RecordPosition(pointers->position()); | |
690 __ Call(code, mode, TypeFeedbackId::None(), al, storage_mode); | 689 __ Call(code, mode, TypeFeedbackId::None(), al, storage_mode); |
691 RecordSafepointWithLazyDeopt(instr, safepoint_mode); | 690 RecordSafepointWithLazyDeopt(instr, safepoint_mode); |
692 | 691 |
693 // Signal that we don't inline smi code before these stubs in the | 692 // Signal that we don't inline smi code before these stubs in the |
694 // optimizing code generator. | 693 // optimizing code generator. |
695 if (code->kind() == Code::BINARY_OP_IC || | 694 if (code->kind() == Code::BINARY_OP_IC || |
696 code->kind() == Code::COMPARE_IC) { | 695 code->kind() == Code::COMPARE_IC) { |
697 __ nop(); | 696 __ nop(); |
698 } | 697 } |
699 } | 698 } |
700 | 699 |
701 | 700 |
702 void LCodeGen::CallRuntime(const Runtime::Function* function, | 701 void LCodeGen::CallRuntime(const Runtime::Function* function, |
703 int num_arguments, | 702 int num_arguments, |
704 LInstruction* instr, | 703 LInstruction* instr, |
705 SaveFPRegsMode save_doubles) { | 704 SaveFPRegsMode save_doubles) { |
706 ASSERT(instr != NULL); | 705 ASSERT(instr != NULL); |
707 LPointerMap* pointers = instr->pointer_map(); | |
708 ASSERT(pointers != NULL); | |
709 RecordPosition(pointers->position()); | |
710 | 706 |
711 __ CallRuntime(function, num_arguments, save_doubles); | 707 __ CallRuntime(function, num_arguments, save_doubles); |
712 | 708 |
713 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); | 709 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
714 } | 710 } |
715 | 711 |
716 | 712 |
717 void LCodeGen::LoadContextFromDeferred(LOperand* context) { | 713 void LCodeGen::LoadContextFromDeferred(LOperand* context) { |
718 if (context->IsRegister()) { | 714 if (context->IsRegister()) { |
719 __ Move(cp, ToRegister(context)); | 715 __ Move(cp, ToRegister(context)); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 } | 953 } |
958 | 954 |
959 | 955 |
960 void LCodeGen::RecordSafepoint(LPointerMap* pointers, | 956 void LCodeGen::RecordSafepoint(LPointerMap* pointers, |
961 Safepoint::DeoptMode deopt_mode) { | 957 Safepoint::DeoptMode deopt_mode) { |
962 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); | 958 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); |
963 } | 959 } |
964 | 960 |
965 | 961 |
966 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { | 962 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { |
967 LPointerMap empty_pointers(RelocInfo::kNoPosition, zone()); | 963 LPointerMap empty_pointers(zone()); |
968 RecordSafepoint(&empty_pointers, deopt_mode); | 964 RecordSafepoint(&empty_pointers, deopt_mode); |
969 } | 965 } |
970 | 966 |
971 | 967 |
972 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, | 968 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, |
973 int arguments, | 969 int arguments, |
974 Safepoint::DeoptMode deopt_mode) { | 970 Safepoint::DeoptMode deopt_mode) { |
975 RecordSafepoint( | 971 RecordSafepoint( |
976 pointers, Safepoint::kWithRegisters, arguments, deopt_mode); | 972 pointers, Safepoint::kWithRegisters, arguments, deopt_mode); |
977 } | 973 } |
978 | 974 |
979 | 975 |
980 void LCodeGen::RecordSafepointWithRegistersAndDoubles( | 976 void LCodeGen::RecordSafepointWithRegistersAndDoubles( |
981 LPointerMap* pointers, | 977 LPointerMap* pointers, |
982 int arguments, | 978 int arguments, |
983 Safepoint::DeoptMode deopt_mode) { | 979 Safepoint::DeoptMode deopt_mode) { |
984 RecordSafepoint( | 980 RecordSafepoint( |
985 pointers, Safepoint::kWithRegistersAndDoubles, arguments, deopt_mode); | 981 pointers, Safepoint::kWithRegistersAndDoubles, arguments, deopt_mode); |
986 } | 982 } |
987 | 983 |
988 | 984 |
989 void LCodeGen::RecordPosition(int position) { | 985 void LCodeGen::RecordAndWritePosition(int position) { |
990 if (position == RelocInfo::kNoPosition) return; | 986 if (position == RelocInfo::kNoPosition) return; |
991 masm()->positions_recorder()->RecordPosition(position); | 987 masm()->positions_recorder()->RecordPosition(position); |
| 988 masm()->positions_recorder()->WriteRecordedPositions(); |
992 } | 989 } |
993 | 990 |
994 | 991 |
995 void LCodeGen::RecordAndUpdatePosition(int position) { | |
996 if (position >= 0 && position != old_position_) { | |
997 masm()->positions_recorder()->RecordPosition(position); | |
998 old_position_ = position; | |
999 } | |
1000 } | |
1001 | |
1002 | |
1003 static const char* LabelType(LLabel* label) { | 992 static const char* LabelType(LLabel* label) { |
1004 if (label->is_loop_header()) return " (loop header)"; | 993 if (label->is_loop_header()) return " (loop header)"; |
1005 if (label->is_osr_entry()) return " (OSR entry)"; | 994 if (label->is_osr_entry()) return " (OSR entry)"; |
1006 return ""; | 995 return ""; |
1007 } | 996 } |
1008 | 997 |
1009 | 998 |
1010 void LCodeGen::DoLabel(LLabel* label) { | 999 void LCodeGen::DoLabel(LLabel* label) { |
1011 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", | 1000 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", |
1012 current_instruction_, | 1001 current_instruction_, |
(...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3496 __ b(eq, &invoke); | 3485 __ b(eq, &invoke); |
3497 __ bind(&loop); | 3486 __ bind(&loop); |
3498 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); | 3487 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); |
3499 __ push(scratch); | 3488 __ push(scratch); |
3500 __ sub(length, length, Operand(1), SetCC); | 3489 __ sub(length, length, Operand(1), SetCC); |
3501 __ b(ne, &loop); | 3490 __ b(ne, &loop); |
3502 | 3491 |
3503 __ bind(&invoke); | 3492 __ bind(&invoke); |
3504 ASSERT(instr->HasPointerMap()); | 3493 ASSERT(instr->HasPointerMap()); |
3505 LPointerMap* pointers = instr->pointer_map(); | 3494 LPointerMap* pointers = instr->pointer_map(); |
3506 RecordPosition(pointers->position()); | |
3507 SafepointGenerator safepoint_generator( | 3495 SafepointGenerator safepoint_generator( |
3508 this, pointers, Safepoint::kLazyDeopt); | 3496 this, pointers, Safepoint::kLazyDeopt); |
3509 // The number of arguments is stored in receiver which is r0, as expected | 3497 // The number of arguments is stored in receiver which is r0, as expected |
3510 // by InvokeFunction. | 3498 // by InvokeFunction. |
3511 ParameterCount actual(receiver); | 3499 ParameterCount actual(receiver); |
3512 __ InvokeFunction(function, actual, CALL_FUNCTION, | 3500 __ InvokeFunction(function, actual, CALL_FUNCTION, |
3513 safepoint_generator, CALL_AS_METHOD); | 3501 safepoint_generator, CALL_AS_METHOD); |
3514 } | 3502 } |
3515 | 3503 |
3516 | 3504 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3586 int arity, | 3574 int arity, |
3587 LInstruction* instr, | 3575 LInstruction* instr, |
3588 CallKind call_kind, | 3576 CallKind call_kind, |
3589 R1State r1_state) { | 3577 R1State r1_state) { |
3590 bool dont_adapt_arguments = | 3578 bool dont_adapt_arguments = |
3591 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3579 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
3592 bool can_invoke_directly = | 3580 bool can_invoke_directly = |
3593 dont_adapt_arguments || formal_parameter_count == arity; | 3581 dont_adapt_arguments || formal_parameter_count == arity; |
3594 | 3582 |
3595 LPointerMap* pointers = instr->pointer_map(); | 3583 LPointerMap* pointers = instr->pointer_map(); |
3596 RecordPosition(pointers->position()); | |
3597 | 3584 |
3598 if (can_invoke_directly) { | 3585 if (can_invoke_directly) { |
3599 if (r1_state == R1_UNINITIALIZED) { | 3586 if (r1_state == R1_UNINITIALIZED) { |
3600 __ LoadHeapObject(r1, function); | 3587 __ LoadHeapObject(r1, function); |
3601 } | 3588 } |
3602 | 3589 |
3603 // Change context. | 3590 // Change context. |
3604 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 3591 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
3605 | 3592 |
3606 // Set r0 to arguments count if adaption is not needed. Assumes that r0 | 3593 // Set r0 to arguments count if adaption is not needed. Assumes that r0 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3998 | 3985 |
3999 | 3986 |
4000 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3987 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
4001 ASSERT(ToRegister(instr->context()).is(cp)); | 3988 ASSERT(ToRegister(instr->context()).is(cp)); |
4002 ASSERT(ToRegister(instr->function()).is(r1)); | 3989 ASSERT(ToRegister(instr->function()).is(r1)); |
4003 ASSERT(instr->HasPointerMap()); | 3990 ASSERT(instr->HasPointerMap()); |
4004 | 3991 |
4005 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); | 3992 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); |
4006 if (known_function.is_null()) { | 3993 if (known_function.is_null()) { |
4007 LPointerMap* pointers = instr->pointer_map(); | 3994 LPointerMap* pointers = instr->pointer_map(); |
4008 RecordPosition(pointers->position()); | |
4009 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3995 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
4010 ParameterCount count(instr->arity()); | 3996 ParameterCount count(instr->arity()); |
4011 __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); | 3997 __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
4012 } else { | 3998 } else { |
4013 CallKnownFunction(known_function, | 3999 CallKnownFunction(known_function, |
4014 instr->hydrogen()->formal_parameter_count(), | 4000 instr->hydrogen()->formal_parameter_count(), |
4015 instr->arity(), | 4001 instr->arity(), |
4016 instr, | 4002 instr, |
4017 CALL_AS_METHOD, | 4003 CALL_AS_METHOD, |
4018 R1_CONTAINS_TARGET); | 4004 R1_CONTAINS_TARGET); |
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5841 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5827 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5842 __ ldr(result, FieldMemOperand(scratch, | 5828 __ ldr(result, FieldMemOperand(scratch, |
5843 FixedArray::kHeaderSize - kPointerSize)); | 5829 FixedArray::kHeaderSize - kPointerSize)); |
5844 __ bind(&done); | 5830 __ bind(&done); |
5845 } | 5831 } |
5846 | 5832 |
5847 | 5833 |
5848 #undef __ | 5834 #undef __ |
5849 | 5835 |
5850 } } // namespace v8::internal | 5836 } } // namespace v8::internal |
OLD | NEW |