| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 __ Subu(sp, sp, Operand(slots * kPointerSize)); | 246 __ Subu(sp, sp, Operand(slots * kPointerSize)); |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 bool LCodeGen::GenerateDeferredCode() { | 250 bool LCodeGen::GenerateDeferredCode() { |
| 251 ASSERT(is_generating()); | 251 ASSERT(is_generating()); |
| 252 if (deferred_.length() > 0) { | 252 if (deferred_.length() > 0) { |
| 253 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 253 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
| 254 LDeferredCode* code = deferred_[i]; | 254 LDeferredCode* code = deferred_[i]; |
| 255 | 255 |
| 256 int pos = instructions_->at(code->instruction_index())->position(); | 256 HValue* value = |
| 257 RecordAndUpdatePosition(pos); | 257 instructions_->at(code->instruction_index())->hydrogen_value(); |
| 258 RecordAndWritePosition(value->position()); |
| 258 | 259 |
| 259 Comment(";;; <@%d,#%d> " | 260 Comment(";;; <@%d,#%d> " |
| 260 "-------------------- Deferred %s --------------------", | 261 "-------------------- Deferred %s --------------------", |
| 261 code->instruction_index(), | 262 code->instruction_index(), |
| 262 code->instr()->hydrogen_value()->id(), | 263 code->instr()->hydrogen_value()->id(), |
| 263 code->instr()->Mnemonic()); | 264 code->instr()->Mnemonic()); |
| 264 __ bind(code->entry()); | 265 __ bind(code->entry()); |
| 265 if (NeedsDeferredFrame()) { | 266 if (NeedsDeferredFrame()) { |
| 266 Comment(";;; Build frame"); | 267 Comment(";;; Build frame"); |
| 267 ASSERT(!frame_is_built_); | 268 ASSERT(!frame_is_built_); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT); | 650 CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT); |
| 650 } | 651 } |
| 651 | 652 |
| 652 | 653 |
| 653 void LCodeGen::CallCodeGeneric(Handle<Code> code, | 654 void LCodeGen::CallCodeGeneric(Handle<Code> code, |
| 654 RelocInfo::Mode mode, | 655 RelocInfo::Mode mode, |
| 655 LInstruction* instr, | 656 LInstruction* instr, |
| 656 SafepointMode safepoint_mode) { | 657 SafepointMode safepoint_mode) { |
| 657 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); | 658 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); |
| 658 ASSERT(instr != NULL); | 659 ASSERT(instr != NULL); |
| 659 LPointerMap* pointers = instr->pointer_map(); | |
| 660 RecordPosition(pointers->position()); | |
| 661 __ Call(code, mode); | 660 __ Call(code, mode); |
| 662 RecordSafepointWithLazyDeopt(instr, safepoint_mode); | 661 RecordSafepointWithLazyDeopt(instr, safepoint_mode); |
| 663 } | 662 } |
| 664 | 663 |
| 665 | 664 |
| 666 void LCodeGen::CallRuntime(const Runtime::Function* function, | 665 void LCodeGen::CallRuntime(const Runtime::Function* function, |
| 667 int num_arguments, | 666 int num_arguments, |
| 668 LInstruction* instr, | 667 LInstruction* instr, |
| 669 SaveFPRegsMode save_doubles) { | 668 SaveFPRegsMode save_doubles) { |
| 670 ASSERT(instr != NULL); | 669 ASSERT(instr != NULL); |
| 671 LPointerMap* pointers = instr->pointer_map(); | |
| 672 ASSERT(pointers != NULL); | |
| 673 RecordPosition(pointers->position()); | |
| 674 | 670 |
| 675 __ CallRuntime(function, num_arguments, save_doubles); | 671 __ CallRuntime(function, num_arguments, save_doubles); |
| 676 | 672 |
| 677 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); | 673 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
| 678 } | 674 } |
| 679 | 675 |
| 680 | 676 |
| 681 void LCodeGen::LoadContextFromDeferred(LOperand* context) { | 677 void LCodeGen::LoadContextFromDeferred(LOperand* context) { |
| 682 if (context->IsRegister()) { | 678 if (context->IsRegister()) { |
| 683 __ Move(cp, ToRegister(context)); | 679 __ Move(cp, ToRegister(context)); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 } | 926 } |
| 931 | 927 |
| 932 | 928 |
| 933 void LCodeGen::RecordSafepoint(LPointerMap* pointers, | 929 void LCodeGen::RecordSafepoint(LPointerMap* pointers, |
| 934 Safepoint::DeoptMode deopt_mode) { | 930 Safepoint::DeoptMode deopt_mode) { |
| 935 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); | 931 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); |
| 936 } | 932 } |
| 937 | 933 |
| 938 | 934 |
| 939 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { | 935 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { |
| 940 LPointerMap empty_pointers(RelocInfo::kNoPosition, zone()); | 936 LPointerMap empty_pointers(zone()); |
| 941 RecordSafepoint(&empty_pointers, deopt_mode); | 937 RecordSafepoint(&empty_pointers, deopt_mode); |
| 942 } | 938 } |
| 943 | 939 |
| 944 | 940 |
| 945 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, | 941 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, |
| 946 int arguments, | 942 int arguments, |
| 947 Safepoint::DeoptMode deopt_mode) { | 943 Safepoint::DeoptMode deopt_mode) { |
| 948 RecordSafepoint( | 944 RecordSafepoint( |
| 949 pointers, Safepoint::kWithRegisters, arguments, deopt_mode); | 945 pointers, Safepoint::kWithRegisters, arguments, deopt_mode); |
| 950 } | 946 } |
| 951 | 947 |
| 952 | 948 |
| 953 void LCodeGen::RecordSafepointWithRegistersAndDoubles( | 949 void LCodeGen::RecordSafepointWithRegistersAndDoubles( |
| 954 LPointerMap* pointers, | 950 LPointerMap* pointers, |
| 955 int arguments, | 951 int arguments, |
| 956 Safepoint::DeoptMode deopt_mode) { | 952 Safepoint::DeoptMode deopt_mode) { |
| 957 RecordSafepoint( | 953 RecordSafepoint( |
| 958 pointers, Safepoint::kWithRegistersAndDoubles, arguments, deopt_mode); | 954 pointers, Safepoint::kWithRegistersAndDoubles, arguments, deopt_mode); |
| 959 } | 955 } |
| 960 | 956 |
| 961 | 957 |
| 962 void LCodeGen::RecordPosition(int position) { | 958 void LCodeGen::RecordAndWritePosition(int position) { |
| 963 if (position == RelocInfo::kNoPosition) return; | 959 if (position == RelocInfo::kNoPosition) return; |
| 964 masm()->positions_recorder()->RecordPosition(position); | 960 masm()->positions_recorder()->RecordPosition(position); |
| 961 masm()->positions_recorder()->WriteRecordedPositions(); |
| 965 } | 962 } |
| 966 | 963 |
| 967 | 964 |
| 968 void LCodeGen::RecordAndUpdatePosition(int position) { | |
| 969 if (position >= 0 && position != old_position_) { | |
| 970 masm()->positions_recorder()->RecordPosition(position); | |
| 971 old_position_ = position; | |
| 972 } | |
| 973 } | |
| 974 | |
| 975 | |
| 976 static const char* LabelType(LLabel* label) { | 965 static const char* LabelType(LLabel* label) { |
| 977 if (label->is_loop_header()) return " (loop header)"; | 966 if (label->is_loop_header()) return " (loop header)"; |
| 978 if (label->is_osr_entry()) return " (OSR entry)"; | 967 if (label->is_osr_entry()) return " (OSR entry)"; |
| 979 return ""; | 968 return ""; |
| 980 } | 969 } |
| 981 | 970 |
| 982 | 971 |
| 983 void LCodeGen::DoLabel(LLabel* label) { | 972 void LCodeGen::DoLabel(LLabel* label) { |
| 984 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", | 973 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", |
| 985 current_instruction_, | 974 current_instruction_, |
| (...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3367 __ Addu(scratch, elements, scratch); | 3356 __ Addu(scratch, elements, scratch); |
| 3368 __ lw(scratch, MemOperand(scratch)); | 3357 __ lw(scratch, MemOperand(scratch)); |
| 3369 __ push(scratch); | 3358 __ push(scratch); |
| 3370 __ Subu(length, length, Operand(1)); | 3359 __ Subu(length, length, Operand(1)); |
| 3371 __ Branch(USE_DELAY_SLOT, &loop, ne, length, Operand(zero_reg)); | 3360 __ Branch(USE_DELAY_SLOT, &loop, ne, length, Operand(zero_reg)); |
| 3372 __ sll(scratch, length, 2); | 3361 __ sll(scratch, length, 2); |
| 3373 | 3362 |
| 3374 __ bind(&invoke); | 3363 __ bind(&invoke); |
| 3375 ASSERT(instr->HasPointerMap()); | 3364 ASSERT(instr->HasPointerMap()); |
| 3376 LPointerMap* pointers = instr->pointer_map(); | 3365 LPointerMap* pointers = instr->pointer_map(); |
| 3377 RecordPosition(pointers->position()); | |
| 3378 SafepointGenerator safepoint_generator( | 3366 SafepointGenerator safepoint_generator( |
| 3379 this, pointers, Safepoint::kLazyDeopt); | 3367 this, pointers, Safepoint::kLazyDeopt); |
| 3380 // The number of arguments is stored in receiver which is a0, as expected | 3368 // The number of arguments is stored in receiver which is a0, as expected |
| 3381 // by InvokeFunction. | 3369 // by InvokeFunction. |
| 3382 ParameterCount actual(receiver); | 3370 ParameterCount actual(receiver); |
| 3383 __ InvokeFunction(function, actual, CALL_FUNCTION, | 3371 __ InvokeFunction(function, actual, CALL_FUNCTION, |
| 3384 safepoint_generator, CALL_AS_METHOD); | 3372 safepoint_generator, CALL_AS_METHOD); |
| 3385 } | 3373 } |
| 3386 | 3374 |
| 3387 | 3375 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 int arity, | 3444 int arity, |
| 3457 LInstruction* instr, | 3445 LInstruction* instr, |
| 3458 CallKind call_kind, | 3446 CallKind call_kind, |
| 3459 A1State a1_state) { | 3447 A1State a1_state) { |
| 3460 bool dont_adapt_arguments = | 3448 bool dont_adapt_arguments = |
| 3461 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3449 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
| 3462 bool can_invoke_directly = | 3450 bool can_invoke_directly = |
| 3463 dont_adapt_arguments || formal_parameter_count == arity; | 3451 dont_adapt_arguments || formal_parameter_count == arity; |
| 3464 | 3452 |
| 3465 LPointerMap* pointers = instr->pointer_map(); | 3453 LPointerMap* pointers = instr->pointer_map(); |
| 3466 RecordPosition(pointers->position()); | |
| 3467 | 3454 |
| 3468 if (can_invoke_directly) { | 3455 if (can_invoke_directly) { |
| 3469 if (a1_state == A1_UNINITIALIZED) { | 3456 if (a1_state == A1_UNINITIALIZED) { |
| 3470 __ LoadHeapObject(a1, function); | 3457 __ LoadHeapObject(a1, function); |
| 3471 } | 3458 } |
| 3472 | 3459 |
| 3473 // Change context. | 3460 // Change context. |
| 3474 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 3461 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 3475 | 3462 |
| 3476 // Set r0 to arguments count if adaption is not needed. Assumes that r0 | 3463 // Set r0 to arguments count if adaption is not needed. Assumes that r0 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3914 | 3901 |
| 3915 | 3902 |
| 3916 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3903 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
| 3917 ASSERT(ToRegister(instr->context()).is(cp)); | 3904 ASSERT(ToRegister(instr->context()).is(cp)); |
| 3918 ASSERT(ToRegister(instr->function()).is(a1)); | 3905 ASSERT(ToRegister(instr->function()).is(a1)); |
| 3919 ASSERT(instr->HasPointerMap()); | 3906 ASSERT(instr->HasPointerMap()); |
| 3920 | 3907 |
| 3921 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); | 3908 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); |
| 3922 if (known_function.is_null()) { | 3909 if (known_function.is_null()) { |
| 3923 LPointerMap* pointers = instr->pointer_map(); | 3910 LPointerMap* pointers = instr->pointer_map(); |
| 3924 RecordPosition(pointers->position()); | |
| 3925 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3911 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3926 ParameterCount count(instr->arity()); | 3912 ParameterCount count(instr->arity()); |
| 3927 __ InvokeFunction(a1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); | 3913 __ InvokeFunction(a1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
| 3928 } else { | 3914 } else { |
| 3929 CallKnownFunction(known_function, | 3915 CallKnownFunction(known_function, |
| 3930 instr->hydrogen()->formal_parameter_count(), | 3916 instr->hydrogen()->formal_parameter_count(), |
| 3931 instr->arity(), | 3917 instr->arity(), |
| 3932 instr, | 3918 instr, |
| 3933 CALL_AS_METHOD, | 3919 CALL_AS_METHOD, |
| 3934 A1_CONTAINS_TARGET); | 3920 A1_CONTAINS_TARGET); |
| (...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5830 __ Subu(scratch, result, scratch); | 5816 __ Subu(scratch, result, scratch); |
| 5831 __ lw(result, FieldMemOperand(scratch, | 5817 __ lw(result, FieldMemOperand(scratch, |
| 5832 FixedArray::kHeaderSize - kPointerSize)); | 5818 FixedArray::kHeaderSize - kPointerSize)); |
| 5833 __ bind(&done); | 5819 __ bind(&done); |
| 5834 } | 5820 } |
| 5835 | 5821 |
| 5836 | 5822 |
| 5837 #undef __ | 5823 #undef __ |
| 5838 | 5824 |
| 5839 } } // namespace v8::internal | 5825 } } // namespace v8::internal |
| OLD | NEW |