| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 int receiver_offset = scope()->num_parameters() * kPointerSize; | 127 int receiver_offset = scope()->num_parameters() * kPointerSize; |
| 128 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 128 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 129 __ sw(a2, MemOperand(sp, receiver_offset)); | 129 __ sw(a2, MemOperand(sp, receiver_offset)); |
| 130 __ bind(&ok); | 130 __ bind(&ok); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 info()->set_prologue_offset(masm_->pc_offset()); | 134 info()->set_prologue_offset(masm_->pc_offset()); |
| 135 if (NeedsEagerFrame()) { | 135 if (NeedsEagerFrame()) { |
| 136 if (info()->IsStub()) { | 136 __ Prologue(info()->IsStub() ? BUILD_STUB_FRAME : BUILD_FUNCTION_FRAME); |
| 137 __ Push(ra, fp, cp); | |
| 138 __ Push(Smi::FromInt(StackFrame::STUB)); | |
| 139 // Adjust FP to point to saved FP. | |
| 140 __ Addu(fp, sp, Operand(2 * kPointerSize)); | |
| 141 } else { | |
| 142 // The following three instructions must remain together and unmodified | |
| 143 // for code aging to work properly. | |
| 144 __ Push(ra, fp, cp, a1); | |
| 145 // Add unused nop to ensure prologue sequence is identical for | |
| 146 // full-codegen and lithium-codegen. | |
| 147 __ nop(Assembler::CODE_AGE_SEQUENCE_NOP); | |
| 148 // Adj. FP to point to saved FP. | |
| 149 __ Addu(fp, sp, Operand(2 * kPointerSize)); | |
| 150 } | |
| 151 frame_is_built_ = true; | 137 frame_is_built_ = true; |
| 152 info_->AddNoFrameRange(0, masm_->pc_offset()); | 138 info_->AddNoFrameRange(0, masm_->pc_offset()); |
| 153 } | 139 } |
| 154 | 140 |
| 155 // Reserve space for the stack slots needed by the code. | 141 // Reserve space for the stack slots needed by the code. |
| 156 int slots = GetStackSlotCount(); | 142 int slots = GetStackSlotCount(); |
| 157 if (slots > 0) { | 143 if (slots > 0) { |
| 158 if (FLAG_debug_code) { | 144 if (FLAG_debug_code) { |
| 159 __ Subu(sp, sp, Operand(slots * kPointerSize)); | 145 __ Subu(sp, sp, Operand(slots * kPointerSize)); |
| 160 __ push(a0); | 146 __ push(a0); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 __ Subu(sp, sp, Operand(slots * kPointerSize)); | 232 __ Subu(sp, sp, Operand(slots * kPointerSize)); |
| 247 } | 233 } |
| 248 | 234 |
| 249 | 235 |
| 250 bool LCodeGen::GenerateDeferredCode() { | 236 bool LCodeGen::GenerateDeferredCode() { |
| 251 ASSERT(is_generating()); | 237 ASSERT(is_generating()); |
| 252 if (deferred_.length() > 0) { | 238 if (deferred_.length() > 0) { |
| 253 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 239 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
| 254 LDeferredCode* code = deferred_[i]; | 240 LDeferredCode* code = deferred_[i]; |
| 255 | 241 |
| 256 int pos = instructions_->at(code->instruction_index())->position(); | 242 HValue* value = |
| 257 RecordAndUpdatePosition(pos); | 243 instructions_->at(code->instruction_index())->hydrogen_value(); |
| 244 RecordAndWritePosition(value->position()); |
| 258 | 245 |
| 259 Comment(";;; <@%d,#%d> " | 246 Comment(";;; <@%d,#%d> " |
| 260 "-------------------- Deferred %s --------------------", | 247 "-------------------- Deferred %s --------------------", |
| 261 code->instruction_index(), | 248 code->instruction_index(), |
| 262 code->instr()->hydrogen_value()->id(), | 249 code->instr()->hydrogen_value()->id(), |
| 263 code->instr()->Mnemonic()); | 250 code->instr()->Mnemonic()); |
| 264 __ bind(code->entry()); | 251 __ bind(code->entry()); |
| 265 if (NeedsDeferredFrame()) { | 252 if (NeedsDeferredFrame()) { |
| 266 Comment(";;; Build frame"); | 253 Comment(";;; Build frame"); |
| 267 ASSERT(!frame_is_built_); | 254 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); | 636 CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT); |
| 650 } | 637 } |
| 651 | 638 |
| 652 | 639 |
| 653 void LCodeGen::CallCodeGeneric(Handle<Code> code, | 640 void LCodeGen::CallCodeGeneric(Handle<Code> code, |
| 654 RelocInfo::Mode mode, | 641 RelocInfo::Mode mode, |
| 655 LInstruction* instr, | 642 LInstruction* instr, |
| 656 SafepointMode safepoint_mode) { | 643 SafepointMode safepoint_mode) { |
| 657 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); | 644 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); |
| 658 ASSERT(instr != NULL); | 645 ASSERT(instr != NULL); |
| 659 LPointerMap* pointers = instr->pointer_map(); | |
| 660 RecordPosition(pointers->position()); | |
| 661 __ Call(code, mode); | 646 __ Call(code, mode); |
| 662 RecordSafepointWithLazyDeopt(instr, safepoint_mode); | 647 RecordSafepointWithLazyDeopt(instr, safepoint_mode); |
| 663 } | 648 } |
| 664 | 649 |
| 665 | 650 |
| 666 void LCodeGen::CallRuntime(const Runtime::Function* function, | 651 void LCodeGen::CallRuntime(const Runtime::Function* function, |
| 667 int num_arguments, | 652 int num_arguments, |
| 668 LInstruction* instr, | 653 LInstruction* instr, |
| 669 SaveFPRegsMode save_doubles) { | 654 SaveFPRegsMode save_doubles) { |
| 670 ASSERT(instr != NULL); | 655 ASSERT(instr != NULL); |
| 671 LPointerMap* pointers = instr->pointer_map(); | |
| 672 ASSERT(pointers != NULL); | |
| 673 RecordPosition(pointers->position()); | |
| 674 | 656 |
| 675 __ CallRuntime(function, num_arguments, save_doubles); | 657 __ CallRuntime(function, num_arguments, save_doubles); |
| 676 | 658 |
| 677 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); | 659 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
| 678 } | 660 } |
| 679 | 661 |
| 680 | 662 |
| 681 void LCodeGen::LoadContextFromDeferred(LOperand* context) { | 663 void LCodeGen::LoadContextFromDeferred(LOperand* context) { |
| 682 if (context->IsRegister()) { | 664 if (context->IsRegister()) { |
| 683 __ Move(cp, ToRegister(context)); | 665 __ Move(cp, ToRegister(context)); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 } | 912 } |
| 931 | 913 |
| 932 | 914 |
| 933 void LCodeGen::RecordSafepoint(LPointerMap* pointers, | 915 void LCodeGen::RecordSafepoint(LPointerMap* pointers, |
| 934 Safepoint::DeoptMode deopt_mode) { | 916 Safepoint::DeoptMode deopt_mode) { |
| 935 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); | 917 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); |
| 936 } | 918 } |
| 937 | 919 |
| 938 | 920 |
| 939 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { | 921 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { |
| 940 LPointerMap empty_pointers(RelocInfo::kNoPosition, zone()); | 922 LPointerMap empty_pointers(zone()); |
| 941 RecordSafepoint(&empty_pointers, deopt_mode); | 923 RecordSafepoint(&empty_pointers, deopt_mode); |
| 942 } | 924 } |
| 943 | 925 |
| 944 | 926 |
| 945 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, | 927 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, |
| 946 int arguments, | 928 int arguments, |
| 947 Safepoint::DeoptMode deopt_mode) { | 929 Safepoint::DeoptMode deopt_mode) { |
| 948 RecordSafepoint( | 930 RecordSafepoint( |
| 949 pointers, Safepoint::kWithRegisters, arguments, deopt_mode); | 931 pointers, Safepoint::kWithRegisters, arguments, deopt_mode); |
| 950 } | 932 } |
| 951 | 933 |
| 952 | 934 |
| 953 void LCodeGen::RecordSafepointWithRegistersAndDoubles( | 935 void LCodeGen::RecordSafepointWithRegistersAndDoubles( |
| 954 LPointerMap* pointers, | 936 LPointerMap* pointers, |
| 955 int arguments, | 937 int arguments, |
| 956 Safepoint::DeoptMode deopt_mode) { | 938 Safepoint::DeoptMode deopt_mode) { |
| 957 RecordSafepoint( | 939 RecordSafepoint( |
| 958 pointers, Safepoint::kWithRegistersAndDoubles, arguments, deopt_mode); | 940 pointers, Safepoint::kWithRegistersAndDoubles, arguments, deopt_mode); |
| 959 } | 941 } |
| 960 | 942 |
| 961 | 943 |
| 962 void LCodeGen::RecordPosition(int position) { | 944 void LCodeGen::RecordAndWritePosition(int position) { |
| 963 if (position == RelocInfo::kNoPosition) return; | 945 if (position == RelocInfo::kNoPosition) return; |
| 964 masm()->positions_recorder()->RecordPosition(position); | 946 masm()->positions_recorder()->RecordPosition(position); |
| 947 masm()->positions_recorder()->WriteRecordedPositions(); |
| 965 } | 948 } |
| 966 | 949 |
| 967 | 950 |
| 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) { | 951 static const char* LabelType(LLabel* label) { |
| 977 if (label->is_loop_header()) return " (loop header)"; | 952 if (label->is_loop_header()) return " (loop header)"; |
| 978 if (label->is_osr_entry()) return " (OSR entry)"; | 953 if (label->is_osr_entry()) return " (OSR entry)"; |
| 979 return ""; | 954 return ""; |
| 980 } | 955 } |
| 981 | 956 |
| 982 | 957 |
| 983 void LCodeGen::DoLabel(LLabel* label) { | 958 void LCodeGen::DoLabel(LLabel* label) { |
| 984 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", | 959 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", |
| 985 current_instruction_, | 960 current_instruction_, |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 } | 2146 } |
| 2172 | 2147 |
| 2173 | 2148 |
| 2174 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { | 2149 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { |
| 2175 Condition cond = kNoCondition; | 2150 Condition cond = kNoCondition; |
| 2176 switch (op) { | 2151 switch (op) { |
| 2177 case Token::EQ: | 2152 case Token::EQ: |
| 2178 case Token::EQ_STRICT: | 2153 case Token::EQ_STRICT: |
| 2179 cond = eq; | 2154 cond = eq; |
| 2180 break; | 2155 break; |
| 2156 case Token::NE: |
| 2157 case Token::NE_STRICT: |
| 2158 cond = ne; |
| 2159 break; |
| 2181 case Token::LT: | 2160 case Token::LT: |
| 2182 cond = is_unsigned ? lo : lt; | 2161 cond = is_unsigned ? lo : lt; |
| 2183 break; | 2162 break; |
| 2184 case Token::GT: | 2163 case Token::GT: |
| 2185 cond = is_unsigned ? hi : gt; | 2164 cond = is_unsigned ? hi : gt; |
| 2186 break; | 2165 break; |
| 2187 case Token::LTE: | 2166 case Token::LTE: |
| 2188 cond = is_unsigned ? ls : le; | 2167 cond = is_unsigned ? ls : le; |
| 2189 break; | 2168 break; |
| 2190 case Token::GTE: | 2169 case Token::GTE: |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 __ Addu(scratch, elements, scratch); | 3342 __ Addu(scratch, elements, scratch); |
| 3364 __ lw(scratch, MemOperand(scratch)); | 3343 __ lw(scratch, MemOperand(scratch)); |
| 3365 __ push(scratch); | 3344 __ push(scratch); |
| 3366 __ Subu(length, length, Operand(1)); | 3345 __ Subu(length, length, Operand(1)); |
| 3367 __ Branch(USE_DELAY_SLOT, &loop, ne, length, Operand(zero_reg)); | 3346 __ Branch(USE_DELAY_SLOT, &loop, ne, length, Operand(zero_reg)); |
| 3368 __ sll(scratch, length, 2); | 3347 __ sll(scratch, length, 2); |
| 3369 | 3348 |
| 3370 __ bind(&invoke); | 3349 __ bind(&invoke); |
| 3371 ASSERT(instr->HasPointerMap()); | 3350 ASSERT(instr->HasPointerMap()); |
| 3372 LPointerMap* pointers = instr->pointer_map(); | 3351 LPointerMap* pointers = instr->pointer_map(); |
| 3373 RecordPosition(pointers->position()); | |
| 3374 SafepointGenerator safepoint_generator( | 3352 SafepointGenerator safepoint_generator( |
| 3375 this, pointers, Safepoint::kLazyDeopt); | 3353 this, pointers, Safepoint::kLazyDeopt); |
| 3376 // The number of arguments is stored in receiver which is a0, as expected | 3354 // The number of arguments is stored in receiver which is a0, as expected |
| 3377 // by InvokeFunction. | 3355 // by InvokeFunction. |
| 3378 ParameterCount actual(receiver); | 3356 ParameterCount actual(receiver); |
| 3379 __ InvokeFunction(function, actual, CALL_FUNCTION, | 3357 __ InvokeFunction(function, actual, CALL_FUNCTION, |
| 3380 safepoint_generator, CALL_AS_METHOD); | 3358 safepoint_generator, CALL_AS_METHOD); |
| 3381 } | 3359 } |
| 3382 | 3360 |
| 3383 | 3361 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3452 int arity, | 3430 int arity, |
| 3453 LInstruction* instr, | 3431 LInstruction* instr, |
| 3454 CallKind call_kind, | 3432 CallKind call_kind, |
| 3455 A1State a1_state) { | 3433 A1State a1_state) { |
| 3456 bool dont_adapt_arguments = | 3434 bool dont_adapt_arguments = |
| 3457 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3435 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
| 3458 bool can_invoke_directly = | 3436 bool can_invoke_directly = |
| 3459 dont_adapt_arguments || formal_parameter_count == arity; | 3437 dont_adapt_arguments || formal_parameter_count == arity; |
| 3460 | 3438 |
| 3461 LPointerMap* pointers = instr->pointer_map(); | 3439 LPointerMap* pointers = instr->pointer_map(); |
| 3462 RecordPosition(pointers->position()); | |
| 3463 | 3440 |
| 3464 if (can_invoke_directly) { | 3441 if (can_invoke_directly) { |
| 3465 if (a1_state == A1_UNINITIALIZED) { | 3442 if (a1_state == A1_UNINITIALIZED) { |
| 3466 __ LoadHeapObject(a1, function); | 3443 __ LoadHeapObject(a1, function); |
| 3467 } | 3444 } |
| 3468 | 3445 |
| 3469 // Change context. | 3446 // Change context. |
| 3470 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 3447 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 3471 | 3448 |
| 3472 // Set r0 to arguments count if adaption is not needed. Assumes that r0 | 3449 // 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... |
| 3910 | 3887 |
| 3911 | 3888 |
| 3912 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { | 3889 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
| 3913 ASSERT(ToRegister(instr->context()).is(cp)); | 3890 ASSERT(ToRegister(instr->context()).is(cp)); |
| 3914 ASSERT(ToRegister(instr->function()).is(a1)); | 3891 ASSERT(ToRegister(instr->function()).is(a1)); |
| 3915 ASSERT(instr->HasPointerMap()); | 3892 ASSERT(instr->HasPointerMap()); |
| 3916 | 3893 |
| 3917 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); | 3894 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); |
| 3918 if (known_function.is_null()) { | 3895 if (known_function.is_null()) { |
| 3919 LPointerMap* pointers = instr->pointer_map(); | 3896 LPointerMap* pointers = instr->pointer_map(); |
| 3920 RecordPosition(pointers->position()); | |
| 3921 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 3897 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3922 ParameterCount count(instr->arity()); | 3898 ParameterCount count(instr->arity()); |
| 3923 __ InvokeFunction(a1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); | 3899 __ InvokeFunction(a1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
| 3924 } else { | 3900 } else { |
| 3925 CallKnownFunction(known_function, | 3901 CallKnownFunction(known_function, |
| 3926 instr->hydrogen()->formal_parameter_count(), | 3902 instr->hydrogen()->formal_parameter_count(), |
| 3927 instr->arity(), | 3903 instr->arity(), |
| 3928 instr, | 3904 instr, |
| 3929 CALL_AS_METHOD, | 3905 CALL_AS_METHOD, |
| 3930 A1_CONTAINS_TARGET); | 3906 A1_CONTAINS_TARGET); |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4459 RecordSafepointWithRegistersAndDoubles( | 4435 RecordSafepointWithRegistersAndDoubles( |
| 4460 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); | 4436 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); |
| 4461 } | 4437 } |
| 4462 __ bind(¬_applicable); | 4438 __ bind(¬_applicable); |
| 4463 } | 4439 } |
| 4464 | 4440 |
| 4465 | 4441 |
| 4466 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { | 4442 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { |
| 4467 Register object = ToRegister(instr->object()); | 4443 Register object = ToRegister(instr->object()); |
| 4468 Register temp = ToRegister(instr->temp()); | 4444 Register temp = ToRegister(instr->temp()); |
| 4469 Label fail; | 4445 Label no_memento_found; |
| 4470 __ TestJSArrayForAllocationMemento(object, temp, ne, &fail); | 4446 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found, |
| 4447 ne, &no_memento_found); |
| 4471 DeoptimizeIf(al, instr->environment()); | 4448 DeoptimizeIf(al, instr->environment()); |
| 4472 __ bind(&fail); | 4449 __ bind(&no_memento_found); |
| 4473 } | 4450 } |
| 4474 | 4451 |
| 4475 | 4452 |
| 4476 void LCodeGen::DoStringAdd(LStringAdd* instr) { | 4453 void LCodeGen::DoStringAdd(LStringAdd* instr) { |
| 4477 ASSERT(ToRegister(instr->context()).is(cp)); | 4454 ASSERT(ToRegister(instr->context()).is(cp)); |
| 4478 __ push(ToRegister(instr->left())); | 4455 __ push(ToRegister(instr->left())); |
| 4479 __ push(ToRegister(instr->right())); | 4456 __ push(ToRegister(instr->right())); |
| 4480 StringAddStub stub(instr->hydrogen()->flags()); | 4457 StringAddStub stub(instr->hydrogen()->flags()); |
| 4481 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 4458 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 4482 } | 4459 } |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4888 // The input is a tagged HeapObject. | 4865 // The input is a tagged HeapObject. |
| 4889 // Heap number map check. | 4866 // Heap number map check. |
| 4890 __ lw(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 4867 __ lw(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); |
| 4891 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | 4868 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
| 4892 // This 'at' value and scratch1 map value are used for tests in both clauses | 4869 // This 'at' value and scratch1 map value are used for tests in both clauses |
| 4893 // of the if. | 4870 // of the if. |
| 4894 | 4871 |
| 4895 if (instr->truncating()) { | 4872 if (instr->truncating()) { |
| 4896 // Performs a truncating conversion of a floating point number as used by | 4873 // Performs a truncating conversion of a floating point number as used by |
| 4897 // the JS bitwise operations. | 4874 // the JS bitwise operations. |
| 4898 Label heap_number; | 4875 Label no_heap_number, check_bools, check_false; |
| 4899 __ Branch(&heap_number, eq, scratch1, Operand(at)); // HeapNumber map? | 4876 __ Branch(&no_heap_number, ne, scratch1, Operand(at)); // HeapNumber map? |
| 4900 // Check for undefined. Undefined is converted to zero for truncating | 4877 __ mov(scratch2, input_reg); |
| 4901 // conversions. | 4878 __ TruncateHeapNumberToI(input_reg, scratch2); |
| 4902 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | |
| 4903 DeoptimizeIf(ne, instr->environment(), input_reg, Operand(at)); | |
| 4904 ASSERT(ToRegister(instr->result()).is(input_reg)); | |
| 4905 __ mov(input_reg, zero_reg); | |
| 4906 __ Branch(&done); | 4879 __ Branch(&done); |
| 4907 | 4880 |
| 4908 __ bind(&heap_number); | 4881 // Check for Oddballs. Undefined/False is converted to zero and True to one |
| 4909 __ mov(scratch2, input_reg); | 4882 // for truncating conversions. |
| 4910 __ TruncateHeapNumberToI(input_reg, scratch2); | 4883 __ bind(&no_heap_number); |
| 4884 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
| 4885 __ Branch(&check_bools, ne, input_reg, Operand(at)); |
| 4886 ASSERT(ToRegister(instr->result()).is(input_reg)); |
| 4887 __ Branch(USE_DELAY_SLOT, &done); |
| 4888 __ mov(input_reg, zero_reg); // In delay slot. |
| 4889 |
| 4890 __ bind(&check_bools); |
| 4891 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
| 4892 __ Branch(&check_false, ne, scratch2, Operand(at)); |
| 4893 __ Branch(USE_DELAY_SLOT, &done); |
| 4894 __ li(input_reg, Operand(1)); // In delay slot. |
| 4895 |
| 4896 __ bind(&check_false); |
| 4897 __ LoadRoot(at, Heap::kFalseValueRootIndex); |
| 4898 DeoptimizeIf(ne, instr->environment(), scratch2, Operand(at)); |
| 4899 __ Branch(USE_DELAY_SLOT, &done); |
| 4900 __ mov(input_reg, zero_reg); // In delay slot. |
| 4911 } else { | 4901 } else { |
| 4912 // Deoptimize if we don't have a heap number. | 4902 // Deoptimize if we don't have a heap number. |
| 4913 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at)); | 4903 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at)); |
| 4914 | 4904 |
| 4915 // Load the double value. | 4905 // Load the double value. |
| 4916 __ ldc1(double_scratch, | 4906 __ ldc1(double_scratch, |
| 4917 FieldMemOperand(input_reg, HeapNumber::kValueOffset)); | 4907 FieldMemOperand(input_reg, HeapNumber::kValueOffset)); |
| 4918 | 4908 |
| 4919 Register except_flag = scratch2; | 4909 Register except_flag = scratch2; |
| 4920 __ EmitFPUTruncate(kRoundToZero, | 4910 __ EmitFPUTruncate(kRoundToZero, |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5812 __ Subu(scratch, result, scratch); | 5802 __ Subu(scratch, result, scratch); |
| 5813 __ lw(result, FieldMemOperand(scratch, | 5803 __ lw(result, FieldMemOperand(scratch, |
| 5814 FixedArray::kHeaderSize - kPointerSize)); | 5804 FixedArray::kHeaderSize - kPointerSize)); |
| 5815 __ bind(&done); | 5805 __ bind(&done); |
| 5816 } | 5806 } |
| 5817 | 5807 |
| 5818 | 5808 |
| 5819 #undef __ | 5809 #undef __ |
| 5820 | 5810 |
| 5821 } } // namespace v8::internal | 5811 } } // namespace v8::internal |
| OLD | NEW |