| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 codegen_->RecordSafepoint(pointers_, deoptimization_index_); | 47 codegen_->RecordSafepoint(pointers_, deoptimization_index_); |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 LCodeGen* codegen_; | 51 LCodeGen* codegen_; |
| 52 LPointerMap* pointers_; | 52 LPointerMap* pointers_; |
| 53 int deoptimization_index_; | 53 int deoptimization_index_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 | 56 |
| 57 class LGapNode: public ZoneObject { |
| 58 public: |
| 59 explicit LGapNode(LOperand* operand) |
| 60 : operand_(operand), resolved_(false), visited_id_(-1) { } |
| 61 |
| 62 LOperand* operand() const { return operand_; } |
| 63 bool IsResolved() const { return !IsAssigned() || resolved_; } |
| 64 void MarkResolved() { |
| 65 ASSERT(!IsResolved()); |
| 66 resolved_ = true; |
| 67 } |
| 68 int visited_id() const { return visited_id_; } |
| 69 void set_visited_id(int id) { |
| 70 ASSERT(id > visited_id_); |
| 71 visited_id_ = id; |
| 72 } |
| 73 |
| 74 bool IsAssigned() const { return assigned_from_.is_set(); } |
| 75 LGapNode* assigned_from() const { return assigned_from_.get(); } |
| 76 void set_assigned_from(LGapNode* n) { assigned_from_.set(n); } |
| 77 |
| 78 private: |
| 79 LOperand* operand_; |
| 80 SetOncePointer<LGapNode> assigned_from_; |
| 81 bool resolved_; |
| 82 int visited_id_; |
| 83 }; |
| 84 |
| 85 |
| 86 LGapResolver::LGapResolver() |
| 87 : nodes_(32), |
| 88 identified_cycles_(4), |
| 89 result_(16), |
| 90 next_visited_id_(0) { |
| 91 } |
| 92 |
| 93 |
| 94 const ZoneList<LMoveOperands>* LGapResolver::Resolve( |
| 95 const ZoneList<LMoveOperands>* moves, |
| 96 LOperand* marker_operand) { |
| 97 nodes_.Rewind(0); |
| 98 identified_cycles_.Rewind(0); |
| 99 result_.Rewind(0); |
| 100 next_visited_id_ = 0; |
| 101 |
| 102 for (int i = 0; i < moves->length(); ++i) { |
| 103 LMoveOperands move = moves->at(i); |
| 104 if (!move.IsRedundant()) RegisterMove(move); |
| 105 } |
| 106 |
| 107 for (int i = 0; i < identified_cycles_.length(); ++i) { |
| 108 ResolveCycle(identified_cycles_[i], marker_operand); |
| 109 } |
| 110 |
| 111 int unresolved_nodes; |
| 112 do { |
| 113 unresolved_nodes = 0; |
| 114 for (int j = 0; j < nodes_.length(); j++) { |
| 115 LGapNode* node = nodes_[j]; |
| 116 if (!node->IsResolved() && node->assigned_from()->IsResolved()) { |
| 117 AddResultMove(node->assigned_from(), node); |
| 118 node->MarkResolved(); |
| 119 } |
| 120 if (!node->IsResolved()) ++unresolved_nodes; |
| 121 } |
| 122 } while (unresolved_nodes > 0); |
| 123 return &result_; |
| 124 } |
| 125 |
| 126 |
| 127 void LGapResolver::AddResultMove(LGapNode* from, LGapNode* to) { |
| 128 AddResultMove(from->operand(), to->operand()); |
| 129 } |
| 130 |
| 131 |
| 132 void LGapResolver::AddResultMove(LOperand* from, LOperand* to) { |
| 133 result_.Add(LMoveOperands(from, to)); |
| 134 } |
| 135 |
| 136 |
| 137 void LGapResolver::ResolveCycle(LGapNode* start, LOperand* marker_operand) { |
| 138 ZoneList<LOperand*> cycle_operands(8); |
| 139 cycle_operands.Add(marker_operand); |
| 140 LGapNode* cur = start; |
| 141 do { |
| 142 cur->MarkResolved(); |
| 143 cycle_operands.Add(cur->operand()); |
| 144 cur = cur->assigned_from(); |
| 145 } while (cur != start); |
| 146 cycle_operands.Add(marker_operand); |
| 147 |
| 148 for (int i = cycle_operands.length() - 1; i > 0; --i) { |
| 149 LOperand* from = cycle_operands[i]; |
| 150 LOperand* to = cycle_operands[i - 1]; |
| 151 AddResultMove(from, to); |
| 152 } |
| 153 } |
| 154 |
| 155 |
| 156 bool LGapResolver::CanReach(LGapNode* a, LGapNode* b, int visited_id) { |
| 157 ASSERT(a != b); |
| 158 LGapNode* cur = a; |
| 159 while (cur != b && cur->visited_id() != visited_id && cur->IsAssigned()) { |
| 160 cur->set_visited_id(visited_id); |
| 161 cur = cur->assigned_from(); |
| 162 } |
| 163 |
| 164 return cur == b; |
| 165 } |
| 166 |
| 167 |
| 168 bool LGapResolver::CanReach(LGapNode* a, LGapNode* b) { |
| 169 ASSERT(a != b); |
| 170 return CanReach(a, b, next_visited_id_++); |
| 171 } |
| 172 |
| 173 |
| 174 void LGapResolver::RegisterMove(LMoveOperands move) { |
| 175 if (move.source()->IsConstantOperand()) { |
| 176 // Constant moves should be last in the machine code. Therefore add them |
| 177 // first to the result set. |
| 178 AddResultMove(move.source(), move.destination()); |
| 179 } else { |
| 180 LGapNode* from = LookupNode(move.source()); |
| 181 LGapNode* to = LookupNode(move.destination()); |
| 182 if (to->IsAssigned() && to->assigned_from() == from) { |
| 183 move.Eliminate(); |
| 184 return; |
| 185 } |
| 186 ASSERT(!to->IsAssigned()); |
| 187 if (CanReach(from, to)) { |
| 188 // This introduces a cycle. Save. |
| 189 identified_cycles_.Add(from); |
| 190 } |
| 191 to->set_assigned_from(from); |
| 192 } |
| 193 } |
| 194 |
| 195 |
| 196 LGapNode* LGapResolver::LookupNode(LOperand* operand) { |
| 197 for (int i = 0; i < nodes_.length(); ++i) { |
| 198 if (nodes_[i]->operand()->Equals(operand)) return nodes_[i]; |
| 199 } |
| 200 |
| 201 // No node found => create a new one. |
| 202 LGapNode* result = new LGapNode(operand); |
| 203 nodes_.Add(result); |
| 204 return result; |
| 205 } |
| 206 |
| 207 |
| 57 #define __ masm()-> | 208 #define __ masm()-> |
| 58 | 209 |
| 59 bool LCodeGen::GenerateCode() { | 210 bool LCodeGen::GenerateCode() { |
| 60 HPhase phase("Code generation", chunk()); | 211 HPhase phase("Code generation", chunk()); |
| 61 ASSERT(is_unused()); | 212 ASSERT(is_unused()); |
| 62 status_ = GENERATING; | 213 status_ = GENERATING; |
| 63 CpuFeatures::Scope scope1(VFP3); | 214 CpuFeatures::Scope scope1(VFP3); |
| 64 CpuFeatures::Scope scope2(ARMv7); | 215 CpuFeatures::Scope scope2(ARMv7); |
| 65 return GeneratePrologue() && | 216 return GeneratePrologue() && |
| 66 GenerateBody() && | 217 GenerateBody() && |
| 67 GenerateDeferredCode() && | 218 GenerateDeferredCode() && |
| 68 GenerateSafepointTable(); | 219 GenerateSafepointTable(); |
| 69 } | 220 } |
| 70 | 221 |
| 71 | 222 |
| 72 void LCodeGen::FinishCode(Handle<Code> code) { | 223 void LCodeGen::FinishCode(Handle<Code> code) { |
| 73 ASSERT(is_done()); | 224 ASSERT(is_done()); |
| 74 code->set_stack_slots(StackSlotCount()); | 225 code->set_stack_slots(StackSlotCount()); |
| 75 code->set_safepoint_table_start(safepoints_.GetCodeOffset()); | 226 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
| 76 PopulateDeoptimizationData(code); | 227 PopulateDeoptimizationData(code); |
| 77 } | 228 } |
| 78 | 229 |
| 79 | 230 |
| 80 void LCodeGen::Abort(const char* format, ...) { | 231 void LCodeGen::Abort(const char* format, ...) { |
| 81 if (FLAG_trace_bailout) { | 232 if (FLAG_trace_bailout) { |
| 82 SmartPointer<char> debug_name = graph()->debug_name()->ToCString(); | 233 SmartPointer<char> debug_name = graph()->debug_name()->ToCString(); |
| 83 PrintF("Aborting LCodeGen in @\"%s\": ", *debug_name); | 234 PrintF("Aborting LCodeGen in @\"%s\": ", *debug_name); |
| 84 va_list arguments; | 235 va_list arguments; |
| 85 va_start(arguments, format); | 236 va_start(arguments, format); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 334 |
| 184 bool LCodeGen::GenerateDeferredCode() { | 335 bool LCodeGen::GenerateDeferredCode() { |
| 185 ASSERT(is_generating()); | 336 ASSERT(is_generating()); |
| 186 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 337 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
| 187 LDeferredCode* code = deferred_[i]; | 338 LDeferredCode* code = deferred_[i]; |
| 188 __ bind(code->entry()); | 339 __ bind(code->entry()); |
| 189 code->Generate(); | 340 code->Generate(); |
| 190 __ jmp(code->exit()); | 341 __ jmp(code->exit()); |
| 191 } | 342 } |
| 192 | 343 |
| 344 // Force constant pool emission at the end of deferred code to make |
| 345 // sure that no constant pools are emitted after the official end of |
| 346 // the instruction sequence. |
| 347 masm()->CheckConstPool(true, false); |
| 348 |
| 193 // Deferred code is the last part of the instruction sequence. Mark | 349 // Deferred code is the last part of the instruction sequence. Mark |
| 194 // the generated code as done unless we bailed out. | 350 // the generated code as done unless we bailed out. |
| 195 if (!is_aborted()) status_ = DONE; | 351 if (!is_aborted()) status_ = DONE; |
| 196 return !is_aborted(); | 352 return !is_aborted(); |
| 197 } | 353 } |
| 198 | 354 |
| 199 | 355 |
| 200 bool LCodeGen::GenerateSafepointTable() { | 356 bool LCodeGen::GenerateSafepointTable() { |
| 201 ASSERT(is_done()); | 357 ASSERT(is_done()); |
| 202 safepoints_.Emit(masm(), StackSlotCount()); | 358 safepoints_.Emit(masm(), StackSlotCount()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // Local or spill slot. Skip the frame pointer, function, and | 473 // Local or spill slot. Skip the frame pointer, function, and |
| 318 // context in the fixed part of the frame. | 474 // context in the fixed part of the frame. |
| 319 return MemOperand(fp, -(index + 3) * kPointerSize); | 475 return MemOperand(fp, -(index + 3) * kPointerSize); |
| 320 } else { | 476 } else { |
| 321 // Incoming parameter. Skip the return address. | 477 // Incoming parameter. Skip the return address. |
| 322 return MemOperand(fp, -(index - 1) * kPointerSize); | 478 return MemOperand(fp, -(index - 1) * kPointerSize); |
| 323 } | 479 } |
| 324 } | 480 } |
| 325 | 481 |
| 326 | 482 |
| 483 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 484 Translation* translation) { |
| 485 if (environment == NULL) return; |
| 486 |
| 487 // The translation includes one command per value in the environment. |
| 488 int translation_size = environment->values()->length(); |
| 489 // The output frame height does not include the parameters. |
| 490 int height = translation_size - environment->parameter_count(); |
| 491 |
| 492 WriteTranslation(environment->outer(), translation); |
| 493 int closure_id = DefineDeoptimizationLiteral(environment->closure()); |
| 494 translation->BeginFrame(environment->ast_id(), closure_id, height); |
| 495 for (int i = 0; i < translation_size; ++i) { |
| 496 LOperand* value = environment->values()->at(i); |
| 497 // spilled_registers_ and spilled_double_registers_ are either |
| 498 // both NULL or both set. |
| 499 if (environment->spilled_registers() != NULL && value != NULL) { |
| 500 if (value->IsRegister() && |
| 501 environment->spilled_registers()[value->index()] != NULL) { |
| 502 translation->MarkDuplicate(); |
| 503 AddToTranslation(translation, |
| 504 environment->spilled_registers()[value->index()], |
| 505 environment->HasTaggedValueAt(i)); |
| 506 } else if ( |
| 507 value->IsDoubleRegister() && |
| 508 environment->spilled_double_registers()[value->index()] != NULL) { |
| 509 translation->MarkDuplicate(); |
| 510 AddToTranslation( |
| 511 translation, |
| 512 environment->spilled_double_registers()[value->index()], |
| 513 false); |
| 514 } |
| 515 } |
| 516 |
| 517 AddToTranslation(translation, value, environment->HasTaggedValueAt(i)); |
| 518 } |
| 519 } |
| 520 |
| 521 |
| 327 void LCodeGen::AddToTranslation(Translation* translation, | 522 void LCodeGen::AddToTranslation(Translation* translation, |
| 328 LOperand* op, | 523 LOperand* op, |
| 329 bool is_tagged) { | 524 bool is_tagged) { |
| 330 if (op == NULL) { | 525 if (op == NULL) { |
| 331 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 526 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 332 // is not present and must be reconstructed from the deoptimizer. Currently | 527 // is not present and must be reconstructed from the deoptimizer. Currently |
| 333 // this is only used for the arguments object. | 528 // this is only used for the arguments object. |
| 334 translation->StoreArgumentsObject(); | 529 translation->StoreArgumentsObject(); |
| 335 } else if (op->IsStackSlot()) { | 530 } else if (op->IsStackSlot()) { |
| 336 if (is_tagged) { | 531 if (is_tagged) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 360 translation->StoreLiteral(src_index); | 555 translation->StoreLiteral(src_index); |
| 361 } else { | 556 } else { |
| 362 UNREACHABLE(); | 557 UNREACHABLE(); |
| 363 } | 558 } |
| 364 } | 559 } |
| 365 | 560 |
| 366 | 561 |
| 367 void LCodeGen::CallCode(Handle<Code> code, | 562 void LCodeGen::CallCode(Handle<Code> code, |
| 368 RelocInfo::Mode mode, | 563 RelocInfo::Mode mode, |
| 369 LInstruction* instr) { | 564 LInstruction* instr) { |
| 370 if (instr != NULL) { | 565 ASSERT(instr != NULL); |
| 371 LPointerMap* pointers = instr->pointer_map(); | 566 LPointerMap* pointers = instr->pointer_map(); |
| 372 RecordPosition(pointers->position()); | 567 RecordPosition(pointers->position()); |
| 373 __ Call(code, mode); | 568 __ Call(code, mode); |
| 374 RegisterLazyDeoptimization(instr); | 569 RegisterLazyDeoptimization(instr); |
| 375 } else { | |
| 376 LPointerMap no_pointers(0); | |
| 377 RecordPosition(no_pointers.position()); | |
| 378 __ Call(code, mode); | |
| 379 RecordSafepoint(&no_pointers, Safepoint::kNoDeoptimizationIndex); | |
| 380 } | |
| 381 } | 570 } |
| 382 | 571 |
| 383 | 572 |
| 384 void LCodeGen::CallRuntime(Runtime::Function* function, | 573 void LCodeGen::CallRuntime(Runtime::Function* function, |
| 385 int num_arguments, | 574 int num_arguments, |
| 386 LInstruction* instr) { | 575 LInstruction* instr) { |
| 387 ASSERT(instr != NULL); | 576 ASSERT(instr != NULL); |
| 388 LPointerMap* pointers = instr->pointer_map(); | 577 LPointerMap* pointers = instr->pointer_map(); |
| 389 ASSERT(pointers != NULL); | 578 ASSERT(pointers != NULL); |
| 390 RecordPosition(pointers->position()); | 579 RecordPosition(pointers->position()); |
| 391 | 580 |
| 392 __ CallRuntime(function, num_arguments); | 581 __ CallRuntime(function, num_arguments); |
| 393 // Runtime calls to Throw are not supposed to ever return at the | 582 RegisterLazyDeoptimization(instr); |
| 394 // call site, so don't register lazy deoptimization for these. We do | |
| 395 // however have to record a safepoint since throwing exceptions can | |
| 396 // cause garbage collections. | |
| 397 if (!instr->IsThrow()) { | |
| 398 RegisterLazyDeoptimization(instr); | |
| 399 } else { | |
| 400 RecordSafepoint(instr->pointer_map(), Safepoint::kNoDeoptimizationIndex); | |
| 401 } | |
| 402 } | 583 } |
| 403 | 584 |
| 404 | 585 |
| 405 void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { | 586 void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { |
| 406 // Create the environment to bailout to. If the call has side effects | 587 // Create the environment to bailout to. If the call has side effects |
| 407 // execution has to continue after the call otherwise execution can continue | 588 // execution has to continue after the call otherwise execution can continue |
| 408 // from a previous bailout point repeating the call. | 589 // from a previous bailout point repeating the call. |
| 409 LEnvironment* deoptimization_environment; | 590 LEnvironment* deoptimization_environment; |
| 410 if (instr->HasDeoptimizationEnvironment()) { | 591 if (instr->HasDeoptimizationEnvironment()) { |
| 411 deoptimization_environment = instr->deoptimization_environment(); | 592 deoptimization_environment = instr->deoptimization_environment(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 432 // Layout of the translation: | 613 // Layout of the translation: |
| 433 // 0 ........................................................ size - 1 + 4 | 614 // 0 ........................................................ size - 1 + 4 |
| 434 // [expression stack including arguments] [locals] [4 words] [parameters] | 615 // [expression stack including arguments] [locals] [4 words] [parameters] |
| 435 // |>------------ translation_size ------------<| | 616 // |>------------ translation_size ------------<| |
| 436 | 617 |
| 437 int frame_count = 0; | 618 int frame_count = 0; |
| 438 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 619 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
| 439 ++frame_count; | 620 ++frame_count; |
| 440 } | 621 } |
| 441 Translation translation(&translations_, frame_count); | 622 Translation translation(&translations_, frame_count); |
| 442 environment->WriteTranslation(this, &translation); | 623 WriteTranslation(environment, &translation); |
| 443 int deoptimization_index = deoptimizations_.length(); | 624 int deoptimization_index = deoptimizations_.length(); |
| 444 environment->Register(deoptimization_index, translation.index()); | 625 environment->Register(deoptimization_index, translation.index()); |
| 445 deoptimizations_.Add(environment); | 626 deoptimizations_.Add(environment); |
| 446 } | 627 } |
| 447 } | 628 } |
| 448 | 629 |
| 449 | 630 |
| 450 void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { | 631 void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { |
| 451 RegisterEnvironmentForDeoptimization(environment); | 632 RegisterEnvironmentForDeoptimization(environment); |
| 452 ASSERT(environment->HasBeenRegistered()); | 633 ASSERT(environment->HasBeenRegistered()); |
| 453 int id = environment->deoptimization_index(); | 634 int id = environment->deoptimization_index(); |
| 454 Address entry = Deoptimizer::GetDeoptimizationEntry(id, Deoptimizer::EAGER); | 635 Address entry = Deoptimizer::GetDeoptimizationEntry(id, Deoptimizer::EAGER); |
| 455 ASSERT(entry != NULL); | 636 ASSERT(entry != NULL); |
| 456 if (entry == NULL) { | 637 if (entry == NULL) { |
| 457 Abort("bailout was not prepared"); | 638 Abort("bailout was not prepared"); |
| 458 return; | 639 return; |
| 459 } | 640 } |
| 460 | 641 |
| 461 ASSERT(FLAG_deopt_every_n_times < 2); // Other values not supported on ARM. | 642 ASSERT(FLAG_deopt_every_n_times < 2); // Other values not supported on ARM. |
| 462 | 643 |
| 463 if (FLAG_deopt_every_n_times == 1 && | 644 if (FLAG_deopt_every_n_times == 1 && |
| 464 info_->shared_info()->opt_count() == id) { | 645 info_->shared_info()->opt_count() == id) { |
| 465 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 646 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
| 466 return; | 647 return; |
| 467 } | 648 } |
| 468 | 649 |
| 469 if (cc == no_condition) { | 650 if (cc == al) { |
| 470 if (FLAG_trap_on_deopt) __ stop("trap_on_deopt"); | 651 if (FLAG_trap_on_deopt) __ stop("trap_on_deopt"); |
| 471 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 652 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
| 472 } else { | 653 } else { |
| 473 if (FLAG_trap_on_deopt) { | 654 if (FLAG_trap_on_deopt) { |
| 474 Label done; | 655 Label done; |
| 475 __ b(&done, NegateCondition(cc)); | 656 __ b(&done, NegateCondition(cc)); |
| 476 __ stop("trap_on_deopt"); | 657 __ stop("trap_on_deopt"); |
| 477 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 658 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
| 478 __ bind(&done); | 659 __ bind(&done); |
| 479 } else { | 660 } else { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 for (int i = 0, length = inlined_closures->length(); | 715 for (int i = 0, length = inlined_closures->length(); |
| 535 i < length; | 716 i < length; |
| 536 i++) { | 717 i++) { |
| 537 DefineDeoptimizationLiteral(inlined_closures->at(i)); | 718 DefineDeoptimizationLiteral(inlined_closures->at(i)); |
| 538 } | 719 } |
| 539 | 720 |
| 540 inlined_function_count_ = deoptimization_literals_.length(); | 721 inlined_function_count_ = deoptimization_literals_.length(); |
| 541 } | 722 } |
| 542 | 723 |
| 543 | 724 |
| 725 void LCodeGen::RecordSafepoint( |
| 726 LPointerMap* pointers, |
| 727 Safepoint::Kind kind, |
| 728 int arguments, |
| 729 int deoptimization_index) { |
| 730 const ZoneList<LOperand*>* operands = pointers->operands(); |
| 731 Safepoint safepoint = safepoints_.DefineSafepoint(masm(), |
| 732 kind, arguments, deoptimization_index); |
| 733 for (int i = 0; i < operands->length(); i++) { |
| 734 LOperand* pointer = operands->at(i); |
| 735 if (pointer->IsStackSlot()) { |
| 736 safepoint.DefinePointerSlot(pointer->index()); |
| 737 } else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) { |
| 738 safepoint.DefinePointerRegister(ToRegister(pointer)); |
| 739 } |
| 740 } |
| 741 if (kind & Safepoint::kWithRegisters) { |
| 742 // Register cp always contains a pointer to the context. |
| 743 safepoint.DefinePointerRegister(cp); |
| 744 } |
| 745 } |
| 746 |
| 747 |
| 544 void LCodeGen::RecordSafepoint(LPointerMap* pointers, | 748 void LCodeGen::RecordSafepoint(LPointerMap* pointers, |
| 545 int deoptimization_index) { | 749 int deoptimization_index) { |
| 546 const ZoneList<LOperand*>* operands = pointers->operands(); | 750 RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index); |
| 547 Safepoint safepoint = safepoints_.DefineSafepoint(masm(), | |
| 548 deoptimization_index); | |
| 549 for (int i = 0; i < operands->length(); i++) { | |
| 550 LOperand* pointer = operands->at(i); | |
| 551 if (pointer->IsStackSlot()) { | |
| 552 safepoint.DefinePointerSlot(pointer->index()); | |
| 553 } | |
| 554 } | |
| 555 } | 751 } |
| 556 | 752 |
| 557 | 753 |
| 558 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, | 754 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, |
| 559 int arguments, | 755 int arguments, |
| 560 int deoptimization_index) { | 756 int deoptimization_index) { |
| 561 const ZoneList<LOperand*>* operands = pointers->operands(); | 757 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, |
| 562 Safepoint safepoint = | 758 deoptimization_index); |
| 563 safepoints_.DefineSafepointWithRegisters( | 759 } |
| 564 masm(), arguments, deoptimization_index); | 760 |
| 565 for (int i = 0; i < operands->length(); i++) { | 761 |
| 566 LOperand* pointer = operands->at(i); | 762 void LCodeGen::RecordSafepointWithRegistersAndDoubles( |
| 567 if (pointer->IsStackSlot()) { | 763 LPointerMap* pointers, |
| 568 safepoint.DefinePointerSlot(pointer->index()); | 764 int arguments, |
| 569 } else if (pointer->IsRegister()) { | 765 int deoptimization_index) { |
| 570 safepoint.DefinePointerRegister(ToRegister(pointer)); | 766 RecordSafepoint(pointers, Safepoint::kWithRegistersAndDoubles, arguments, |
| 571 } | 767 deoptimization_index); |
| 572 } | |
| 573 // Register cp always contains a pointer to the context. | |
| 574 safepoint.DefinePointerRegister(cp); | |
| 575 } | 768 } |
| 576 | 769 |
| 577 | 770 |
| 578 void LCodeGen::RecordPosition(int position) { | 771 void LCodeGen::RecordPosition(int position) { |
| 579 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; | 772 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; |
| 580 masm()->positions_recorder()->RecordPosition(position); | 773 masm()->positions_recorder()->RecordPosition(position); |
| 581 } | 774 } |
| 582 | 775 |
| 583 | 776 |
| 584 void LCodeGen::DoLabel(LLabel* label) { | 777 void LCodeGen::DoLabel(LLabel* label) { |
| 585 if (label->is_loop_header()) { | 778 if (label->is_loop_header()) { |
| 586 Comment(";;; B%d - LOOP entry", label->block_id()); | 779 Comment(";;; B%d - LOOP entry", label->block_id()); |
| 587 } else { | 780 } else { |
| 588 Comment(";;; B%d", label->block_id()); | 781 Comment(";;; B%d", label->block_id()); |
| 589 } | 782 } |
| 590 __ bind(label->label()); | 783 __ bind(label->label()); |
| 591 current_block_ = label->block_id(); | 784 current_block_ = label->block_id(); |
| 592 LCodeGen::DoGap(label); | 785 LCodeGen::DoGap(label); |
| 593 } | 786 } |
| 594 | 787 |
| 595 | 788 |
| 596 void LCodeGen::DoParallelMove(LParallelMove* move) { | 789 void LCodeGen::DoParallelMove(LParallelMove* move) { |
| 597 // d0 must always be a scratch register. | 790 // d0 must always be a scratch register. |
| 598 DoubleRegister dbl_scratch = d0; | 791 DoubleRegister dbl_scratch = d0; |
| 599 LUnallocated marker_operand(LUnallocated::NONE); | 792 LUnallocated marker_operand(LUnallocated::NONE); |
| 600 | 793 |
| 601 Register core_scratch = scratch0(); | 794 Register core_scratch = scratch0(); |
| 602 bool destroys_core_scratch = false; | 795 bool destroys_core_scratch = false; |
| 603 | 796 |
| 604 LGapResolver resolver(move->move_operands(), &marker_operand); | 797 const ZoneList<LMoveOperands>* moves = |
| 605 const ZoneList<LMoveOperands>* moves = resolver.ResolveInReverseOrder(); | 798 resolver_.Resolve(move->move_operands(), &marker_operand); |
| 606 for (int i = moves->length() - 1; i >= 0; --i) { | 799 for (int i = moves->length() - 1; i >= 0; --i) { |
| 607 LMoveOperands move = moves->at(i); | 800 LMoveOperands move = moves->at(i); |
| 608 LOperand* from = move.from(); | 801 LOperand* from = move.source(); |
| 609 LOperand* to = move.to(); | 802 LOperand* to = move.destination(); |
| 610 ASSERT(!from->IsDoubleRegister() || | 803 ASSERT(!from->IsDoubleRegister() || |
| 611 !ToDoubleRegister(from).is(dbl_scratch)); | 804 !ToDoubleRegister(from).is(dbl_scratch)); |
| 612 ASSERT(!to->IsDoubleRegister() || !ToDoubleRegister(to).is(dbl_scratch)); | 805 ASSERT(!to->IsDoubleRegister() || !ToDoubleRegister(to).is(dbl_scratch)); |
| 613 ASSERT(!from->IsRegister() || !ToRegister(from).is(core_scratch)); | 806 ASSERT(!from->IsRegister() || !ToRegister(from).is(core_scratch)); |
| 614 ASSERT(!to->IsRegister() || !ToRegister(to).is(core_scratch)); | 807 ASSERT(!to->IsRegister() || !ToRegister(to).is(core_scratch)); |
| 615 if (from == &marker_operand) { | 808 if (from == &marker_operand) { |
| 616 if (to->IsRegister()) { | 809 if (to->IsRegister()) { |
| 617 __ mov(ToRegister(to), core_scratch); | 810 __ mov(ToRegister(to), core_scratch); |
| 618 ASSERT(destroys_core_scratch); | 811 ASSERT(destroys_core_scratch); |
| 619 } else if (to->IsStackSlot()) { | 812 } else if (to->IsStackSlot()) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 RegExpExecStub stub; | 934 RegExpExecStub stub; |
| 742 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 935 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 743 break; | 936 break; |
| 744 } | 937 } |
| 745 case CodeStub::SubString: { | 938 case CodeStub::SubString: { |
| 746 SubStringStub stub; | 939 SubStringStub stub; |
| 747 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 940 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 748 break; | 941 break; |
| 749 } | 942 } |
| 750 case CodeStub::StringCharAt: { | 943 case CodeStub::StringCharAt: { |
| 751 Abort("StringCharAtStub unimplemented."); | 944 StringCharAtStub stub; |
| 945 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 752 break; | 946 break; |
| 753 } | 947 } |
| 754 case CodeStub::MathPow: { | 948 case CodeStub::MathPow: { |
| 755 Abort("MathPowStub unimplemented."); | 949 Abort("MathPowStub unimplemented."); |
| 756 break; | 950 break; |
| 757 } | 951 } |
| 758 case CodeStub::NumberToString: { | 952 case CodeStub::NumberToString: { |
| 759 NumberToStringStub stub; | 953 NumberToStringStub stub; |
| 760 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 954 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 761 break; | 955 break; |
| 762 } | 956 } |
| 763 case CodeStub::StringAdd: { | 957 case CodeStub::StringAdd: { |
| 764 StringAddStub stub(NO_STRING_ADD_FLAGS); | 958 StringAddStub stub(NO_STRING_ADD_FLAGS); |
| 765 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 959 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 766 break; | 960 break; |
| 767 } | 961 } |
| 768 case CodeStub::StringCompare: { | 962 case CodeStub::StringCompare: { |
| 769 StringCompareStub stub; | 963 StringCompareStub stub; |
| 770 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 964 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 771 break; | 965 break; |
| 772 } | 966 } |
| 773 case CodeStub::TranscendentalCache: { | 967 case CodeStub::TranscendentalCache: { |
| 774 Abort("TranscendentalCache unimplemented."); | 968 __ ldr(r0, MemOperand(sp, 0)); |
| 969 TranscendentalCacheStub stub(instr->transcendental_type()); |
| 970 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 775 break; | 971 break; |
| 776 } | 972 } |
| 777 default: | 973 default: |
| 778 UNREACHABLE(); | 974 UNREACHABLE(); |
| 779 } | 975 } |
| 780 } | 976 } |
| 781 | 977 |
| 782 | 978 |
| 783 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 979 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
| 784 // Nothing to do. | 980 // Nothing to do. |
| 785 } | 981 } |
| 786 | 982 |
| 787 | 983 |
| 788 void LCodeGen::DoModI(LModI* instr) { | 984 void LCodeGen::DoModI(LModI* instr) { |
| 789 Abort("DoModI unimplemented."); | 985 class DeferredModI: public LDeferredCode { |
| 986 public: |
| 987 DeferredModI(LCodeGen* codegen, LModI* instr) |
| 988 : LDeferredCode(codegen), instr_(instr) { } |
| 989 virtual void Generate() { |
| 990 codegen()->DoDeferredGenericBinaryStub(instr_, Token::MOD); |
| 991 } |
| 992 private: |
| 993 LModI* instr_; |
| 994 }; |
| 995 // These registers hold untagged 32 bit values. |
| 996 Register left = ToRegister(instr->InputAt(0)); |
| 997 Register right = ToRegister(instr->InputAt(1)); |
| 998 Register result = ToRegister(instr->result()); |
| 999 Register scratch = scratch0(); |
| 1000 |
| 1001 Label deoptimize, done; |
| 1002 // Check for x % 0. |
| 1003 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
| 1004 __ tst(right, Operand(right)); |
| 1005 __ b(eq, &deoptimize); |
| 1006 } |
| 1007 |
| 1008 // Check for (0 % -x) that will produce negative zero. |
| 1009 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1010 Label ok; |
| 1011 __ tst(left, Operand(left)); |
| 1012 __ b(ne, &ok); |
| 1013 __ tst(right, Operand(right)); |
| 1014 __ b(pl, &ok); |
| 1015 __ b(al, &deoptimize); |
| 1016 __ bind(&ok); |
| 1017 } |
| 1018 |
| 1019 // Try a few common cases before using the generic stub. |
| 1020 Label call_stub; |
| 1021 const int kUnfolds = 3; |
| 1022 // Skip if either side is negative. |
| 1023 __ cmp(left, Operand(0)); |
| 1024 __ cmp(right, Operand(0), NegateCondition(mi)); |
| 1025 __ b(mi, &call_stub); |
| 1026 // If the right hand side is smaller than the (nonnegative) |
| 1027 // left hand side, it is the result. Else try a few subtractions |
| 1028 // of the left hand side. |
| 1029 __ mov(scratch, left); |
| 1030 for (int i = 0; i < kUnfolds; i++) { |
| 1031 // Check if the left hand side is less or equal than the |
| 1032 // the right hand side. |
| 1033 __ cmp(scratch, right); |
| 1034 __ mov(result, scratch, LeaveCC, lt); |
| 1035 __ b(lt, &done); |
| 1036 // If not, reduce the left hand side by the right hand |
| 1037 // side and check again. |
| 1038 if (i < kUnfolds - 1) __ sub(scratch, scratch, right); |
| 1039 } |
| 1040 |
| 1041 // Check for power of two on the right hand side. |
| 1042 __ JumpIfNotPowerOfTwoOrZero(right, scratch, &call_stub); |
| 1043 // Perform modulo operation (scratch contains right - 1). |
| 1044 __ and_(result, scratch, Operand(left)); |
| 1045 |
| 1046 __ bind(&call_stub); |
| 1047 // Call the generic stub. The numbers in r0 and r1 have |
| 1048 // to be tagged to Smis. If that is not possible, deoptimize. |
| 1049 DeferredModI* deferred = new DeferredModI(this, instr); |
| 1050 __ TrySmiTag(left, &deoptimize, scratch); |
| 1051 __ TrySmiTag(right, &deoptimize, scratch); |
| 1052 |
| 1053 __ b(al, deferred->entry()); |
| 1054 __ bind(deferred->exit()); |
| 1055 |
| 1056 // If the result in r0 is a Smi, untag it, else deoptimize. |
| 1057 __ JumpIfNotSmi(result, &deoptimize); |
| 1058 __ SmiUntag(result); |
| 1059 |
| 1060 __ b(al, &done); |
| 1061 __ bind(&deoptimize); |
| 1062 DeoptimizeIf(al, instr->environment()); |
| 1063 __ bind(&done); |
| 790 } | 1064 } |
| 791 | 1065 |
| 792 | 1066 |
| 793 void LCodeGen::DoDivI(LDivI* instr) { | 1067 void LCodeGen::DoDivI(LDivI* instr) { |
| 794 Abort("DoDivI unimplemented."); | 1068 class DeferredDivI: public LDeferredCode { |
| 1069 public: |
| 1070 DeferredDivI(LCodeGen* codegen, LDivI* instr) |
| 1071 : LDeferredCode(codegen), instr_(instr) { } |
| 1072 virtual void Generate() { |
| 1073 codegen()->DoDeferredGenericBinaryStub(instr_, Token::DIV); |
| 1074 } |
| 1075 private: |
| 1076 LDivI* instr_; |
| 1077 }; |
| 1078 |
| 1079 const Register left = ToRegister(instr->InputAt(0)); |
| 1080 const Register right = ToRegister(instr->InputAt(1)); |
| 1081 const Register scratch = scratch0(); |
| 1082 const Register result = ToRegister(instr->result()); |
| 1083 |
| 1084 // Check for x / 0. |
| 1085 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
| 1086 __ tst(right, right); |
| 1087 DeoptimizeIf(eq, instr->environment()); |
| 1088 } |
| 1089 |
| 1090 // Check for (0 / -x) that will produce negative zero. |
| 1091 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1092 Label left_not_zero; |
| 1093 __ tst(left, Operand(left)); |
| 1094 __ b(ne, &left_not_zero); |
| 1095 __ tst(right, Operand(right)); |
| 1096 DeoptimizeIf(mi, instr->environment()); |
| 1097 __ bind(&left_not_zero); |
| 1098 } |
| 1099 |
| 1100 // Check for (-kMinInt / -1). |
| 1101 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
| 1102 Label left_not_min_int; |
| 1103 __ cmp(left, Operand(kMinInt)); |
| 1104 __ b(ne, &left_not_min_int); |
| 1105 __ cmp(right, Operand(-1)); |
| 1106 DeoptimizeIf(eq, instr->environment()); |
| 1107 __ bind(&left_not_min_int); |
| 1108 } |
| 1109 |
| 1110 Label done, deoptimize; |
| 1111 // Test for a few common cases first. |
| 1112 __ cmp(right, Operand(1)); |
| 1113 __ mov(result, left, LeaveCC, eq); |
| 1114 __ b(eq, &done); |
| 1115 |
| 1116 __ cmp(right, Operand(2)); |
| 1117 __ tst(left, Operand(1), eq); |
| 1118 __ mov(result, Operand(left, ASR, 1), LeaveCC, eq); |
| 1119 __ b(eq, &done); |
| 1120 |
| 1121 __ cmp(right, Operand(4)); |
| 1122 __ tst(left, Operand(3), eq); |
| 1123 __ mov(result, Operand(left, ASR, 2), LeaveCC, eq); |
| 1124 __ b(eq, &done); |
| 1125 |
| 1126 // Call the generic stub. The numbers in r0 and r1 have |
| 1127 // to be tagged to Smis. If that is not possible, deoptimize. |
| 1128 DeferredDivI* deferred = new DeferredDivI(this, instr); |
| 1129 |
| 1130 __ TrySmiTag(left, &deoptimize, scratch); |
| 1131 __ TrySmiTag(right, &deoptimize, scratch); |
| 1132 |
| 1133 __ b(al, deferred->entry()); |
| 1134 __ bind(deferred->exit()); |
| 1135 |
| 1136 // If the result in r0 is a Smi, untag it, else deoptimize. |
| 1137 __ JumpIfNotSmi(result, &deoptimize); |
| 1138 __ SmiUntag(result); |
| 1139 __ b(&done); |
| 1140 |
| 1141 __ bind(&deoptimize); |
| 1142 DeoptimizeIf(al, instr->environment()); |
| 1143 __ bind(&done); |
| 1144 } |
| 1145 |
| 1146 |
| 1147 template<int T> |
| 1148 void LCodeGen::DoDeferredGenericBinaryStub(LTemplateInstruction<1, 2, T>* instr, |
| 1149 Token::Value op) { |
| 1150 Register left = ToRegister(instr->InputAt(0)); |
| 1151 Register right = ToRegister(instr->InputAt(1)); |
| 1152 |
| 1153 __ PushSafepointRegistersAndDoubles(); |
| 1154 GenericBinaryOpStub stub(op, OVERWRITE_LEFT, left, right); |
| 1155 __ CallStub(&stub); |
| 1156 RecordSafepointWithRegistersAndDoubles(instr->pointer_map(), |
| 1157 0, |
| 1158 Safepoint::kNoDeoptimizationIndex); |
| 1159 // Overwrite the stored value of r0 with the result of the stub. |
| 1160 __ StoreToSafepointRegistersAndDoublesSlot(r0); |
| 1161 __ PopSafepointRegistersAndDoubles(); |
| 795 } | 1162 } |
| 796 | 1163 |
| 797 | 1164 |
| 798 void LCodeGen::DoMulI(LMulI* instr) { | 1165 void LCodeGen::DoMulI(LMulI* instr) { |
| 799 Register scratch = scratch0(); | 1166 Register scratch = scratch0(); |
| 800 Register left = ToRegister(instr->left()); | 1167 Register left = ToRegister(instr->InputAt(0)); |
| 801 Register right = EmitLoadRegister(instr->right(), scratch); | 1168 Register right = EmitLoadRegister(instr->InputAt(1), scratch); |
| 802 | 1169 |
| 803 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && | 1170 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && |
| 804 !instr->right()->IsConstantOperand()) { | 1171 !instr->InputAt(1)->IsConstantOperand()) { |
| 805 __ orr(ToRegister(instr->temp()), left, right); | 1172 __ orr(ToRegister(instr->TempAt(0)), left, right); |
| 806 } | 1173 } |
| 807 | 1174 |
| 808 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 1175 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
| 809 // scratch:left = left * right. | 1176 // scratch:left = left * right. |
| 810 __ smull(scratch, left, left, right); | 1177 __ smull(left, scratch, left, right); |
| 811 __ mov(ip, Operand(left, ASR, 31)); | 1178 __ mov(ip, Operand(left, ASR, 31)); |
| 812 __ cmp(ip, Operand(scratch)); | 1179 __ cmp(ip, Operand(scratch)); |
| 813 DeoptimizeIf(ne, instr->environment()); | 1180 DeoptimizeIf(ne, instr->environment()); |
| 814 } else { | 1181 } else { |
| 815 __ mul(left, left, right); | 1182 __ mul(left, left, right); |
| 816 } | 1183 } |
| 817 | 1184 |
| 818 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1185 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 819 // Bail out if the result is supposed to be negative zero. | 1186 // Bail out if the result is supposed to be negative zero. |
| 820 Label done; | 1187 Label done; |
| 821 __ tst(left, Operand(left)); | 1188 __ tst(left, Operand(left)); |
| 822 __ b(ne, &done); | 1189 __ b(ne, &done); |
| 823 if (instr->right()->IsConstantOperand()) { | 1190 if (instr->InputAt(1)->IsConstantOperand()) { |
| 824 if (ToInteger32(LConstantOperand::cast(instr->right())) < 0) { | 1191 if (ToInteger32(LConstantOperand::cast(instr->InputAt(1))) <= 0) { |
| 825 DeoptimizeIf(no_condition, instr->environment()); | 1192 DeoptimizeIf(al, instr->environment()); |
| 826 } | 1193 } |
| 827 } else { | 1194 } else { |
| 828 // Test the non-zero operand for negative sign. | 1195 // Test the non-zero operand for negative sign. |
| 829 __ cmp(ToRegister(instr->temp()), Operand(0)); | 1196 __ cmp(ToRegister(instr->TempAt(0)), Operand(0)); |
| 830 DeoptimizeIf(mi, instr->environment()); | 1197 DeoptimizeIf(mi, instr->environment()); |
| 831 } | 1198 } |
| 832 __ bind(&done); | 1199 __ bind(&done); |
| 833 } | 1200 } |
| 834 } | 1201 } |
| 835 | 1202 |
| 836 | 1203 |
| 837 void LCodeGen::DoBitI(LBitI* instr) { | 1204 void LCodeGen::DoBitI(LBitI* instr) { |
| 838 LOperand* left = instr->left(); | 1205 LOperand* left = instr->InputAt(0); |
| 839 LOperand* right = instr->right(); | 1206 LOperand* right = instr->InputAt(1); |
| 840 ASSERT(left->Equals(instr->result())); | 1207 ASSERT(left->Equals(instr->result())); |
| 841 ASSERT(left->IsRegister()); | 1208 ASSERT(left->IsRegister()); |
| 842 Register result = ToRegister(left); | 1209 Register result = ToRegister(left); |
| 843 Register right_reg = EmitLoadRegister(right, ip); | 1210 Register right_reg = EmitLoadRegister(right, ip); |
| 844 switch (instr->op()) { | 1211 switch (instr->op()) { |
| 845 case Token::BIT_AND: | 1212 case Token::BIT_AND: |
| 846 __ and_(result, ToRegister(left), Operand(right_reg)); | 1213 __ and_(result, ToRegister(left), Operand(right_reg)); |
| 847 break; | 1214 break; |
| 848 case Token::BIT_OR: | 1215 case Token::BIT_OR: |
| 849 __ orr(result, ToRegister(left), Operand(right_reg)); | 1216 __ orr(result, ToRegister(left), Operand(right_reg)); |
| 850 break; | 1217 break; |
| 851 case Token::BIT_XOR: | 1218 case Token::BIT_XOR: |
| 852 __ eor(result, ToRegister(left), Operand(right_reg)); | 1219 __ eor(result, ToRegister(left), Operand(right_reg)); |
| 853 break; | 1220 break; |
| 854 default: | 1221 default: |
| 855 UNREACHABLE(); | 1222 UNREACHABLE(); |
| 856 break; | 1223 break; |
| 857 } | 1224 } |
| 858 } | 1225 } |
| 859 | 1226 |
| 860 | 1227 |
| 861 void LCodeGen::DoShiftI(LShiftI* instr) { | 1228 void LCodeGen::DoShiftI(LShiftI* instr) { |
| 862 Register scratch = scratch0(); | 1229 Register scratch = scratch0(); |
| 863 LOperand* left = instr->left(); | 1230 LOperand* left = instr->InputAt(0); |
| 864 LOperand* right = instr->right(); | 1231 LOperand* right = instr->InputAt(1); |
| 865 ASSERT(left->Equals(instr->result())); | 1232 ASSERT(left->Equals(instr->result())); |
| 866 ASSERT(left->IsRegister()); | 1233 ASSERT(left->IsRegister()); |
| 867 Register result = ToRegister(left); | 1234 Register result = ToRegister(left); |
| 868 if (right->IsRegister()) { | 1235 if (right->IsRegister()) { |
| 869 // Mask the right operand. | 1236 // Mask the right operand. |
| 870 __ and_(scratch, ToRegister(right), Operand(0x1F)); | 1237 __ and_(scratch, ToRegister(right), Operand(0x1F)); |
| 871 switch (instr->op()) { | 1238 switch (instr->op()) { |
| 872 case Token::SAR: | 1239 case Token::SAR: |
| 873 __ mov(result, Operand(result, ASR, scratch)); | 1240 __ mov(result, Operand(result, ASR, scratch)); |
| 874 break; | 1241 break; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 break; | 1278 break; |
| 912 default: | 1279 default: |
| 913 UNREACHABLE(); | 1280 UNREACHABLE(); |
| 914 break; | 1281 break; |
| 915 } | 1282 } |
| 916 } | 1283 } |
| 917 } | 1284 } |
| 918 | 1285 |
| 919 | 1286 |
| 920 void LCodeGen::DoSubI(LSubI* instr) { | 1287 void LCodeGen::DoSubI(LSubI* instr) { |
| 921 Register left = ToRegister(instr->left()); | 1288 Register left = ToRegister(instr->InputAt(0)); |
| 922 Register right = EmitLoadRegister(instr->right(), ip); | 1289 Register right = EmitLoadRegister(instr->InputAt(1), ip); |
| 923 ASSERT(instr->left()->Equals(instr->result())); | 1290 ASSERT(instr->InputAt(0)->Equals(instr->result())); |
| 924 __ sub(left, left, right, SetCC); | 1291 __ sub(left, left, right, SetCC); |
| 925 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 1292 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
| 926 DeoptimizeIf(vs, instr->environment()); | 1293 DeoptimizeIf(vs, instr->environment()); |
| 927 } | 1294 } |
| 928 } | 1295 } |
| 929 | 1296 |
| 930 | 1297 |
| 931 void LCodeGen::DoConstantI(LConstantI* instr) { | 1298 void LCodeGen::DoConstantI(LConstantI* instr) { |
| 932 ASSERT(instr->result()->IsRegister()); | 1299 ASSERT(instr->result()->IsRegister()); |
| 933 __ mov(ToRegister(instr->result()), Operand(instr->value())); | 1300 __ mov(ToRegister(instr->result()), Operand(instr->value())); |
| 934 } | 1301 } |
| 935 | 1302 |
| 936 | 1303 |
| 937 void LCodeGen::DoConstantD(LConstantD* instr) { | 1304 void LCodeGen::DoConstantD(LConstantD* instr) { |
| 938 Abort("DoConstantD unimplemented."); | 1305 ASSERT(instr->result()->IsDoubleRegister()); |
| 1306 DwVfpRegister result = ToDoubleRegister(instr->result()); |
| 1307 double v = instr->value(); |
| 1308 __ vmov(result, v); |
| 939 } | 1309 } |
| 940 | 1310 |
| 941 | 1311 |
| 942 void LCodeGen::DoConstantT(LConstantT* instr) { | 1312 void LCodeGen::DoConstantT(LConstantT* instr) { |
| 943 ASSERT(instr->result()->IsRegister()); | 1313 ASSERT(instr->result()->IsRegister()); |
| 944 __ mov(ToRegister(instr->result()), Operand(instr->value())); | 1314 __ mov(ToRegister(instr->result()), Operand(instr->value())); |
| 945 } | 1315 } |
| 946 | 1316 |
| 947 | 1317 |
| 948 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { | 1318 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { |
| 949 Register result = ToRegister(instr->result()); | 1319 Register result = ToRegister(instr->result()); |
| 950 Register array = ToRegister(instr->input()); | 1320 Register array = ToRegister(instr->InputAt(0)); |
| 951 __ ldr(result, FieldMemOperand(array, JSArray::kLengthOffset)); | 1321 __ ldr(result, FieldMemOperand(array, JSArray::kLengthOffset)); |
| 952 } | 1322 } |
| 953 | 1323 |
| 954 | 1324 |
| 1325 void LCodeGen::DoPixelArrayLength(LPixelArrayLength* instr) { |
| 1326 Register result = ToRegister(instr->result()); |
| 1327 Register array = ToRegister(instr->InputAt(0)); |
| 1328 __ ldr(result, FieldMemOperand(array, PixelArray::kLengthOffset)); |
| 1329 } |
| 1330 |
| 1331 |
| 955 void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) { | 1332 void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) { |
| 956 Register result = ToRegister(instr->result()); | 1333 Register result = ToRegister(instr->result()); |
| 957 Register array = ToRegister(instr->input()); | 1334 Register array = ToRegister(instr->InputAt(0)); |
| 958 __ ldr(result, FieldMemOperand(array, FixedArray::kLengthOffset)); | 1335 __ ldr(result, FieldMemOperand(array, FixedArray::kLengthOffset)); |
| 959 Abort("DoFixedArrayLength untested."); | |
| 960 } | 1336 } |
| 961 | 1337 |
| 962 | 1338 |
| 963 void LCodeGen::DoValueOf(LValueOf* instr) { | 1339 void LCodeGen::DoValueOf(LValueOf* instr) { |
| 964 Abort("DoValueOf unimplemented."); | 1340 Register input = ToRegister(instr->InputAt(0)); |
| 1341 Register result = ToRegister(instr->result()); |
| 1342 Register map = ToRegister(instr->TempAt(0)); |
| 1343 ASSERT(input.is(result)); |
| 1344 Label done; |
| 1345 |
| 1346 // If the object is a smi return the object. |
| 1347 __ tst(input, Operand(kSmiTagMask)); |
| 1348 __ b(eq, &done); |
| 1349 |
| 1350 // If the object is not a value type, return the object. |
| 1351 __ CompareObjectType(input, map, map, JS_VALUE_TYPE); |
| 1352 __ b(ne, &done); |
| 1353 __ ldr(result, FieldMemOperand(input, JSValue::kValueOffset)); |
| 1354 |
| 1355 __ bind(&done); |
| 965 } | 1356 } |
| 966 | 1357 |
| 967 | 1358 |
| 968 void LCodeGen::DoBitNotI(LBitNotI* instr) { | 1359 void LCodeGen::DoBitNotI(LBitNotI* instr) { |
| 969 LOperand* input = instr->input(); | 1360 LOperand* input = instr->InputAt(0); |
| 970 ASSERT(input->Equals(instr->result())); | 1361 ASSERT(input->Equals(instr->result())); |
| 971 __ mvn(ToRegister(input), Operand(ToRegister(input))); | 1362 __ mvn(ToRegister(input), Operand(ToRegister(input))); |
| 972 Abort("DoBitNotI untested."); | |
| 973 } | 1363 } |
| 974 | 1364 |
| 975 | 1365 |
| 976 void LCodeGen::DoThrow(LThrow* instr) { | 1366 void LCodeGen::DoThrow(LThrow* instr) { |
| 977 Register input_reg = EmitLoadRegister(instr->input(), ip); | 1367 Register input_reg = EmitLoadRegister(instr->InputAt(0), ip); |
| 978 __ push(input_reg); | 1368 __ push(input_reg); |
| 979 CallRuntime(Runtime::kThrow, 1, instr); | 1369 CallRuntime(Runtime::kThrow, 1, instr); |
| 980 | 1370 |
| 981 if (FLAG_debug_code) { | 1371 if (FLAG_debug_code) { |
| 982 __ stop("Unreachable code."); | 1372 __ stop("Unreachable code."); |
| 983 } | 1373 } |
| 984 } | 1374 } |
| 985 | 1375 |
| 986 | 1376 |
| 987 void LCodeGen::DoAddI(LAddI* instr) { | 1377 void LCodeGen::DoAddI(LAddI* instr) { |
| 988 LOperand* left = instr->left(); | 1378 LOperand* left = instr->InputAt(0); |
| 989 LOperand* right = instr->right(); | 1379 LOperand* right = instr->InputAt(1); |
| 990 ASSERT(left->Equals(instr->result())); | 1380 ASSERT(left->Equals(instr->result())); |
| 991 | 1381 |
| 992 Register right_reg = EmitLoadRegister(right, ip); | 1382 Register right_reg = EmitLoadRegister(right, ip); |
| 993 __ add(ToRegister(left), ToRegister(left), Operand(right_reg), SetCC); | 1383 __ add(ToRegister(left), ToRegister(left), Operand(right_reg), SetCC); |
| 994 | 1384 |
| 995 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 1385 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
| 996 DeoptimizeIf(vs, instr->environment()); | 1386 DeoptimizeIf(vs, instr->environment()); |
| 997 } | 1387 } |
| 998 } | 1388 } |
| 999 | 1389 |
| 1000 | 1390 |
| 1001 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { | 1391 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { |
| 1002 DoubleRegister left = ToDoubleRegister(instr->left()); | 1392 DoubleRegister left = ToDoubleRegister(instr->InputAt(0)); |
| 1003 DoubleRegister right = ToDoubleRegister(instr->right()); | 1393 DoubleRegister right = ToDoubleRegister(instr->InputAt(1)); |
| 1004 switch (instr->op()) { | 1394 switch (instr->op()) { |
| 1005 case Token::ADD: | 1395 case Token::ADD: |
| 1006 __ vadd(left, left, right); | 1396 __ vadd(left, left, right); |
| 1007 break; | 1397 break; |
| 1008 case Token::SUB: | 1398 case Token::SUB: |
| 1009 __ vsub(left, left, right); | 1399 __ vsub(left, left, right); |
| 1010 break; | 1400 break; |
| 1011 case Token::MUL: | 1401 case Token::MUL: |
| 1012 __ vmul(left, left, right); | 1402 __ vmul(left, left, right); |
| 1013 break; | 1403 break; |
| 1014 case Token::DIV: | 1404 case Token::DIV: |
| 1015 __ vdiv(left, left, right); | 1405 __ vdiv(left, left, right); |
| 1016 break; | 1406 break; |
| 1017 case Token::MOD: { | 1407 case Token::MOD: { |
| 1018 Abort("DoArithmeticD unimplemented for MOD."); | 1408 // Save r0-r3 on the stack. |
| 1409 __ stm(db_w, sp, r0.bit() | r1.bit() | r2.bit() | r3.bit()); |
| 1410 |
| 1411 __ PrepareCallCFunction(4, scratch0()); |
| 1412 __ vmov(r0, r1, left); |
| 1413 __ vmov(r2, r3, right); |
| 1414 __ CallCFunction(ExternalReference::double_fp_operation(Token::MOD), 4); |
| 1415 // Move the result in the double result register. |
| 1416 __ vmov(ToDoubleRegister(instr->result()), r0, r1); |
| 1417 |
| 1418 // Restore r0-r3. |
| 1419 __ ldm(ia_w, sp, r0.bit() | r1.bit() | r2.bit() | r3.bit()); |
| 1019 break; | 1420 break; |
| 1020 } | 1421 } |
| 1021 default: | 1422 default: |
| 1022 UNREACHABLE(); | 1423 UNREACHABLE(); |
| 1023 break; | 1424 break; |
| 1024 } | 1425 } |
| 1025 } | 1426 } |
| 1026 | 1427 |
| 1027 | 1428 |
| 1028 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { | 1429 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { |
| 1029 ASSERT(ToRegister(instr->left()).is(r1)); | 1430 ASSERT(ToRegister(instr->InputAt(0)).is(r1)); |
| 1030 ASSERT(ToRegister(instr->right()).is(r0)); | 1431 ASSERT(ToRegister(instr->InputAt(1)).is(r0)); |
| 1031 ASSERT(ToRegister(instr->result()).is(r0)); | 1432 ASSERT(ToRegister(instr->result()).is(r0)); |
| 1032 | 1433 |
| 1033 // TODO(regis): Implement TypeRecordingBinaryOpStub and replace current | 1434 // TODO(regis): Implement TypeRecordingBinaryOpStub and replace current |
| 1034 // GenericBinaryOpStub: | 1435 // GenericBinaryOpStub: |
| 1035 // TypeRecordingBinaryOpStub stub(instr->op(), NO_OVERWRITE); | 1436 // TypeRecordingBinaryOpStub stub(instr->op(), NO_OVERWRITE); |
| 1036 GenericBinaryOpStub stub(instr->op(), NO_OVERWRITE, r1, r0); | 1437 GenericBinaryOpStub stub(instr->op(), NO_OVERWRITE, r1, r0); |
| 1037 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 1438 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1038 } | 1439 } |
| 1039 | 1440 |
| 1040 | 1441 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1064 } | 1465 } |
| 1065 } | 1466 } |
| 1066 | 1467 |
| 1067 | 1468 |
| 1068 void LCodeGen::DoBranch(LBranch* instr) { | 1469 void LCodeGen::DoBranch(LBranch* instr) { |
| 1069 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1470 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1070 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1471 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1071 | 1472 |
| 1072 Representation r = instr->hydrogen()->representation(); | 1473 Representation r = instr->hydrogen()->representation(); |
| 1073 if (r.IsInteger32()) { | 1474 if (r.IsInteger32()) { |
| 1074 Register reg = ToRegister(instr->input()); | 1475 Register reg = ToRegister(instr->InputAt(0)); |
| 1075 __ cmp(reg, Operand(0)); | 1476 __ cmp(reg, Operand(0)); |
| 1076 EmitBranch(true_block, false_block, nz); | 1477 EmitBranch(true_block, false_block, ne); |
| 1077 } else if (r.IsDouble()) { | 1478 } else if (r.IsDouble()) { |
| 1078 DoubleRegister reg = ToDoubleRegister(instr->input()); | 1479 DoubleRegister reg = ToDoubleRegister(instr->InputAt(0)); |
| 1079 __ vcmp(reg, 0.0); | 1480 Register scratch = scratch0(); |
| 1481 |
| 1482 // Test the double value. Zero and NaN are false. |
| 1483 __ VFPCompareAndLoadFlags(reg, 0.0, scratch); |
| 1484 __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPVConditionFlagBit)); |
| 1080 EmitBranch(true_block, false_block, ne); | 1485 EmitBranch(true_block, false_block, ne); |
| 1081 } else { | 1486 } else { |
| 1082 ASSERT(r.IsTagged()); | 1487 ASSERT(r.IsTagged()); |
| 1083 Register reg = ToRegister(instr->input()); | 1488 Register reg = ToRegister(instr->InputAt(0)); |
| 1084 if (instr->hydrogen()->type().IsBoolean()) { | 1489 if (instr->hydrogen()->type().IsBoolean()) { |
| 1085 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 1490 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 1086 __ cmp(reg, ip); | 1491 __ cmp(reg, ip); |
| 1087 EmitBranch(true_block, false_block, eq); | 1492 EmitBranch(true_block, false_block, eq); |
| 1088 } else { | 1493 } else { |
| 1089 Label* true_label = chunk_->GetAssemblyLabel(true_block); | 1494 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
| 1090 Label* false_label = chunk_->GetAssemblyLabel(false_block); | 1495 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 1091 | 1496 |
| 1092 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 1497 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 1093 __ cmp(reg, ip); | 1498 __ cmp(reg, ip); |
| 1094 __ b(eq, false_label); | 1499 __ b(eq, false_label); |
| 1095 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 1500 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 1096 __ cmp(reg, ip); | 1501 __ cmp(reg, ip); |
| 1097 __ b(eq, true_label); | 1502 __ b(eq, true_label); |
| 1098 __ LoadRoot(ip, Heap::kFalseValueRootIndex); | 1503 __ LoadRoot(ip, Heap::kFalseValueRootIndex); |
| 1099 __ cmp(reg, ip); | 1504 __ cmp(reg, ip); |
| 1100 __ b(eq, false_label); | 1505 __ b(eq, false_label); |
| 1101 __ cmp(reg, Operand(0)); | 1506 __ cmp(reg, Operand(0)); |
| 1102 __ b(eq, false_label); | 1507 __ b(eq, false_label); |
| 1103 __ tst(reg, Operand(kSmiTagMask)); | 1508 __ tst(reg, Operand(kSmiTagMask)); |
| 1104 __ b(eq, true_label); | 1509 __ b(eq, true_label); |
| 1105 | 1510 |
| 1106 // Test for double values. Zero is false. | 1511 // Test double values. Zero and NaN are false. |
| 1107 Label call_stub; | 1512 Label call_stub; |
| 1108 DoubleRegister dbl_scratch = d0; | 1513 DoubleRegister dbl_scratch = d0; |
| 1109 Register scratch = scratch0(); | 1514 Register scratch = scratch0(); |
| 1110 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); | 1515 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 1111 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 1516 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 1112 __ cmp(scratch, Operand(ip)); | 1517 __ cmp(scratch, Operand(ip)); |
| 1113 __ b(ne, &call_stub); | 1518 __ b(ne, &call_stub); |
| 1114 __ sub(ip, reg, Operand(kHeapObjectTag)); | 1519 __ sub(ip, reg, Operand(kHeapObjectTag)); |
| 1115 __ vldr(dbl_scratch, ip, HeapNumber::kValueOffset); | 1520 __ vldr(dbl_scratch, ip, HeapNumber::kValueOffset); |
| 1116 __ vcmp(dbl_scratch, 0.0); | 1521 __ VFPCompareAndLoadFlags(dbl_scratch, 0.0, scratch); |
| 1117 __ b(eq, false_label); | 1522 __ tst(scratch, Operand(kVFPZConditionFlagBit | kVFPVConditionFlagBit)); |
| 1523 __ b(ne, false_label); |
| 1118 __ b(true_label); | 1524 __ b(true_label); |
| 1119 | 1525 |
| 1120 // The conversion stub doesn't cause garbage collections so it's | 1526 // The conversion stub doesn't cause garbage collections so it's |
| 1121 // safe to not record a safepoint after the call. | 1527 // safe to not record a safepoint after the call. |
| 1122 __ bind(&call_stub); | 1528 __ bind(&call_stub); |
| 1123 ToBooleanStub stub(reg); | 1529 ToBooleanStub stub(reg); |
| 1124 RegList saved_regs = kJSCallerSaved | kCalleeSaved; | 1530 RegList saved_regs = kJSCallerSaved | kCalleeSaved; |
| 1125 __ stm(db_w, sp, saved_regs); | 1531 __ stm(db_w, sp, saved_regs); |
| 1126 __ CallStub(&stub); | 1532 __ CallStub(&stub); |
| 1127 __ cmp(reg, Operand(0)); | 1533 __ cmp(reg, Operand(0)); |
| 1128 __ ldm(ia_w, sp, saved_regs); | 1534 __ ldm(ia_w, sp, saved_regs); |
| 1129 EmitBranch(true_block, false_block, nz); | 1535 EmitBranch(true_block, false_block, ne); |
| 1130 } | 1536 } |
| 1131 } | 1537 } |
| 1132 } | 1538 } |
| 1133 | 1539 |
| 1134 | 1540 |
| 1135 void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { | 1541 void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { |
| 1136 // TODO(srdjan): Perform stack overflow check if this goto needs it | |
| 1137 // before jumping. | |
| 1138 block = chunk_->LookupDestination(block); | 1542 block = chunk_->LookupDestination(block); |
| 1139 int next_block = GetNextEmittedBlock(current_block_); | 1543 int next_block = GetNextEmittedBlock(current_block_); |
| 1140 if (block != next_block) { | 1544 if (block != next_block) { |
| 1141 __ jmp(chunk_->GetAssemblyLabel(block)); | 1545 // Perform stack overflow check if this goto needs it before jumping. |
| 1546 if (deferred_stack_check != NULL) { |
| 1547 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 1548 __ cmp(sp, Operand(ip)); |
| 1549 __ b(hs, chunk_->GetAssemblyLabel(block)); |
| 1550 __ jmp(deferred_stack_check->entry()); |
| 1551 deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block)); |
| 1552 } else { |
| 1553 __ jmp(chunk_->GetAssemblyLabel(block)); |
| 1554 } |
| 1142 } | 1555 } |
| 1143 } | 1556 } |
| 1144 | 1557 |
| 1145 | 1558 |
| 1146 void LCodeGen::DoDeferredStackCheck(LGoto* instr) { | 1559 void LCodeGen::DoDeferredStackCheck(LGoto* instr) { |
| 1147 UNIMPLEMENTED(); | 1560 __ PushSafepointRegisters(); |
| 1561 __ CallRuntimeSaveDoubles(Runtime::kStackGuard); |
| 1562 RecordSafepointWithRegisters( |
| 1563 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
| 1564 __ PopSafepointRegisters(); |
| 1148 } | 1565 } |
| 1149 | 1566 |
| 1150 | 1567 |
| 1151 void LCodeGen::DoGoto(LGoto* instr) { | 1568 void LCodeGen::DoGoto(LGoto* instr) { |
| 1152 // TODO(srdjan): Implement deferred stack check. | 1569 class DeferredStackCheck: public LDeferredCode { |
| 1153 EmitGoto(instr->block_id(), NULL); | 1570 public: |
| 1571 DeferredStackCheck(LCodeGen* codegen, LGoto* instr) |
| 1572 : LDeferredCode(codegen), instr_(instr) { } |
| 1573 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
| 1574 private: |
| 1575 LGoto* instr_; |
| 1576 }; |
| 1577 |
| 1578 DeferredStackCheck* deferred = NULL; |
| 1579 if (instr->include_stack_check()) { |
| 1580 deferred = new DeferredStackCheck(this, instr); |
| 1581 } |
| 1582 EmitGoto(instr->block_id(), deferred); |
| 1154 } | 1583 } |
| 1155 | 1584 |
| 1156 | 1585 |
| 1157 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { | 1586 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { |
| 1158 Condition cond = no_condition; | 1587 Condition cond = kNoCondition; |
| 1159 switch (op) { | 1588 switch (op) { |
| 1160 case Token::EQ: | 1589 case Token::EQ: |
| 1161 case Token::EQ_STRICT: | 1590 case Token::EQ_STRICT: |
| 1162 cond = eq; | 1591 cond = eq; |
| 1163 break; | 1592 break; |
| 1164 case Token::LT: | 1593 case Token::LT: |
| 1165 cond = is_unsigned ? lo : lt; | 1594 cond = is_unsigned ? lo : lt; |
| 1166 break; | 1595 break; |
| 1167 case Token::GT: | 1596 case Token::GT: |
| 1168 cond = is_unsigned ? hi : gt; | 1597 cond = is_unsigned ? hi : gt; |
| 1169 break; | 1598 break; |
| 1170 case Token::LTE: | 1599 case Token::LTE: |
| 1171 cond = is_unsigned ? ls : le; | 1600 cond = is_unsigned ? ls : le; |
| 1172 break; | 1601 break; |
| 1173 case Token::GTE: | 1602 case Token::GTE: |
| 1174 cond = is_unsigned ? hs : ge; | 1603 cond = is_unsigned ? hs : ge; |
| 1175 break; | 1604 break; |
| 1176 case Token::IN: | 1605 case Token::IN: |
| 1177 case Token::INSTANCEOF: | 1606 case Token::INSTANCEOF: |
| 1178 default: | 1607 default: |
| 1179 UNREACHABLE(); | 1608 UNREACHABLE(); |
| 1180 } | 1609 } |
| 1181 return cond; | 1610 return cond; |
| 1182 } | 1611 } |
| 1183 | 1612 |
| 1184 | 1613 |
| 1185 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { | 1614 void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) { |
| 1186 __ cmp(ToRegister(left), ToOperand(right)); | 1615 __ cmp(ToRegister(left), ToRegister(right)); |
| 1187 Abort("EmitCmpI untested."); | |
| 1188 } | 1616 } |
| 1189 | 1617 |
| 1190 | 1618 |
| 1191 void LCodeGen::DoCmpID(LCmpID* instr) { | 1619 void LCodeGen::DoCmpID(LCmpID* instr) { |
| 1192 Abort("DoCmpID unimplemented."); | 1620 LOperand* left = instr->InputAt(0); |
| 1621 LOperand* right = instr->InputAt(1); |
| 1622 LOperand* result = instr->result(); |
| 1623 Register scratch = scratch0(); |
| 1624 |
| 1625 Label unordered, done; |
| 1626 if (instr->is_double()) { |
| 1627 // Compare left and right as doubles and load the |
| 1628 // resulting flags into the normal status register. |
| 1629 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); |
| 1630 // If a NaN is involved, i.e. the result is unordered (V set), |
| 1631 // jump to unordered to return false. |
| 1632 __ b(vs, &unordered); |
| 1633 } else { |
| 1634 EmitCmpI(left, right); |
| 1635 } |
| 1636 |
| 1637 Condition cc = TokenToCondition(instr->op(), instr->is_double()); |
| 1638 __ LoadRoot(ToRegister(result), Heap::kTrueValueRootIndex); |
| 1639 __ b(cc, &done); |
| 1640 |
| 1641 __ bind(&unordered); |
| 1642 __ LoadRoot(ToRegister(result), Heap::kFalseValueRootIndex); |
| 1643 __ bind(&done); |
| 1193 } | 1644 } |
| 1194 | 1645 |
| 1195 | 1646 |
| 1196 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { | 1647 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { |
| 1197 Abort("DoCmpIDAndBranch unimplemented."); | 1648 LOperand* left = instr->InputAt(0); |
| 1649 LOperand* right = instr->InputAt(1); |
| 1650 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1651 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1652 |
| 1653 if (instr->is_double()) { |
| 1654 // Compare left and right as doubles and load the |
| 1655 // resulting flags into the normal status register. |
| 1656 __ VFPCompareAndSetFlags(ToDoubleRegister(left), ToDoubleRegister(right)); |
| 1657 // If a NaN is involved, i.e. the result is unordered (V set), |
| 1658 // jump to false block label. |
| 1659 __ b(vs, chunk_->GetAssemblyLabel(false_block)); |
| 1660 } else { |
| 1661 EmitCmpI(left, right); |
| 1662 } |
| 1663 |
| 1664 Condition cc = TokenToCondition(instr->op(), instr->is_double()); |
| 1665 EmitBranch(true_block, false_block, cc); |
| 1198 } | 1666 } |
| 1199 | 1667 |
| 1200 | 1668 |
| 1201 void LCodeGen::DoCmpJSObjectEq(LCmpJSObjectEq* instr) { | 1669 void LCodeGen::DoCmpJSObjectEq(LCmpJSObjectEq* instr) { |
| 1202 Register left = ToRegister(instr->left()); | 1670 Register left = ToRegister(instr->InputAt(0)); |
| 1203 Register right = ToRegister(instr->right()); | 1671 Register right = ToRegister(instr->InputAt(1)); |
| 1204 Register result = ToRegister(instr->result()); | 1672 Register result = ToRegister(instr->result()); |
| 1205 | 1673 |
| 1206 __ cmp(left, Operand(right)); | 1674 __ cmp(left, Operand(right)); |
| 1207 __ LoadRoot(result, Heap::kTrueValueRootIndex, eq); | 1675 __ LoadRoot(result, Heap::kTrueValueRootIndex, eq); |
| 1208 __ LoadRoot(result, Heap::kFalseValueRootIndex, ne); | 1676 __ LoadRoot(result, Heap::kFalseValueRootIndex, ne); |
| 1209 Abort("DoCmpJSObjectEq untested."); | |
| 1210 } | 1677 } |
| 1211 | 1678 |
| 1212 | 1679 |
| 1213 void LCodeGen::DoCmpJSObjectEqAndBranch(LCmpJSObjectEqAndBranch* instr) { | 1680 void LCodeGen::DoCmpJSObjectEqAndBranch(LCmpJSObjectEqAndBranch* instr) { |
| 1214 Abort("DoCmpJSObjectEqAndBranch unimplemented."); | 1681 Register left = ToRegister(instr->InputAt(0)); |
| 1682 Register right = ToRegister(instr->InputAt(1)); |
| 1683 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1684 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1685 |
| 1686 __ cmp(left, Operand(right)); |
| 1687 EmitBranch(true_block, false_block, eq); |
| 1215 } | 1688 } |
| 1216 | 1689 |
| 1217 | 1690 |
| 1218 void LCodeGen::DoIsNull(LIsNull* instr) { | 1691 void LCodeGen::DoIsNull(LIsNull* instr) { |
| 1219 Register reg = ToRegister(instr->input()); | 1692 Register reg = ToRegister(instr->InputAt(0)); |
| 1220 Register result = ToRegister(instr->result()); | 1693 Register result = ToRegister(instr->result()); |
| 1221 | 1694 |
| 1222 __ LoadRoot(ip, Heap::kNullValueRootIndex); | 1695 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
| 1223 __ cmp(reg, ip); | 1696 __ cmp(reg, ip); |
| 1224 if (instr->is_strict()) { | 1697 if (instr->is_strict()) { |
| 1225 __ LoadRoot(result, Heap::kTrueValueRootIndex, eq); | 1698 __ LoadRoot(result, Heap::kTrueValueRootIndex, eq); |
| 1226 __ LoadRoot(result, Heap::kFalseValueRootIndex, ne); | 1699 __ LoadRoot(result, Heap::kFalseValueRootIndex, ne); |
| 1227 } else { | 1700 } else { |
| 1228 Label true_value, false_value, done; | 1701 Label true_value, false_value, done; |
| 1229 __ b(eq, &true_value); | 1702 __ b(eq, &true_value); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1244 __ jmp(&done); | 1717 __ jmp(&done); |
| 1245 __ bind(&true_value); | 1718 __ bind(&true_value); |
| 1246 __ LoadRoot(result, Heap::kTrueValueRootIndex); | 1719 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 1247 __ bind(&done); | 1720 __ bind(&done); |
| 1248 } | 1721 } |
| 1249 } | 1722 } |
| 1250 | 1723 |
| 1251 | 1724 |
| 1252 void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) { | 1725 void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) { |
| 1253 Register scratch = scratch0(); | 1726 Register scratch = scratch0(); |
| 1254 Register reg = ToRegister(instr->input()); | 1727 Register reg = ToRegister(instr->InputAt(0)); |
| 1255 | 1728 |
| 1256 // TODO(fsc): If the expression is known to be a smi, then it's | 1729 // TODO(fsc): If the expression is known to be a smi, then it's |
| 1257 // definitely not null. Jump to the false block. | 1730 // definitely not null. Jump to the false block. |
| 1258 | 1731 |
| 1259 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1732 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1260 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1733 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1261 | 1734 |
| 1262 __ LoadRoot(ip, Heap::kNullValueRootIndex); | 1735 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
| 1263 __ cmp(reg, ip); | 1736 __ cmp(reg, ip); |
| 1264 if (instr->is_strict()) { | 1737 if (instr->is_strict()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1280 EmitBranch(true_block, false_block, ne); | 1753 EmitBranch(true_block, false_block, ne); |
| 1281 } | 1754 } |
| 1282 } | 1755 } |
| 1283 | 1756 |
| 1284 | 1757 |
| 1285 Condition LCodeGen::EmitIsObject(Register input, | 1758 Condition LCodeGen::EmitIsObject(Register input, |
| 1286 Register temp1, | 1759 Register temp1, |
| 1287 Register temp2, | 1760 Register temp2, |
| 1288 Label* is_not_object, | 1761 Label* is_not_object, |
| 1289 Label* is_object) { | 1762 Label* is_object) { |
| 1290 Abort("EmitIsObject unimplemented."); | 1763 __ JumpIfSmi(input, is_not_object); |
| 1291 return ne; | 1764 |
| 1765 __ LoadRoot(temp1, Heap::kNullValueRootIndex); |
| 1766 __ cmp(input, temp1); |
| 1767 __ b(eq, is_object); |
| 1768 |
| 1769 // Load map. |
| 1770 __ ldr(temp1, FieldMemOperand(input, HeapObject::kMapOffset)); |
| 1771 // Undetectable objects behave like undefined. |
| 1772 __ ldrb(temp2, FieldMemOperand(temp1, Map::kBitFieldOffset)); |
| 1773 __ tst(temp2, Operand(1 << Map::kIsUndetectable)); |
| 1774 __ b(ne, is_not_object); |
| 1775 |
| 1776 // Load instance type and check that it is in object type range. |
| 1777 __ ldrb(temp2, FieldMemOperand(temp1, Map::kInstanceTypeOffset)); |
| 1778 __ cmp(temp2, Operand(FIRST_JS_OBJECT_TYPE)); |
| 1779 __ b(lt, is_not_object); |
| 1780 __ cmp(temp2, Operand(LAST_JS_OBJECT_TYPE)); |
| 1781 return le; |
| 1292 } | 1782 } |
| 1293 | 1783 |
| 1294 | 1784 |
| 1295 void LCodeGen::DoIsObject(LIsObject* instr) { | 1785 void LCodeGen::DoIsObject(LIsObject* instr) { |
| 1296 Abort("DoIsObject unimplemented."); | 1786 Register reg = ToRegister(instr->InputAt(0)); |
| 1787 Register result = ToRegister(instr->result()); |
| 1788 Register temp = scratch0(); |
| 1789 Label is_false, is_true, done; |
| 1790 |
| 1791 Condition true_cond = EmitIsObject(reg, result, temp, &is_false, &is_true); |
| 1792 __ b(true_cond, &is_true); |
| 1793 |
| 1794 __ bind(&is_false); |
| 1795 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 1796 __ b(&done); |
| 1797 |
| 1798 __ bind(&is_true); |
| 1799 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 1800 |
| 1801 __ bind(&done); |
| 1297 } | 1802 } |
| 1298 | 1803 |
| 1299 | 1804 |
| 1300 void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) { | 1805 void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) { |
| 1301 Abort("DoIsObjectAndBranch unimplemented."); | 1806 Register reg = ToRegister(instr->InputAt(0)); |
| 1807 Register temp1 = ToRegister(instr->TempAt(0)); |
| 1808 Register temp2 = scratch0(); |
| 1809 |
| 1810 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1811 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1812 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
| 1813 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 1814 |
| 1815 Condition true_cond = |
| 1816 EmitIsObject(reg, temp1, temp2, false_label, true_label); |
| 1817 |
| 1818 EmitBranch(true_block, false_block, true_cond); |
| 1302 } | 1819 } |
| 1303 | 1820 |
| 1304 | 1821 |
| 1305 void LCodeGen::DoIsSmi(LIsSmi* instr) { | 1822 void LCodeGen::DoIsSmi(LIsSmi* instr) { |
| 1306 ASSERT(instr->hydrogen()->value()->representation().IsTagged()); | 1823 ASSERT(instr->hydrogen()->value()->representation().IsTagged()); |
| 1307 Register result = ToRegister(instr->result()); | 1824 Register result = ToRegister(instr->result()); |
| 1308 Register input_reg = EmitLoadRegister(instr->input(), ip); | 1825 Register input_reg = EmitLoadRegister(instr->InputAt(0), ip); |
| 1309 __ tst(input_reg, Operand(kSmiTagMask)); | 1826 __ tst(input_reg, Operand(kSmiTagMask)); |
| 1310 __ LoadRoot(result, Heap::kTrueValueRootIndex); | 1827 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 1311 Label done; | 1828 Label done; |
| 1312 __ b(eq, &done); | 1829 __ b(eq, &done); |
| 1313 __ LoadRoot(result, Heap::kFalseValueRootIndex); | 1830 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 1314 __ bind(&done); | 1831 __ bind(&done); |
| 1315 } | 1832 } |
| 1316 | 1833 |
| 1317 | 1834 |
| 1318 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { | 1835 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { |
| 1319 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1836 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1320 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1837 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1321 | 1838 |
| 1322 Register input_reg = EmitLoadRegister(instr->input(), ip); | 1839 Register input_reg = EmitLoadRegister(instr->InputAt(0), ip); |
| 1323 __ tst(input_reg, Operand(kSmiTagMask)); | 1840 __ tst(input_reg, Operand(kSmiTagMask)); |
| 1324 EmitBranch(true_block, false_block, eq); | 1841 EmitBranch(true_block, false_block, eq); |
| 1325 } | 1842 } |
| 1326 | 1843 |
| 1327 | 1844 |
| 1328 InstanceType LHasInstanceType::TestType() { | 1845 static InstanceType TestType(HHasInstanceType* instr) { |
| 1329 InstanceType from = hydrogen()->from(); | 1846 InstanceType from = instr->from(); |
| 1330 InstanceType to = hydrogen()->to(); | 1847 InstanceType to = instr->to(); |
| 1331 if (from == FIRST_TYPE) return to; | 1848 if (from == FIRST_TYPE) return to; |
| 1332 ASSERT(from == to || to == LAST_TYPE); | 1849 ASSERT(from == to || to == LAST_TYPE); |
| 1333 return from; | 1850 return from; |
| 1334 } | 1851 } |
| 1335 | 1852 |
| 1336 | 1853 |
| 1337 Condition LHasInstanceType::BranchCondition() { | 1854 static Condition BranchCondition(HHasInstanceType* instr) { |
| 1338 InstanceType from = hydrogen()->from(); | 1855 InstanceType from = instr->from(); |
| 1339 InstanceType to = hydrogen()->to(); | 1856 InstanceType to = instr->to(); |
| 1340 if (from == to) return eq; | 1857 if (from == to) return eq; |
| 1341 if (to == LAST_TYPE) return hs; | 1858 if (to == LAST_TYPE) return hs; |
| 1342 if (from == FIRST_TYPE) return ls; | 1859 if (from == FIRST_TYPE) return ls; |
| 1343 UNREACHABLE(); | 1860 UNREACHABLE(); |
| 1344 return eq; | 1861 return eq; |
| 1345 } | 1862 } |
| 1346 | 1863 |
| 1347 | 1864 |
| 1348 void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) { | 1865 void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) { |
| 1349 Abort("DoHasInstanceType unimplemented."); | 1866 Register input = ToRegister(instr->InputAt(0)); |
| 1867 Register result = ToRegister(instr->result()); |
| 1868 |
| 1869 ASSERT(instr->hydrogen()->value()->representation().IsTagged()); |
| 1870 Label done; |
| 1871 __ tst(input, Operand(kSmiTagMask)); |
| 1872 __ LoadRoot(result, Heap::kFalseValueRootIndex, eq); |
| 1873 __ b(eq, &done); |
| 1874 __ CompareObjectType(input, result, result, TestType(instr->hydrogen())); |
| 1875 Condition cond = BranchCondition(instr->hydrogen()); |
| 1876 __ LoadRoot(result, Heap::kTrueValueRootIndex, cond); |
| 1877 __ LoadRoot(result, Heap::kFalseValueRootIndex, NegateCondition(cond)); |
| 1878 __ bind(&done); |
| 1350 } | 1879 } |
| 1351 | 1880 |
| 1352 | 1881 |
| 1353 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { | 1882 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { |
| 1354 Register scratch = scratch0(); | 1883 Register scratch = scratch0(); |
| 1355 Register input = ToRegister(instr->input()); | 1884 Register input = ToRegister(instr->InputAt(0)); |
| 1356 | 1885 |
| 1357 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1886 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1358 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1887 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1359 | 1888 |
| 1360 Label* false_label = chunk_->GetAssemblyLabel(false_block); | 1889 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 1361 | 1890 |
| 1362 __ tst(input, Operand(kSmiTagMask)); | 1891 __ tst(input, Operand(kSmiTagMask)); |
| 1363 __ b(eq, false_label); | 1892 __ b(eq, false_label); |
| 1364 | 1893 |
| 1365 __ CompareObjectType(input, scratch, scratch, instr->TestType()); | 1894 __ CompareObjectType(input, scratch, scratch, TestType(instr->hydrogen())); |
| 1366 EmitBranch(true_block, false_block, instr->BranchCondition()); | 1895 EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen())); |
| 1367 } | 1896 } |
| 1368 | 1897 |
| 1369 | 1898 |
| 1370 void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) { | 1899 void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) { |
| 1371 Abort("DoHasCachedArrayIndex unimplemented."); | 1900 Register input = ToRegister(instr->InputAt(0)); |
| 1901 Register result = ToRegister(instr->result()); |
| 1902 Register scratch = scratch0(); |
| 1903 |
| 1904 ASSERT(instr->hydrogen()->value()->representation().IsTagged()); |
| 1905 __ ldr(scratch, |
| 1906 FieldMemOperand(input, String::kContainsCachedArrayIndexMask)); |
| 1907 __ tst(scratch, Operand(String::kContainsCachedArrayIndexMask)); |
| 1908 __ LoadRoot(result, Heap::kTrueValueRootIndex, ne); |
| 1909 __ LoadRoot(result, Heap::kFalseValueRootIndex, eq); |
| 1372 } | 1910 } |
| 1373 | 1911 |
| 1374 | 1912 |
| 1375 void LCodeGen::DoHasCachedArrayIndexAndBranch( | 1913 void LCodeGen::DoHasCachedArrayIndexAndBranch( |
| 1376 LHasCachedArrayIndexAndBranch* instr) { | 1914 LHasCachedArrayIndexAndBranch* instr) { |
| 1377 Abort("DoHasCachedArrayIndexAndBranch unimplemented."); | 1915 Register input = ToRegister(instr->InputAt(0)); |
| 1916 Register scratch = scratch0(); |
| 1917 |
| 1918 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1919 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1920 |
| 1921 __ ldr(scratch, |
| 1922 FieldMemOperand(input, String::kContainsCachedArrayIndexMask)); |
| 1923 __ tst(scratch, Operand(String::kContainsCachedArrayIndexMask)); |
| 1924 EmitBranch(true_block, false_block, ne); |
| 1378 } | 1925 } |
| 1379 | 1926 |
| 1380 | 1927 |
| 1381 // Branches to a label or falls through with the answer in the z flag. Trashes | 1928 // Branches to a label or falls through with the answer in flags. Trashes |
| 1382 // the temp registers, but not the input. Only input and temp2 may alias. | 1929 // the temp registers, but not the input. Only input and temp2 may alias. |
| 1383 void LCodeGen::EmitClassOfTest(Label* is_true, | 1930 void LCodeGen::EmitClassOfTest(Label* is_true, |
| 1384 Label* is_false, | 1931 Label* is_false, |
| 1385 Handle<String>class_name, | 1932 Handle<String>class_name, |
| 1386 Register input, | 1933 Register input, |
| 1387 Register temp, | 1934 Register temp, |
| 1388 Register temp2) { | 1935 Register temp2) { |
| 1389 Abort("EmitClassOfTest unimplemented."); | 1936 ASSERT(!input.is(temp)); |
| 1937 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. |
| 1938 __ tst(input, Operand(kSmiTagMask)); |
| 1939 __ b(eq, is_false); |
| 1940 __ CompareObjectType(input, temp, temp2, FIRST_JS_OBJECT_TYPE); |
| 1941 __ b(lt, is_false); |
| 1942 |
| 1943 // Map is now in temp. |
| 1944 // Functions have class 'Function'. |
| 1945 __ CompareInstanceType(temp, temp2, JS_FUNCTION_TYPE); |
| 1946 if (class_name->IsEqualTo(CStrVector("Function"))) { |
| 1947 __ b(eq, is_true); |
| 1948 } else { |
| 1949 __ b(eq, is_false); |
| 1950 } |
| 1951 |
| 1952 // Check if the constructor in the map is a function. |
| 1953 __ ldr(temp, FieldMemOperand(temp, Map::kConstructorOffset)); |
| 1954 |
| 1955 // As long as JS_FUNCTION_TYPE is the last instance type and it is |
| 1956 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for |
| 1957 // LAST_JS_OBJECT_TYPE. |
| 1958 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 1959 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); |
| 1960 |
| 1961 // Objects with a non-function constructor have class 'Object'. |
| 1962 __ CompareObjectType(temp, temp2, temp2, JS_FUNCTION_TYPE); |
| 1963 if (class_name->IsEqualTo(CStrVector("Object"))) { |
| 1964 __ b(ne, is_true); |
| 1965 } else { |
| 1966 __ b(ne, is_false); |
| 1967 } |
| 1968 |
| 1969 // temp now contains the constructor function. Grab the |
| 1970 // instance class name from there. |
| 1971 __ ldr(temp, FieldMemOperand(temp, JSFunction::kSharedFunctionInfoOffset)); |
| 1972 __ ldr(temp, FieldMemOperand(temp, |
| 1973 SharedFunctionInfo::kInstanceClassNameOffset)); |
| 1974 // The class name we are testing against is a symbol because it's a literal. |
| 1975 // The name in the constructor is a symbol because of the way the context is |
| 1976 // booted. This routine isn't expected to work for random API-created |
| 1977 // classes and it doesn't have to because you can't access it with natives |
| 1978 // syntax. Since both sides are symbols it is sufficient to use an identity |
| 1979 // comparison. |
| 1980 __ cmp(temp, Operand(class_name)); |
| 1981 // End with the answer in flags. |
| 1390 } | 1982 } |
| 1391 | 1983 |
| 1392 | 1984 |
| 1393 void LCodeGen::DoClassOfTest(LClassOfTest* instr) { | 1985 void LCodeGen::DoClassOfTest(LClassOfTest* instr) { |
| 1394 Abort("DoClassOfTest unimplemented."); | 1986 Register input = ToRegister(instr->InputAt(0)); |
| 1987 Register result = ToRegister(instr->result()); |
| 1988 ASSERT(input.is(result)); |
| 1989 Handle<String> class_name = instr->hydrogen()->class_name(); |
| 1990 |
| 1991 Label done, is_true, is_false; |
| 1992 |
| 1993 EmitClassOfTest(&is_true, &is_false, class_name, input, scratch0(), input); |
| 1994 __ b(ne, &is_false); |
| 1995 |
| 1996 __ bind(&is_true); |
| 1997 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 1998 __ jmp(&done); |
| 1999 |
| 2000 __ bind(&is_false); |
| 2001 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 2002 __ bind(&done); |
| 1395 } | 2003 } |
| 1396 | 2004 |
| 1397 | 2005 |
| 1398 void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) { | 2006 void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) { |
| 1399 Abort("DoClassOfTestAndBranch unimplemented."); | 2007 Register input = ToRegister(instr->InputAt(0)); |
| 2008 Register temp = scratch0(); |
| 2009 Register temp2 = ToRegister(instr->TempAt(0)); |
| 2010 Handle<String> class_name = instr->hydrogen()->class_name(); |
| 2011 |
| 2012 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 2013 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 2014 |
| 2015 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
| 2016 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 2017 |
| 2018 EmitClassOfTest(true_label, false_label, class_name, input, temp, temp2); |
| 2019 |
| 2020 EmitBranch(true_block, false_block, eq); |
| 1400 } | 2021 } |
| 1401 | 2022 |
| 1402 | 2023 |
| 1403 void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) { | 2024 void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) { |
| 1404 Register reg = ToRegister(instr->input()); | 2025 Register reg = ToRegister(instr->InputAt(0)); |
| 1405 Register temp = ToRegister(instr->temp()); | 2026 Register temp = ToRegister(instr->TempAt(0)); |
| 1406 int true_block = instr->true_block_id(); | 2027 int true_block = instr->true_block_id(); |
| 1407 int false_block = instr->false_block_id(); | 2028 int false_block = instr->false_block_id(); |
| 1408 | 2029 |
| 1409 __ ldr(temp, FieldMemOperand(reg, HeapObject::kMapOffset)); | 2030 __ ldr(temp, FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 1410 __ cmp(temp, Operand(instr->map())); | 2031 __ cmp(temp, Operand(instr->map())); |
| 1411 EmitBranch(true_block, false_block, eq); | 2032 EmitBranch(true_block, false_block, eq); |
| 1412 } | 2033 } |
| 1413 | 2034 |
| 1414 | 2035 |
| 1415 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { | 2036 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { |
| 1416 ASSERT(ToRegister(instr->left()).is(r0)); // Object is in r0. | 2037 ASSERT(ToRegister(instr->InputAt(0)).is(r0)); // Object is in r0. |
| 1417 ASSERT(ToRegister(instr->right()).is(r1)); // Function is in r1. | 2038 ASSERT(ToRegister(instr->InputAt(1)).is(r1)); // Function is in r1. |
| 1418 | 2039 |
| 1419 InstanceofStub stub(InstanceofStub::kArgsInRegisters); | 2040 InstanceofStub stub(InstanceofStub::kArgsInRegisters); |
| 1420 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 2041 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1421 | 2042 |
| 1422 Label true_value, done; | 2043 Label true_value, done; |
| 1423 __ tst(r0, r0); | 2044 __ tst(r0, r0); |
| 1424 __ mov(r0, Operand(Factory::false_value()), LeaveCC, ne); | 2045 __ mov(r0, Operand(Factory::false_value()), LeaveCC, ne); |
| 1425 __ mov(r0, Operand(Factory::true_value()), LeaveCC, eq); | 2046 __ mov(r0, Operand(Factory::true_value()), LeaveCC, eq); |
| 1426 } | 2047 } |
| 1427 | 2048 |
| 1428 | 2049 |
| 1429 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { | 2050 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { |
| 1430 Abort("DoInstanceOfAndBranch unimplemented."); | 2051 ASSERT(ToRegister(instr->InputAt(0)).is(r0)); // Object is in r0. |
| 2052 ASSERT(ToRegister(instr->InputAt(1)).is(r1)); // Function is in r1. |
| 2053 |
| 2054 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 2055 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 2056 |
| 2057 InstanceofStub stub(InstanceofStub::kArgsInRegisters); |
| 2058 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2059 __ tst(r0, Operand(r0)); |
| 2060 EmitBranch(true_block, false_block, eq); |
| 1431 } | 2061 } |
| 1432 | 2062 |
| 1433 | 2063 |
| 2064 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
| 2065 class DeferredInstanceOfKnownGlobal: public LDeferredCode { |
| 2066 public: |
| 2067 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, |
| 2068 LInstanceOfKnownGlobal* instr) |
| 2069 : LDeferredCode(codegen), instr_(instr) { } |
| 2070 virtual void Generate() { |
| 2071 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_); |
| 2072 } |
| 2073 |
| 2074 Label* map_check() { return &map_check_; } |
| 2075 |
| 2076 private: |
| 2077 LInstanceOfKnownGlobal* instr_; |
| 2078 Label map_check_; |
| 2079 }; |
| 2080 |
| 2081 DeferredInstanceOfKnownGlobal* deferred; |
| 2082 deferred = new DeferredInstanceOfKnownGlobal(this, instr); |
| 2083 |
| 2084 Label done, false_result; |
| 2085 Register object = ToRegister(instr->InputAt(0)); |
| 2086 Register temp = ToRegister(instr->TempAt(0)); |
| 2087 Register result = ToRegister(instr->result()); |
| 2088 |
| 2089 ASSERT(object.is(r0)); |
| 2090 ASSERT(result.is(r0)); |
| 2091 |
| 2092 // A Smi is not instance of anything. |
| 2093 __ JumpIfSmi(object, &false_result); |
| 2094 |
| 2095 // This is the inlined call site instanceof cache. The two occurences of the |
| 2096 // hole value will be patched to the last map/result pair generated by the |
| 2097 // instanceof stub. |
| 2098 Label cache_miss; |
| 2099 Register map = temp; |
| 2100 __ ldr(map, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 2101 __ bind(deferred->map_check()); // Label for calculating code patching. |
| 2102 // We use Factory::the_hole_value() on purpose instead of loading from the |
| 2103 // root array to force relocation to be able to later patch with |
| 2104 // the cached map. |
| 2105 __ mov(ip, Operand(Factory::the_hole_value())); |
| 2106 __ cmp(map, Operand(ip)); |
| 2107 __ b(ne, &cache_miss); |
| 2108 // We use Factory::the_hole_value() on purpose instead of loading from the |
| 2109 // root array to force relocation to be able to later patch |
| 2110 // with true or false. |
| 2111 __ mov(result, Operand(Factory::the_hole_value())); |
| 2112 __ b(&done); |
| 2113 |
| 2114 // The inlined call site cache did not match. Check null and string before |
| 2115 // calling the deferred code. |
| 2116 __ bind(&cache_miss); |
| 2117 // Null is not instance of anything. |
| 2118 __ LoadRoot(ip, Heap::kNullValueRootIndex); |
| 2119 __ cmp(object, Operand(ip)); |
| 2120 __ b(eq, &false_result); |
| 2121 |
| 2122 // String values is not instance of anything. |
| 2123 Condition is_string = masm_->IsObjectStringType(object, temp); |
| 2124 __ b(is_string, &false_result); |
| 2125 |
| 2126 // Go to the deferred code. |
| 2127 __ b(deferred->entry()); |
| 2128 |
| 2129 __ bind(&false_result); |
| 2130 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 2131 |
| 2132 // Here result has either true or false. Deferred code also produces true or |
| 2133 // false object. |
| 2134 __ bind(deferred->exit()); |
| 2135 __ bind(&done); |
| 2136 } |
| 2137 |
| 2138 |
| 2139 void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 2140 Label* map_check) { |
| 2141 Register result = ToRegister(instr->result()); |
| 2142 ASSERT(result.is(r0)); |
| 2143 |
| 2144 InstanceofStub::Flags flags = InstanceofStub::kNoFlags; |
| 2145 flags = static_cast<InstanceofStub::Flags>( |
| 2146 flags | InstanceofStub::kArgsInRegisters); |
| 2147 flags = static_cast<InstanceofStub::Flags>( |
| 2148 flags | InstanceofStub::kCallSiteInlineCheck); |
| 2149 flags = static_cast<InstanceofStub::Flags>( |
| 2150 flags | InstanceofStub::kReturnTrueFalseObject); |
| 2151 InstanceofStub stub(flags); |
| 2152 |
| 2153 __ PushSafepointRegisters(); |
| 2154 |
| 2155 // Get the temp register reserved by the instruction. This needs to be r4 as |
| 2156 // its slot of the pushing of safepoint registers is used to communicate the |
| 2157 // offset to the location of the map check. |
| 2158 Register temp = ToRegister(instr->TempAt(0)); |
| 2159 ASSERT(temp.is(r4)); |
| 2160 __ mov(InstanceofStub::right(), Operand(instr->function())); |
| 2161 static const int kAdditionalDelta = 4; |
| 2162 int delta = masm_->InstructionsGeneratedSince(map_check) + kAdditionalDelta; |
| 2163 Label before_push_delta; |
| 2164 __ bind(&before_push_delta); |
| 2165 __ BlockConstPoolFor(kAdditionalDelta); |
| 2166 __ mov(temp, Operand(delta * kPointerSize)); |
| 2167 __ StoreToSafepointRegisterSlot(temp); |
| 2168 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 2169 ASSERT_EQ(kAdditionalDelta, |
| 2170 masm_->InstructionsGeneratedSince(&before_push_delta)); |
| 2171 RecordSafepointWithRegisters( |
| 2172 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
| 2173 // Put the result value into the result register slot and |
| 2174 // restore all registers. |
| 2175 __ StoreToSafepointRegisterSlot(result); |
| 2176 |
| 2177 __ PopSafepointRegisters(); |
| 2178 } |
| 2179 |
| 1434 | 2180 |
| 1435 static Condition ComputeCompareCondition(Token::Value op) { | 2181 static Condition ComputeCompareCondition(Token::Value op) { |
| 1436 switch (op) { | 2182 switch (op) { |
| 1437 case Token::EQ_STRICT: | 2183 case Token::EQ_STRICT: |
| 1438 case Token::EQ: | 2184 case Token::EQ: |
| 1439 return eq; | 2185 return eq; |
| 1440 case Token::LT: | 2186 case Token::LT: |
| 1441 return lt; | 2187 return lt; |
| 1442 case Token::GT: | 2188 case Token::GT: |
| 1443 return gt; | 2189 return gt; |
| 1444 case Token::LTE: | 2190 case Token::LTE: |
| 1445 return le; | 2191 return le; |
| 1446 case Token::GTE: | 2192 case Token::GTE: |
| 1447 return ge; | 2193 return ge; |
| 1448 default: | 2194 default: |
| 1449 UNREACHABLE(); | 2195 UNREACHABLE(); |
| 1450 return no_condition; | 2196 return kNoCondition; |
| 1451 } | 2197 } |
| 1452 } | 2198 } |
| 1453 | 2199 |
| 1454 | 2200 |
| 1455 void LCodeGen::DoCmpT(LCmpT* instr) { | 2201 void LCodeGen::DoCmpT(LCmpT* instr) { |
| 1456 Token::Value op = instr->op(); | 2202 Token::Value op = instr->op(); |
| 1457 | 2203 |
| 1458 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2204 Handle<Code> ic = CompareIC::GetUninitialized(op); |
| 1459 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2205 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2206 __ cmp(r0, Operand(0)); // This instruction also signals no smi code inlined. |
| 1460 | 2207 |
| 1461 Condition condition = ComputeCompareCondition(op); | 2208 Condition condition = ComputeCompareCondition(op); |
| 1462 if (op == Token::GT || op == Token::LTE) { | 2209 if (op == Token::GT || op == Token::LTE) { |
| 1463 condition = ReverseCondition(condition); | 2210 condition = ReverseCondition(condition); |
| 1464 } | 2211 } |
| 1465 __ cmp(r0, Operand(0)); | 2212 __ LoadRoot(ToRegister(instr->result()), |
| 1466 __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex, | 2213 Heap::kTrueValueRootIndex, |
| 1467 condition); | 2214 condition); |
| 1468 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex, | 2215 __ LoadRoot(ToRegister(instr->result()), |
| 1469 NegateCondition(condition)); | 2216 Heap::kFalseValueRootIndex, |
| 2217 NegateCondition(condition)); |
| 1470 } | 2218 } |
| 1471 | 2219 |
| 1472 | 2220 |
| 1473 void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) { | 2221 void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) { |
| 1474 Abort("DoCmpTAndBranch unimplemented."); | 2222 Token::Value op = instr->op(); |
| 2223 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 2224 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 2225 |
| 2226 Handle<Code> ic = CompareIC::GetUninitialized(op); |
| 2227 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2228 |
| 2229 // The compare stub expects compare condition and the input operands |
| 2230 // reversed for GT and LTE. |
| 2231 Condition condition = ComputeCompareCondition(op); |
| 2232 if (op == Token::GT || op == Token::LTE) { |
| 2233 condition = ReverseCondition(condition); |
| 2234 } |
| 2235 __ cmp(r0, Operand(0)); |
| 2236 EmitBranch(true_block, false_block, condition); |
| 1475 } | 2237 } |
| 1476 | 2238 |
| 1477 | 2239 |
| 1478 void LCodeGen::DoReturn(LReturn* instr) { | 2240 void LCodeGen::DoReturn(LReturn* instr) { |
| 1479 if (FLAG_trace) { | 2241 if (FLAG_trace) { |
| 1480 // Push the return value on the stack as the parameter. | 2242 // Push the return value on the stack as the parameter. |
| 1481 // Runtime::TraceExit returns its parameter in r0. | 2243 // Runtime::TraceExit returns its parameter in r0. |
| 1482 __ push(r0); | 2244 __ push(r0); |
| 1483 __ CallRuntime(Runtime::kTraceExit, 1); | 2245 __ CallRuntime(Runtime::kTraceExit, 1); |
| 1484 } | 2246 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1496 __ ldr(result, FieldMemOperand(ip, JSGlobalPropertyCell::kValueOffset)); | 2258 __ ldr(result, FieldMemOperand(ip, JSGlobalPropertyCell::kValueOffset)); |
| 1497 if (instr->hydrogen()->check_hole_value()) { | 2259 if (instr->hydrogen()->check_hole_value()) { |
| 1498 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 2260 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 1499 __ cmp(result, ip); | 2261 __ cmp(result, ip); |
| 1500 DeoptimizeIf(eq, instr->environment()); | 2262 DeoptimizeIf(eq, instr->environment()); |
| 1501 } | 2263 } |
| 1502 } | 2264 } |
| 1503 | 2265 |
| 1504 | 2266 |
| 1505 void LCodeGen::DoStoreGlobal(LStoreGlobal* instr) { | 2267 void LCodeGen::DoStoreGlobal(LStoreGlobal* instr) { |
| 1506 Register value = ToRegister(instr->input()); | 2268 Register value = ToRegister(instr->InputAt(0)); |
| 1507 __ mov(ip, Operand(Handle<Object>(instr->hydrogen()->cell()))); | 2269 Register scratch = scratch0(); |
| 1508 __ str(value, FieldMemOperand(ip, JSGlobalPropertyCell::kValueOffset)); | 2270 |
| 2271 // Load the cell. |
| 2272 __ mov(scratch, Operand(Handle<Object>(instr->hydrogen()->cell()))); |
| 2273 |
| 2274 // If the cell we are storing to contains the hole it could have |
| 2275 // been deleted from the property dictionary. In that case, we need |
| 2276 // to update the property details in the property dictionary to mark |
| 2277 // it as no longer deleted. |
| 2278 if (instr->hydrogen()->check_hole_value()) { |
| 2279 Register scratch2 = ToRegister(instr->TempAt(0)); |
| 2280 __ ldr(scratch2, |
| 2281 FieldMemOperand(scratch, JSGlobalPropertyCell::kValueOffset)); |
| 2282 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 2283 __ cmp(scratch2, ip); |
| 2284 DeoptimizeIf(eq, instr->environment()); |
| 2285 } |
| 2286 |
| 2287 // Store the value. |
| 2288 __ str(value, FieldMemOperand(scratch, JSGlobalPropertyCell::kValueOffset)); |
| 2289 } |
| 2290 |
| 2291 |
| 2292 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) { |
| 2293 Register context = ToRegister(instr->context()); |
| 2294 Register result = ToRegister(instr->result()); |
| 2295 __ ldr(result, |
| 2296 MemOperand(context, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 2297 __ ldr(result, ContextOperand(result, instr->slot_index())); |
| 2298 } |
| 2299 |
| 2300 |
| 2301 void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { |
| 2302 Register context = ToRegister(instr->context()); |
| 2303 Register value = ToRegister(instr->value()); |
| 2304 __ ldr(context, |
| 2305 MemOperand(context, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 2306 __ str(value, ContextOperand(context, instr->slot_index())); |
| 2307 if (instr->needs_write_barrier()) { |
| 2308 int offset = Context::SlotOffset(instr->slot_index()); |
| 2309 __ RecordWrite(context, Operand(offset), value, scratch0()); |
| 2310 } |
| 1509 } | 2311 } |
| 1510 | 2312 |
| 1511 | 2313 |
| 1512 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { | 2314 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { |
| 1513 Register object = ToRegister(instr->input()); | 2315 Register object = ToRegister(instr->InputAt(0)); |
| 1514 Register result = ToRegister(instr->result()); | 2316 Register result = ToRegister(instr->result()); |
| 1515 if (instr->hydrogen()->is_in_object()) { | 2317 if (instr->hydrogen()->is_in_object()) { |
| 1516 __ ldr(result, FieldMemOperand(object, instr->hydrogen()->offset())); | 2318 __ ldr(result, FieldMemOperand(object, instr->hydrogen()->offset())); |
| 1517 } else { | 2319 } else { |
| 1518 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 2320 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
| 1519 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset())); | 2321 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset())); |
| 1520 } | 2322 } |
| 1521 } | 2323 } |
| 1522 | 2324 |
| 1523 | 2325 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 // in initial map. | 2372 // in initial map. |
| 1571 __ bind(&non_instance); | 2373 __ bind(&non_instance); |
| 1572 __ ldr(result, FieldMemOperand(result, Map::kConstructorOffset)); | 2374 __ ldr(result, FieldMemOperand(result, Map::kConstructorOffset)); |
| 1573 | 2375 |
| 1574 // All done. | 2376 // All done. |
| 1575 __ bind(&done); | 2377 __ bind(&done); |
| 1576 } | 2378 } |
| 1577 | 2379 |
| 1578 | 2380 |
| 1579 void LCodeGen::DoLoadElements(LLoadElements* instr) { | 2381 void LCodeGen::DoLoadElements(LLoadElements* instr) { |
| 1580 Abort("DoLoadElements unimplemented."); | 2382 Register result = ToRegister(instr->result()); |
| 2383 Register input = ToRegister(instr->InputAt(0)); |
| 2384 Register scratch = scratch0(); |
| 2385 |
| 2386 __ ldr(result, FieldMemOperand(input, JSObject::kElementsOffset)); |
| 2387 if (FLAG_debug_code) { |
| 2388 Label done; |
| 2389 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset)); |
| 2390 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); |
| 2391 __ cmp(scratch, ip); |
| 2392 __ b(eq, &done); |
| 2393 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); |
| 2394 __ cmp(scratch, ip); |
| 2395 __ b(eq, &done); |
| 2396 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex); |
| 2397 __ cmp(scratch, ip); |
| 2398 __ Check(eq, "Check for fast elements failed."); |
| 2399 __ bind(&done); |
| 2400 } |
| 2401 } |
| 2402 |
| 2403 |
| 2404 void LCodeGen::DoLoadPixelArrayExternalPointer( |
| 2405 LLoadPixelArrayExternalPointer* instr) { |
| 2406 Register to_reg = ToRegister(instr->result()); |
| 2407 Register from_reg = ToRegister(instr->InputAt(0)); |
| 2408 __ ldr(to_reg, FieldMemOperand(from_reg, PixelArray::kExternalPointerOffset)); |
| 1581 } | 2409 } |
| 1582 | 2410 |
| 1583 | 2411 |
| 1584 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { | 2412 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
| 1585 Abort("DoAccessArgumentsAt unimplemented."); | 2413 Register arguments = ToRegister(instr->arguments()); |
| 2414 Register length = ToRegister(instr->length()); |
| 2415 Register index = ToRegister(instr->index()); |
| 2416 Register result = ToRegister(instr->result()); |
| 2417 |
| 2418 // Bailout index is not a valid argument index. Use unsigned check to get |
| 2419 // negative check for free. |
| 2420 __ sub(length, length, index, SetCC); |
| 2421 DeoptimizeIf(ls, instr->environment()); |
| 2422 |
| 2423 // There are two words between the frame pointer and the last argument. |
| 2424 // Subtracting from length accounts for one of them add one more. |
| 2425 __ add(length, length, Operand(1)); |
| 2426 __ ldr(result, MemOperand(arguments, length, LSL, kPointerSizeLog2)); |
| 1586 } | 2427 } |
| 1587 | 2428 |
| 1588 | 2429 |
| 1589 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { | 2430 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
| 1590 Abort("DoLoadKeyedFastElement unimplemented."); | 2431 Register elements = ToRegister(instr->elements()); |
| 2432 Register key = EmitLoadRegister(instr->key(), scratch0()); |
| 2433 Register result = ToRegister(instr->result()); |
| 2434 Register scratch = scratch0(); |
| 2435 ASSERT(result.is(elements)); |
| 2436 |
| 2437 // Load the result. |
| 2438 __ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2)); |
| 2439 __ ldr(result, FieldMemOperand(scratch, FixedArray::kHeaderSize)); |
| 2440 |
| 2441 // Check for the hole value. |
| 2442 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); |
| 2443 __ cmp(result, scratch); |
| 2444 DeoptimizeIf(eq, instr->environment()); |
| 2445 } |
| 2446 |
| 2447 |
| 2448 void LCodeGen::DoLoadPixelArrayElement(LLoadPixelArrayElement* instr) { |
| 2449 Register external_elements = ToRegister(instr->external_pointer()); |
| 2450 Register key = ToRegister(instr->key()); |
| 2451 Register result = ToRegister(instr->result()); |
| 2452 |
| 2453 // Load the result. |
| 2454 __ ldrb(result, MemOperand(external_elements, key)); |
| 1591 } | 2455 } |
| 1592 | 2456 |
| 1593 | 2457 |
| 1594 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { | 2458 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
| 1595 ASSERT(ToRegister(instr->object()).is(r1)); | 2459 ASSERT(ToRegister(instr->object()).is(r1)); |
| 1596 ASSERT(ToRegister(instr->key()).is(r0)); | 2460 ASSERT(ToRegister(instr->key()).is(r0)); |
| 1597 | 2461 |
| 1598 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 2462 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
| 1599 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2463 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1600 } | 2464 } |
| 1601 | 2465 |
| 1602 | 2466 |
| 1603 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { | 2467 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) { |
| 1604 Abort("DoArgumentsElements unimplemented."); | 2468 Register scratch = scratch0(); |
| 2469 Register result = ToRegister(instr->result()); |
| 2470 |
| 2471 // Check if the calling frame is an arguments adaptor frame. |
| 2472 Label done, adapted; |
| 2473 __ ldr(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2474 __ ldr(result, MemOperand(scratch, StandardFrameConstants::kContextOffset)); |
| 2475 __ cmp(result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 2476 |
| 2477 // Result is the frame pointer for the frame if not adapted and for the real |
| 2478 // frame below the adaptor frame if adapted. |
| 2479 __ mov(result, fp, LeaveCC, ne); |
| 2480 __ mov(result, scratch, LeaveCC, eq); |
| 1605 } | 2481 } |
| 1606 | 2482 |
| 1607 | 2483 |
| 1608 void LCodeGen::DoArgumentsLength(LArgumentsLength* instr) { | 2484 void LCodeGen::DoArgumentsLength(LArgumentsLength* instr) { |
| 1609 Abort("DoArgumentsLength unimplemented."); | 2485 Register elem = ToRegister(instr->InputAt(0)); |
| 2486 Register result = ToRegister(instr->result()); |
| 2487 |
| 2488 Label done; |
| 2489 |
| 2490 // If no arguments adaptor frame the number of arguments is fixed. |
| 2491 __ cmp(fp, elem); |
| 2492 __ mov(result, Operand(scope()->num_parameters())); |
| 2493 __ b(eq, &done); |
| 2494 |
| 2495 // Arguments adaptor frame present. Get argument length from there. |
| 2496 __ ldr(result, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2497 __ ldr(result, |
| 2498 MemOperand(result, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 2499 __ SmiUntag(result); |
| 2500 |
| 2501 // Argument length is in result register. |
| 2502 __ bind(&done); |
| 1610 } | 2503 } |
| 1611 | 2504 |
| 1612 | 2505 |
| 1613 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 2506 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
| 1614 Abort("DoApplyArguments unimplemented."); | 2507 Register receiver = ToRegister(instr->receiver()); |
| 2508 Register function = ToRegister(instr->function()); |
| 2509 Register length = ToRegister(instr->length()); |
| 2510 Register elements = ToRegister(instr->elements()); |
| 2511 Register scratch = scratch0(); |
| 2512 ASSERT(receiver.is(r0)); // Used for parameter count. |
| 2513 ASSERT(function.is(r1)); // Required by InvokeFunction. |
| 2514 ASSERT(ToRegister(instr->result()).is(r0)); |
| 2515 |
| 2516 // If the receiver is null or undefined, we have to pass the global object |
| 2517 // as a receiver. |
| 2518 Label global_object, receiver_ok; |
| 2519 __ LoadRoot(scratch, Heap::kNullValueRootIndex); |
| 2520 __ cmp(receiver, scratch); |
| 2521 __ b(eq, &global_object); |
| 2522 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
| 2523 __ cmp(receiver, scratch); |
| 2524 __ b(eq, &global_object); |
| 2525 |
| 2526 // Deoptimize if the receiver is not a JS object. |
| 2527 __ tst(receiver, Operand(kSmiTagMask)); |
| 2528 DeoptimizeIf(eq, instr->environment()); |
| 2529 __ CompareObjectType(receiver, scratch, scratch, FIRST_JS_OBJECT_TYPE); |
| 2530 DeoptimizeIf(lo, instr->environment()); |
| 2531 __ jmp(&receiver_ok); |
| 2532 |
| 2533 __ bind(&global_object); |
| 2534 __ ldr(receiver, GlobalObjectOperand()); |
| 2535 __ bind(&receiver_ok); |
| 2536 |
| 2537 // Copy the arguments to this function possibly from the |
| 2538 // adaptor frame below it. |
| 2539 const uint32_t kArgumentsLimit = 1 * KB; |
| 2540 __ cmp(length, Operand(kArgumentsLimit)); |
| 2541 DeoptimizeIf(hi, instr->environment()); |
| 2542 |
| 2543 // Push the receiver and use the register to keep the original |
| 2544 // number of arguments. |
| 2545 __ push(receiver); |
| 2546 __ mov(receiver, length); |
| 2547 // The arguments are at a one pointer size offset from elements. |
| 2548 __ add(elements, elements, Operand(1 * kPointerSize)); |
| 2549 |
| 2550 // Loop through the arguments pushing them onto the execution |
| 2551 // stack. |
| 2552 Label invoke, loop; |
| 2553 // length is a small non-negative integer, due to the test above. |
| 2554 __ tst(length, Operand(length)); |
| 2555 __ b(eq, &invoke); |
| 2556 __ bind(&loop); |
| 2557 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); |
| 2558 __ push(scratch); |
| 2559 __ sub(length, length, Operand(1), SetCC); |
| 2560 __ b(ne, &loop); |
| 2561 |
| 2562 __ bind(&invoke); |
| 2563 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 2564 LPointerMap* pointers = instr->pointer_map(); |
| 2565 LEnvironment* env = instr->deoptimization_environment(); |
| 2566 RecordPosition(pointers->position()); |
| 2567 RegisterEnvironmentForDeoptimization(env); |
| 2568 SafepointGenerator safepoint_generator(this, |
| 2569 pointers, |
| 2570 env->deoptimization_index()); |
| 2571 // The number of arguments is stored in receiver which is r0, as expected |
| 2572 // by InvokeFunction. |
| 2573 v8::internal::ParameterCount actual(receiver); |
| 2574 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); |
| 2575 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1615 } | 2576 } |
| 1616 | 2577 |
| 1617 | 2578 |
| 1618 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2579 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
| 1619 LOperand* argument = instr->input(); | 2580 LOperand* argument = instr->InputAt(0); |
| 1620 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { | 2581 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { |
| 1621 Abort("DoPushArgument not implemented for double type."); | 2582 Abort("DoPushArgument not implemented for double type."); |
| 1622 } else { | 2583 } else { |
| 1623 Register argument_reg = EmitLoadRegister(argument, ip); | 2584 Register argument_reg = EmitLoadRegister(argument, ip); |
| 1624 __ push(argument_reg); | 2585 __ push(argument_reg); |
| 1625 } | 2586 } |
| 1626 } | 2587 } |
| 1627 | 2588 |
| 1628 | 2589 |
| 2590 void LCodeGen::DoContext(LContext* instr) { |
| 2591 Register result = ToRegister(instr->result()); |
| 2592 __ mov(result, cp); |
| 2593 } |
| 2594 |
| 2595 |
| 2596 void LCodeGen::DoOuterContext(LOuterContext* instr) { |
| 2597 Register context = ToRegister(instr->context()); |
| 2598 Register result = ToRegister(instr->result()); |
| 2599 __ ldr(result, |
| 2600 MemOperand(context, Context::SlotOffset(Context::CLOSURE_INDEX))); |
| 2601 __ ldr(result, FieldMemOperand(result, JSFunction::kContextOffset)); |
| 2602 } |
| 2603 |
| 2604 |
| 1629 void LCodeGen::DoGlobalObject(LGlobalObject* instr) { | 2605 void LCodeGen::DoGlobalObject(LGlobalObject* instr) { |
| 2606 Register context = ToRegister(instr->context()); |
| 1630 Register result = ToRegister(instr->result()); | 2607 Register result = ToRegister(instr->result()); |
| 1631 __ ldr(result, ContextOperand(cp, Context::GLOBAL_INDEX)); | 2608 __ ldr(result, ContextOperand(cp, Context::GLOBAL_INDEX)); |
| 1632 } | 2609 } |
| 1633 | 2610 |
| 1634 | 2611 |
| 1635 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { | 2612 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { |
| 2613 Register global = ToRegister(instr->global()); |
| 1636 Register result = ToRegister(instr->result()); | 2614 Register result = ToRegister(instr->result()); |
| 1637 __ ldr(result, ContextOperand(cp, Context::GLOBAL_INDEX)); | 2615 __ ldr(result, FieldMemOperand(global, GlobalObject::kGlobalReceiverOffset)); |
| 1638 __ ldr(result, FieldMemOperand(result, GlobalObject::kGlobalReceiverOffset)); | |
| 1639 } | 2616 } |
| 1640 | 2617 |
| 1641 | 2618 |
| 1642 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 2619 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
| 1643 int arity, | 2620 int arity, |
| 1644 LInstruction* instr) { | 2621 LInstruction* instr) { |
| 1645 // Change context if needed. | 2622 // Change context if needed. |
| 1646 bool change_context = | 2623 bool change_context = |
| 1647 (graph()->info()->closure()->context() != function->context()) || | 2624 (graph()->info()->closure()->context() != function->context()) || |
| 1648 scope()->contains_with() || | 2625 scope()->contains_with() || |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1673 | 2650 |
| 1674 | 2651 |
| 1675 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 2652 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
| 1676 ASSERT(ToRegister(instr->result()).is(r0)); | 2653 ASSERT(ToRegister(instr->result()).is(r0)); |
| 1677 __ mov(r1, Operand(instr->function())); | 2654 __ mov(r1, Operand(instr->function())); |
| 1678 CallKnownFunction(instr->function(), instr->arity(), instr); | 2655 CallKnownFunction(instr->function(), instr->arity(), instr); |
| 1679 } | 2656 } |
| 1680 | 2657 |
| 1681 | 2658 |
| 1682 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { | 2659 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
| 1683 Abort("DoDeferredMathAbsTaggedHeapNumber unimplemented."); | 2660 ASSERT(instr->InputAt(0)->Equals(instr->result())); |
| 2661 Register input = ToRegister(instr->InputAt(0)); |
| 2662 Register scratch = scratch0(); |
| 2663 |
| 2664 // Deoptimize if not a heap number. |
| 2665 __ ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); |
| 2666 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 2667 __ cmp(scratch, Operand(ip)); |
| 2668 DeoptimizeIf(ne, instr->environment()); |
| 2669 |
| 2670 Label done; |
| 2671 Register exponent = scratch0(); |
| 2672 scratch = no_reg; |
| 2673 __ ldr(exponent, FieldMemOperand(input, HeapNumber::kExponentOffset)); |
| 2674 // Check the sign of the argument. If the argument is positive, just |
| 2675 // return it. We do not need to patch the stack since |input| and |
| 2676 // |result| are the same register and |input| would be restored |
| 2677 // unchanged by popping safepoint registers. |
| 2678 __ tst(exponent, Operand(HeapNumber::kSignMask)); |
| 2679 __ b(eq, &done); |
| 2680 |
| 2681 // Input is negative. Reverse its sign. |
| 2682 // Preserve the value of all registers. |
| 2683 __ PushSafepointRegisters(); |
| 2684 |
| 2685 // Registers were saved at the safepoint, so we can use |
| 2686 // many scratch registers. |
| 2687 Register tmp1 = input.is(r1) ? r0 : r1; |
| 2688 Register tmp2 = input.is(r2) ? r0 : r2; |
| 2689 Register tmp3 = input.is(r3) ? r0 : r3; |
| 2690 Register tmp4 = input.is(r4) ? r0 : r4; |
| 2691 |
| 2692 // exponent: floating point exponent value. |
| 2693 |
| 2694 Label allocated, slow; |
| 2695 __ LoadRoot(tmp4, Heap::kHeapNumberMapRootIndex); |
| 2696 __ AllocateHeapNumber(tmp1, tmp2, tmp3, tmp4, &slow); |
| 2697 __ b(&allocated); |
| 2698 |
| 2699 // Slow case: Call the runtime system to do the number allocation. |
| 2700 __ bind(&slow); |
| 2701 |
| 2702 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
| 2703 RecordSafepointWithRegisters( |
| 2704 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
| 2705 // Set the pointer to the new heap number in tmp. |
| 2706 if (!tmp1.is(r0)) __ mov(tmp1, Operand(r0)); |
| 2707 // Restore input_reg after call to runtime. |
| 2708 __ LoadFromSafepointRegisterSlot(input); |
| 2709 __ ldr(exponent, FieldMemOperand(input, HeapNumber::kExponentOffset)); |
| 2710 |
| 2711 __ bind(&allocated); |
| 2712 // exponent: floating point exponent value. |
| 2713 // tmp1: allocated heap number. |
| 2714 __ bic(exponent, exponent, Operand(HeapNumber::kSignMask)); |
| 2715 __ str(exponent, FieldMemOperand(tmp1, HeapNumber::kExponentOffset)); |
| 2716 __ ldr(tmp2, FieldMemOperand(input, HeapNumber::kMantissaOffset)); |
| 2717 __ str(tmp2, FieldMemOperand(tmp1, HeapNumber::kMantissaOffset)); |
| 2718 |
| 2719 __ str(tmp1, masm()->SafepointRegisterSlot(input)); |
| 2720 __ PopSafepointRegisters(); |
| 2721 |
| 2722 __ bind(&done); |
| 2723 } |
| 2724 |
| 2725 |
| 2726 void LCodeGen::EmitIntegerMathAbs(LUnaryMathOperation* instr) { |
| 2727 Register input = ToRegister(instr->InputAt(0)); |
| 2728 __ cmp(input, Operand(0)); |
| 2729 // We can make rsb conditional because the previous cmp instruction |
| 2730 // will clear the V (overflow) flag and rsb won't set this flag |
| 2731 // if input is positive. |
| 2732 __ rsb(input, input, Operand(0), SetCC, mi); |
| 2733 // Deoptimize on overflow. |
| 2734 DeoptimizeIf(vs, instr->environment()); |
| 1684 } | 2735 } |
| 1685 | 2736 |
| 1686 | 2737 |
| 1687 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { | 2738 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { |
| 1688 Abort("DoMathAbs unimplemented."); | 2739 // Class for deferred case. |
| 2740 class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { |
| 2741 public: |
| 2742 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, |
| 2743 LUnaryMathOperation* instr) |
| 2744 : LDeferredCode(codegen), instr_(instr) { } |
| 2745 virtual void Generate() { |
| 2746 codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); |
| 2747 } |
| 2748 private: |
| 2749 LUnaryMathOperation* instr_; |
| 2750 }; |
| 2751 |
| 2752 ASSERT(instr->InputAt(0)->Equals(instr->result())); |
| 2753 Representation r = instr->hydrogen()->value()->representation(); |
| 2754 if (r.IsDouble()) { |
| 2755 DwVfpRegister input = ToDoubleRegister(instr->InputAt(0)); |
| 2756 __ vabs(input, input); |
| 2757 } else if (r.IsInteger32()) { |
| 2758 EmitIntegerMathAbs(instr); |
| 2759 } else { |
| 2760 // Representation is tagged. |
| 2761 DeferredMathAbsTaggedHeapNumber* deferred = |
| 2762 new DeferredMathAbsTaggedHeapNumber(this, instr); |
| 2763 Register input = ToRegister(instr->InputAt(0)); |
| 2764 // Smi check. |
| 2765 __ JumpIfNotSmi(input, deferred->entry()); |
| 2766 // If smi, handle it directly. |
| 2767 EmitIntegerMathAbs(instr); |
| 2768 __ bind(deferred->exit()); |
| 2769 } |
| 2770 } |
| 2771 |
| 2772 |
| 2773 // Truncates a double using a specific rounding mode. |
| 2774 // Clears the z flag (ne condition) if an overflow occurs. |
| 2775 void LCodeGen::EmitVFPTruncate(VFPRoundingMode rounding_mode, |
| 2776 SwVfpRegister result, |
| 2777 DwVfpRegister double_input, |
| 2778 Register scratch1, |
| 2779 Register scratch2) { |
| 2780 Register prev_fpscr = scratch1; |
| 2781 Register scratch = scratch2; |
| 2782 |
| 2783 // Set custom FPCSR: |
| 2784 // - Set rounding mode. |
| 2785 // - Clear vfp cumulative exception flags. |
| 2786 // - Make sure Flush-to-zero mode control bit is unset. |
| 2787 __ vmrs(prev_fpscr); |
| 2788 __ bic(scratch, prev_fpscr, Operand(kVFPExceptionMask | |
| 2789 kVFPRoundingModeMask | |
| 2790 kVFPFlushToZeroMask)); |
| 2791 __ orr(scratch, scratch, Operand(rounding_mode)); |
| 2792 __ vmsr(scratch); |
| 2793 |
| 2794 // Convert the argument to an integer. |
| 2795 __ vcvt_s32_f64(result, |
| 2796 double_input, |
| 2797 kFPSCRRounding); |
| 2798 |
| 2799 // Retrieve FPSCR. |
| 2800 __ vmrs(scratch); |
| 2801 // Restore FPSCR. |
| 2802 __ vmsr(prev_fpscr); |
| 2803 // Check for vfp exceptions. |
| 2804 __ tst(scratch, Operand(kVFPExceptionMask)); |
| 1689 } | 2805 } |
| 1690 | 2806 |
| 1691 | 2807 |
| 1692 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { | 2808 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
| 1693 Abort("DoMathFloor unimplemented."); | 2809 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
| 2810 Register result = ToRegister(instr->result()); |
| 2811 SwVfpRegister single_scratch = double_scratch0().low(); |
| 2812 Register scratch1 = scratch0(); |
| 2813 Register scratch2 = ToRegister(instr->TempAt(0)); |
| 2814 |
| 2815 EmitVFPTruncate(kRoundToMinusInf, |
| 2816 single_scratch, |
| 2817 input, |
| 2818 scratch1, |
| 2819 scratch2); |
| 2820 DeoptimizeIf(ne, instr->environment()); |
| 2821 |
| 2822 // Move the result back to general purpose register r0. |
| 2823 __ vmov(result, single_scratch); |
| 2824 |
| 2825 // Test for -0. |
| 2826 Label done; |
| 2827 __ cmp(result, Operand(0)); |
| 2828 __ b(ne, &done); |
| 2829 __ vmov(scratch1, input.high()); |
| 2830 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| 2831 DeoptimizeIf(ne, instr->environment()); |
| 2832 __ bind(&done); |
| 1694 } | 2833 } |
| 1695 | 2834 |
| 1696 | 2835 |
| 1697 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2836 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
| 1698 Abort("DoMathSqrt unimplemented."); | 2837 DoubleRegister input = ToDoubleRegister(instr->InputAt(0)); |
| 2838 ASSERT(ToDoubleRegister(instr->result()).is(input)); |
| 2839 __ vsqrt(input, input); |
| 1699 } | 2840 } |
| 1700 | 2841 |
| 1701 | 2842 |
| 1702 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { | 2843 void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) { |
| 1703 switch (instr->op()) { | 2844 switch (instr->op()) { |
| 1704 case kMathAbs: | 2845 case kMathAbs: |
| 1705 DoMathAbs(instr); | 2846 DoMathAbs(instr); |
| 1706 break; | 2847 break; |
| 1707 case kMathFloor: | 2848 case kMathFloor: |
| 1708 DoMathFloor(instr); | 2849 DoMathFloor(instr); |
| 1709 break; | 2850 break; |
| 1710 case kMathSqrt: | 2851 case kMathSqrt: |
| 1711 DoMathSqrt(instr); | 2852 DoMathSqrt(instr); |
| 1712 break; | 2853 break; |
| 1713 default: | 2854 default: |
| 1714 Abort("Unimplemented type of LUnaryMathOperation."); | 2855 Abort("Unimplemented type of LUnaryMathOperation."); |
| 1715 UNREACHABLE(); | 2856 UNREACHABLE(); |
| 1716 } | 2857 } |
| 1717 } | 2858 } |
| 1718 | 2859 |
| 1719 | 2860 |
| 1720 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | 2861 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { |
| 1721 Abort("DoCallKeyed unimplemented."); | 2862 ASSERT(ToRegister(instr->result()).is(r0)); |
| 2863 |
| 2864 int arity = instr->arity(); |
| 2865 Handle<Code> ic = StubCache::ComputeKeyedCallInitialize(arity, NOT_IN_LOOP); |
| 2866 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2867 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1722 } | 2868 } |
| 1723 | 2869 |
| 1724 | 2870 |
| 1725 void LCodeGen::DoCallNamed(LCallNamed* instr) { | 2871 void LCodeGen::DoCallNamed(LCallNamed* instr) { |
| 1726 ASSERT(ToRegister(instr->result()).is(r0)); | 2872 ASSERT(ToRegister(instr->result()).is(r0)); |
| 1727 | 2873 |
| 1728 int arity = instr->arity(); | 2874 int arity = instr->arity(); |
| 1729 Handle<Code> ic = StubCache::ComputeCallInitialize(arity, NOT_IN_LOOP); | 2875 Handle<Code> ic = StubCache::ComputeCallInitialize(arity, NOT_IN_LOOP); |
| 1730 __ mov(r2, Operand(instr->name())); | 2876 __ mov(r2, Operand(instr->name())); |
| 1731 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2877 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1732 // Restore context register. | 2878 // Restore context register. |
| 1733 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2879 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1734 } | 2880 } |
| 1735 | 2881 |
| 1736 | 2882 |
| 1737 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 2883 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
| 1738 ASSERT(ToRegister(instr->result()).is(r0)); | 2884 ASSERT(ToRegister(instr->result()).is(r0)); |
| 1739 | 2885 |
| 1740 int arity = instr->arity(); | 2886 int arity = instr->arity(); |
| 1741 CallFunctionStub stub(arity, NOT_IN_LOOP, RECEIVER_MIGHT_BE_VALUE); | 2887 CallFunctionStub stub(arity, NOT_IN_LOOP, RECEIVER_MIGHT_BE_VALUE); |
| 1742 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 2888 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1743 __ Drop(1); | 2889 __ Drop(1); |
| 1744 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2890 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1745 } | 2891 } |
| 1746 | 2892 |
| 1747 | 2893 |
| 1748 void LCodeGen::DoCallGlobal(LCallGlobal* instr) { | 2894 void LCodeGen::DoCallGlobal(LCallGlobal* instr) { |
| 1749 Abort("DoCallGlobal unimplemented."); | 2895 ASSERT(ToRegister(instr->result()).is(r0)); |
| 2896 |
| 2897 int arity = instr->arity(); |
| 2898 Handle<Code> ic = StubCache::ComputeCallInitialize(arity, NOT_IN_LOOP); |
| 2899 __ mov(r2, Operand(instr->name())); |
| 2900 CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr); |
| 2901 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1750 } | 2902 } |
| 1751 | 2903 |
| 1752 | 2904 |
| 1753 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { | 2905 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { |
| 1754 ASSERT(ToRegister(instr->result()).is(r0)); | 2906 ASSERT(ToRegister(instr->result()).is(r0)); |
| 1755 __ mov(r1, Operand(instr->target())); | 2907 __ mov(r1, Operand(instr->target())); |
| 1756 CallKnownFunction(instr->target(), instr->arity(), instr); | 2908 CallKnownFunction(instr->target(), instr->arity(), instr); |
| 1757 } | 2909 } |
| 1758 | 2910 |
| 1759 | 2911 |
| 1760 void LCodeGen::DoCallNew(LCallNew* instr) { | 2912 void LCodeGen::DoCallNew(LCallNew* instr) { |
| 1761 ASSERT(ToRegister(instr->input()).is(r1)); | 2913 ASSERT(ToRegister(instr->InputAt(0)).is(r1)); |
| 1762 ASSERT(ToRegister(instr->result()).is(r0)); | 2914 ASSERT(ToRegister(instr->result()).is(r0)); |
| 1763 | 2915 |
| 1764 Handle<Code> builtin(Builtins::builtin(Builtins::JSConstructCall)); | 2916 Handle<Code> builtin(Builtins::builtin(Builtins::JSConstructCall)); |
| 1765 __ mov(r0, Operand(instr->arity())); | 2917 __ mov(r0, Operand(instr->arity())); |
| 1766 CallCode(builtin, RelocInfo::CONSTRUCT_CALL, instr); | 2918 CallCode(builtin, RelocInfo::CONSTRUCT_CALL, instr); |
| 1767 } | 2919 } |
| 1768 | 2920 |
| 1769 | 2921 |
| 1770 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { | 2922 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { |
| 1771 CallRuntime(instr->function(), instr->arity(), instr); | 2923 CallRuntime(instr->function(), instr->arity(), instr); |
| 1772 } | 2924 } |
| 1773 | 2925 |
| 1774 | 2926 |
| 1775 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { | 2927 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { |
| 1776 Abort("DoStoreNamedField unimplemented."); | 2928 Register object = ToRegister(instr->object()); |
| 2929 Register value = ToRegister(instr->value()); |
| 2930 Register scratch = scratch0(); |
| 2931 int offset = instr->offset(); |
| 2932 |
| 2933 ASSERT(!object.is(value)); |
| 2934 |
| 2935 if (!instr->transition().is_null()) { |
| 2936 __ mov(scratch, Operand(instr->transition())); |
| 2937 __ str(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 2938 } |
| 2939 |
| 2940 // Do the store. |
| 2941 if (instr->is_in_object()) { |
| 2942 __ str(value, FieldMemOperand(object, offset)); |
| 2943 if (instr->needs_write_barrier()) { |
| 2944 // Update the write barrier for the object for in-object properties. |
| 2945 __ RecordWrite(object, Operand(offset), value, scratch); |
| 2946 } |
| 2947 } else { |
| 2948 __ ldr(scratch, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
| 2949 __ str(value, FieldMemOperand(scratch, offset)); |
| 2950 if (instr->needs_write_barrier()) { |
| 2951 // Update the write barrier for the properties array. |
| 2952 // object is used as a scratch register. |
| 2953 __ RecordWrite(scratch, Operand(offset), value, object); |
| 2954 } |
| 2955 } |
| 1777 } | 2956 } |
| 1778 | 2957 |
| 1779 | 2958 |
| 1780 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { | 2959 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { |
| 1781 ASSERT(ToRegister(instr->object()).is(r1)); | 2960 ASSERT(ToRegister(instr->object()).is(r1)); |
| 1782 ASSERT(ToRegister(instr->value()).is(r0)); | 2961 ASSERT(ToRegister(instr->value()).is(r0)); |
| 1783 | 2962 |
| 1784 // Name is always in r2. | 2963 // Name is always in r2. |
| 1785 __ mov(r2, Operand(instr->name())); | 2964 __ mov(r2, Operand(instr->name())); |
| 1786 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 2965 Handle<Code> ic(Builtins::builtin(info_->is_strict() |
| 2966 ? Builtins::StoreIC_Initialize_Strict |
| 2967 : Builtins::StoreIC_Initialize)); |
| 1787 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2968 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1788 } | 2969 } |
| 1789 | 2970 |
| 1790 | 2971 |
| 1791 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { | 2972 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { |
| 1792 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); | 2973 __ cmp(ToRegister(instr->index()), ToRegister(instr->length())); |
| 1793 DeoptimizeIf(hs, instr->environment()); | 2974 DeoptimizeIf(hs, instr->environment()); |
| 1794 } | 2975 } |
| 1795 | 2976 |
| 1796 | 2977 |
| 1797 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { | 2978 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
| 1798 Abort("DoStoreKeyedFastElement unimplemented."); | 2979 Register value = ToRegister(instr->value()); |
| 2980 Register elements = ToRegister(instr->object()); |
| 2981 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
| 2982 Register scratch = scratch0(); |
| 2983 |
| 2984 // Do the store. |
| 2985 if (instr->key()->IsConstantOperand()) { |
| 2986 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); |
| 2987 LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); |
| 2988 int offset = |
| 2989 ToInteger32(const_operand) * kPointerSize + FixedArray::kHeaderSize; |
| 2990 __ str(value, FieldMemOperand(elements, offset)); |
| 2991 } else { |
| 2992 __ add(scratch, elements, Operand(key, LSL, kPointerSizeLog2)); |
| 2993 __ str(value, FieldMemOperand(scratch, FixedArray::kHeaderSize)); |
| 2994 } |
| 2995 |
| 2996 if (instr->hydrogen()->NeedsWriteBarrier()) { |
| 2997 // Compute address of modified element and store it into key register. |
| 2998 __ add(key, scratch, Operand(FixedArray::kHeaderSize)); |
| 2999 __ RecordWrite(elements, key, value); |
| 3000 } |
| 1799 } | 3001 } |
| 1800 | 3002 |
| 1801 | 3003 |
| 1802 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 3004 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
| 1803 ASSERT(ToRegister(instr->object()).is(r2)); | 3005 ASSERT(ToRegister(instr->object()).is(r2)); |
| 1804 ASSERT(ToRegister(instr->key()).is(r1)); | 3006 ASSERT(ToRegister(instr->key()).is(r1)); |
| 1805 ASSERT(ToRegister(instr->value()).is(r0)); | 3007 ASSERT(ToRegister(instr->value()).is(r0)); |
| 1806 | 3008 |
| 1807 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 3009 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); |
| 1808 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3010 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1809 } | 3011 } |
| 1810 | 3012 |
| 1811 | 3013 |
| 3014 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { |
| 3015 class DeferredStringCharCodeAt: public LDeferredCode { |
| 3016 public: |
| 3017 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) |
| 3018 : LDeferredCode(codegen), instr_(instr) { } |
| 3019 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } |
| 3020 private: |
| 3021 LStringCharCodeAt* instr_; |
| 3022 }; |
| 3023 |
| 3024 Register scratch = scratch0(); |
| 3025 Register string = ToRegister(instr->string()); |
| 3026 Register index = no_reg; |
| 3027 int const_index = -1; |
| 3028 if (instr->index()->IsConstantOperand()) { |
| 3029 const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
| 3030 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
| 3031 if (!Smi::IsValid(const_index)) { |
| 3032 // Guaranteed to be out of bounds because of the assert above. |
| 3033 // So the bounds check that must dominate this instruction must |
| 3034 // have deoptimized already. |
| 3035 if (FLAG_debug_code) { |
| 3036 __ Abort("StringCharCodeAt: out of bounds index."); |
| 3037 } |
| 3038 // No code needs to be generated. |
| 3039 return; |
| 3040 } |
| 3041 } else { |
| 3042 index = ToRegister(instr->index()); |
| 3043 } |
| 3044 Register result = ToRegister(instr->result()); |
| 3045 |
| 3046 DeferredStringCharCodeAt* deferred = |
| 3047 new DeferredStringCharCodeAt(this, instr); |
| 3048 |
| 3049 Label flat_string, ascii_string, done; |
| 3050 |
| 3051 // Fetch the instance type of the receiver into result register. |
| 3052 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3053 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
| 3054 |
| 3055 // We need special handling for non-flat strings. |
| 3056 STATIC_ASSERT(kSeqStringTag == 0); |
| 3057 __ tst(result, Operand(kStringRepresentationMask)); |
| 3058 __ b(eq, &flat_string); |
| 3059 |
| 3060 // Handle non-flat strings. |
| 3061 __ tst(result, Operand(kIsConsStringMask)); |
| 3062 __ b(eq, deferred->entry()); |
| 3063 |
| 3064 // ConsString. |
| 3065 // Check whether the right hand side is the empty string (i.e. if |
| 3066 // this is really a flat string in a cons string). If that is not |
| 3067 // the case we would rather go to the runtime system now to flatten |
| 3068 // the string. |
| 3069 __ ldr(scratch, FieldMemOperand(string, ConsString::kSecondOffset)); |
| 3070 __ LoadRoot(ip, Heap::kEmptyStringRootIndex); |
| 3071 __ cmp(scratch, ip); |
| 3072 __ b(ne, deferred->entry()); |
| 3073 // Get the first of the two strings and load its instance type. |
| 3074 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset)); |
| 3075 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3076 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
| 3077 // If the first cons component is also non-flat, then go to runtime. |
| 3078 STATIC_ASSERT(kSeqStringTag == 0); |
| 3079 __ tst(result, Operand(kStringRepresentationMask)); |
| 3080 __ b(ne, deferred->entry()); |
| 3081 |
| 3082 // Check for 1-byte or 2-byte string. |
| 3083 __ bind(&flat_string); |
| 3084 STATIC_ASSERT(kAsciiStringTag != 0); |
| 3085 __ tst(result, Operand(kStringEncodingMask)); |
| 3086 __ b(ne, &ascii_string); |
| 3087 |
| 3088 // 2-byte string. |
| 3089 // Load the 2-byte character code into the result register. |
| 3090 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
| 3091 if (instr->index()->IsConstantOperand()) { |
| 3092 __ ldrh(result, |
| 3093 FieldMemOperand(string, |
| 3094 SeqTwoByteString::kHeaderSize + 2 * const_index)); |
| 3095 } else { |
| 3096 __ add(scratch, |
| 3097 string, |
| 3098 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 3099 __ ldrh(result, MemOperand(scratch, index, LSL, 1)); |
| 3100 } |
| 3101 __ jmp(&done); |
| 3102 |
| 3103 // ASCII string. |
| 3104 // Load the byte into the result register. |
| 3105 __ bind(&ascii_string); |
| 3106 if (instr->index()->IsConstantOperand()) { |
| 3107 __ ldrb(result, FieldMemOperand(string, |
| 3108 SeqAsciiString::kHeaderSize + const_index)); |
| 3109 } else { |
| 3110 __ add(scratch, |
| 3111 string, |
| 3112 Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); |
| 3113 __ ldrb(result, MemOperand(scratch, index)); |
| 3114 } |
| 3115 __ bind(&done); |
| 3116 __ bind(deferred->exit()); |
| 3117 } |
| 3118 |
| 3119 |
| 3120 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { |
| 3121 Register string = ToRegister(instr->string()); |
| 3122 Register result = ToRegister(instr->result()); |
| 3123 Register scratch = scratch0(); |
| 3124 |
| 3125 // TODO(3095996): Get rid of this. For now, we need to make the |
| 3126 // result register contain a valid pointer because it is already |
| 3127 // contained in the register pointer map. |
| 3128 __ mov(result, Operand(0)); |
| 3129 |
| 3130 __ PushSafepointRegisters(); |
| 3131 __ push(string); |
| 3132 // Push the index as a smi. This is safe because of the checks in |
| 3133 // DoStringCharCodeAt above. |
| 3134 if (instr->index()->IsConstantOperand()) { |
| 3135 int const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
| 3136 __ mov(scratch, Operand(Smi::FromInt(const_index))); |
| 3137 __ push(scratch); |
| 3138 } else { |
| 3139 Register index = ToRegister(instr->index()); |
| 3140 __ SmiTag(index); |
| 3141 __ push(index); |
| 3142 } |
| 3143 __ CallRuntimeSaveDoubles(Runtime::kStringCharCodeAt); |
| 3144 RecordSafepointWithRegisters( |
| 3145 instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex); |
| 3146 if (FLAG_debug_code) { |
| 3147 __ AbortIfNotSmi(r0); |
| 3148 } |
| 3149 __ SmiUntag(r0); |
| 3150 MemOperand result_stack_slot = masm()->SafepointRegisterSlot(result); |
| 3151 __ str(r0, result_stack_slot); |
| 3152 __ PopSafepointRegisters(); |
| 3153 } |
| 3154 |
| 3155 |
| 3156 void LCodeGen::DoStringLength(LStringLength* instr) { |
| 3157 Register string = ToRegister(instr->InputAt(0)); |
| 3158 Register result = ToRegister(instr->result()); |
| 3159 __ ldr(result, FieldMemOperand(string, String::kLengthOffset)); |
| 3160 } |
| 3161 |
| 3162 |
| 1812 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { | 3163 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { |
| 1813 Abort("DoInteger32ToDouble unimplemented."); | 3164 LOperand* input = instr->InputAt(0); |
| 3165 ASSERT(input->IsRegister() || input->IsStackSlot()); |
| 3166 LOperand* output = instr->result(); |
| 3167 ASSERT(output->IsDoubleRegister()); |
| 3168 SwVfpRegister single_scratch = double_scratch0().low(); |
| 3169 if (input->IsStackSlot()) { |
| 3170 Register scratch = scratch0(); |
| 3171 __ ldr(scratch, ToMemOperand(input)); |
| 3172 __ vmov(single_scratch, scratch); |
| 3173 } else { |
| 3174 __ vmov(single_scratch, ToRegister(input)); |
| 3175 } |
| 3176 __ vcvt_f64_s32(ToDoubleRegister(output), single_scratch); |
| 1814 } | 3177 } |
| 1815 | 3178 |
| 1816 | 3179 |
| 1817 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { | 3180 void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
| 1818 class DeferredNumberTagI: public LDeferredCode { | 3181 class DeferredNumberTagI: public LDeferredCode { |
| 1819 public: | 3182 public: |
| 1820 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) | 3183 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) |
| 1821 : LDeferredCode(codegen), instr_(instr) { } | 3184 : LDeferredCode(codegen), instr_(instr) { } |
| 1822 virtual void Generate() { codegen()->DoDeferredNumberTagI(instr_); } | 3185 virtual void Generate() { codegen()->DoDeferredNumberTagI(instr_); } |
| 1823 private: | 3186 private: |
| 1824 LNumberTagI* instr_; | 3187 LNumberTagI* instr_; |
| 1825 }; | 3188 }; |
| 1826 | 3189 |
| 1827 LOperand* input = instr->input(); | 3190 LOperand* input = instr->InputAt(0); |
| 1828 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 3191 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
| 1829 Register reg = ToRegister(input); | 3192 Register reg = ToRegister(input); |
| 1830 | 3193 |
| 1831 DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr); | 3194 DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr); |
| 1832 __ SmiTag(reg, SetCC); | 3195 __ SmiTag(reg, SetCC); |
| 1833 __ b(vs, deferred->entry()); | 3196 __ b(vs, deferred->entry()); |
| 1834 __ bind(deferred->exit()); | 3197 __ bind(deferred->exit()); |
| 1835 } | 3198 } |
| 1836 | 3199 |
| 1837 | 3200 |
| 1838 void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { | 3201 void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { |
| 1839 Label slow; | 3202 Label slow; |
| 1840 Register reg = ToRegister(instr->input()); | 3203 Register reg = ToRegister(instr->InputAt(0)); |
| 1841 DoubleRegister dbl_scratch = d0; | 3204 DoubleRegister dbl_scratch = d0; |
| 1842 SwVfpRegister flt_scratch = s0; | 3205 SwVfpRegister flt_scratch = s0; |
| 1843 | 3206 |
| 1844 // Preserve the value of all registers. | 3207 // Preserve the value of all registers. |
| 1845 __ PushSafepointRegisters(); | 3208 __ PushSafepointRegisters(); |
| 1846 | 3209 |
| 1847 // There was overflow, so bits 30 and 31 of the original integer | 3210 // There was overflow, so bits 30 and 31 of the original integer |
| 1848 // disagree. Try to allocate a heap number in new space and store | 3211 // disagree. Try to allocate a heap number in new space and store |
| 1849 // the value in there. If that fails, call the runtime system. | 3212 // the value in there. If that fails, call the runtime system. |
| 1850 Label done; | 3213 Label done; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 void LCodeGen::DoNumberTagD(LNumberTagD* instr) { | 3250 void LCodeGen::DoNumberTagD(LNumberTagD* instr) { |
| 1888 class DeferredNumberTagD: public LDeferredCode { | 3251 class DeferredNumberTagD: public LDeferredCode { |
| 1889 public: | 3252 public: |
| 1890 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) | 3253 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr) |
| 1891 : LDeferredCode(codegen), instr_(instr) { } | 3254 : LDeferredCode(codegen), instr_(instr) { } |
| 1892 virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); } | 3255 virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); } |
| 1893 private: | 3256 private: |
| 1894 LNumberTagD* instr_; | 3257 LNumberTagD* instr_; |
| 1895 }; | 3258 }; |
| 1896 | 3259 |
| 1897 DoubleRegister input_reg = ToDoubleRegister(instr->input()); | 3260 DoubleRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 1898 Register scratch = scratch0(); | 3261 Register scratch = scratch0(); |
| 1899 Register reg = ToRegister(instr->result()); | 3262 Register reg = ToRegister(instr->result()); |
| 1900 Register temp1 = ToRegister(instr->temp1()); | 3263 Register temp1 = ToRegister(instr->TempAt(0)); |
| 1901 Register temp2 = ToRegister(instr->temp2()); | 3264 Register temp2 = ToRegister(instr->TempAt(1)); |
| 1902 | 3265 |
| 1903 DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr); | 3266 DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr); |
| 1904 if (FLAG_inline_new) { | 3267 if (FLAG_inline_new) { |
| 1905 __ LoadRoot(scratch, Heap::kHeapNumberMapRootIndex); | 3268 __ LoadRoot(scratch, Heap::kHeapNumberMapRootIndex); |
| 1906 __ AllocateHeapNumber(reg, temp1, temp2, scratch, deferred->entry()); | 3269 __ AllocateHeapNumber(reg, temp1, temp2, scratch, deferred->entry()); |
| 1907 } else { | 3270 } else { |
| 1908 __ jmp(deferred->entry()); | 3271 __ jmp(deferred->entry()); |
| 1909 } | 3272 } |
| 1910 __ bind(deferred->exit()); | 3273 __ bind(deferred->exit()); |
| 1911 __ sub(ip, reg, Operand(kHeapObjectTag)); | 3274 __ sub(ip, reg, Operand(kHeapObjectTag)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1924 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | 3287 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
| 1925 RecordSafepointWithRegisters( | 3288 RecordSafepointWithRegisters( |
| 1926 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); | 3289 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
| 1927 int reg_stack_index = __ SafepointRegisterStackIndex(reg.code()); | 3290 int reg_stack_index = __ SafepointRegisterStackIndex(reg.code()); |
| 1928 __ str(r0, MemOperand(sp, reg_stack_index * kPointerSize)); | 3291 __ str(r0, MemOperand(sp, reg_stack_index * kPointerSize)); |
| 1929 __ PopSafepointRegisters(); | 3292 __ PopSafepointRegisters(); |
| 1930 } | 3293 } |
| 1931 | 3294 |
| 1932 | 3295 |
| 1933 void LCodeGen::DoSmiTag(LSmiTag* instr) { | 3296 void LCodeGen::DoSmiTag(LSmiTag* instr) { |
| 1934 LOperand* input = instr->input(); | 3297 LOperand* input = instr->InputAt(0); |
| 1935 ASSERT(input->IsRegister() && input->Equals(instr->result())); | 3298 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
| 1936 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); | 3299 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); |
| 1937 __ SmiTag(ToRegister(input)); | 3300 __ SmiTag(ToRegister(input)); |
| 1938 } | 3301 } |
| 1939 | 3302 |
| 1940 | 3303 |
| 1941 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { | 3304 void LCodeGen::DoSmiUntag(LSmiUntag* instr) { |
| 1942 Abort("DoSmiUntag unimplemented."); | 3305 LOperand* input = instr->InputAt(0); |
| 3306 ASSERT(input->IsRegister() && input->Equals(instr->result())); |
| 3307 if (instr->needs_check()) { |
| 3308 __ tst(ToRegister(input), Operand(kSmiTagMask)); |
| 3309 DeoptimizeIf(ne, instr->environment()); |
| 3310 } |
| 3311 __ SmiUntag(ToRegister(input)); |
| 1943 } | 3312 } |
| 1944 | 3313 |
| 1945 | 3314 |
| 1946 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3315 void LCodeGen::EmitNumberUntagD(Register input_reg, |
| 1947 DoubleRegister result_reg, | 3316 DoubleRegister result_reg, |
| 1948 LEnvironment* env) { | 3317 LEnvironment* env) { |
| 1949 Register scratch = scratch0(); | 3318 Register scratch = scratch0(); |
| 1950 SwVfpRegister flt_scratch = s0; | 3319 SwVfpRegister flt_scratch = s0; |
| 1951 ASSERT(!result_reg.is(d0)); | 3320 ASSERT(!result_reg.is(d0)); |
| 1952 | 3321 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) | 3362 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) |
| 1994 : LDeferredCode(codegen), instr_(instr) { } | 3363 : LDeferredCode(codegen), instr_(instr) { } |
| 1995 virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); } | 3364 virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); } |
| 1996 private: | 3365 private: |
| 1997 LTaggedToI* instr_; | 3366 LTaggedToI* instr_; |
| 1998 }; | 3367 }; |
| 1999 | 3368 |
| 2000 | 3369 |
| 2001 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 3370 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
| 2002 Label done; | 3371 Label done; |
| 2003 Register input_reg = ToRegister(instr->input()); | 3372 Register input_reg = ToRegister(instr->InputAt(0)); |
| 2004 Register scratch = scratch0(); | 3373 Register scratch = scratch0(); |
| 2005 DoubleRegister dbl_scratch = d0; | 3374 DoubleRegister dbl_scratch = d0; |
| 2006 SwVfpRegister flt_scratch = s0; | 3375 SwVfpRegister flt_scratch = s0; |
| 2007 DoubleRegister dbl_tmp = ToDoubleRegister(instr->temp()); | 3376 DoubleRegister dbl_tmp = ToDoubleRegister(instr->TempAt(0)); |
| 2008 | 3377 |
| 2009 // Heap number map check. | 3378 // Heap number map check. |
| 2010 __ ldr(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 3379 __ ldr(scratch, FieldMemOperand(input_reg, HeapObject::kMapOffset)); |
| 2011 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 3380 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 2012 __ cmp(scratch, Operand(ip)); | 3381 __ cmp(scratch, Operand(ip)); |
| 2013 | 3382 |
| 2014 if (instr->truncating()) { | 3383 if (instr->truncating()) { |
| 2015 Label heap_number; | 3384 Label heap_number; |
| 2016 __ b(eq, &heap_number); | 3385 __ b(eq, &heap_number); |
| 2017 // Check for undefined. Undefined is converted to zero for truncating | 3386 // Check for undefined. Undefined is converted to zero for truncating |
| 2018 // conversions. | 3387 // conversions. |
| 2019 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 3388 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 2020 __ cmp(input_reg, Operand(ip)); | 3389 __ cmp(input_reg, Operand(ip)); |
| 2021 DeoptimizeIf(ne, instr->environment()); | 3390 DeoptimizeIf(ne, instr->environment()); |
| 2022 __ mov(input_reg, Operand(0)); | 3391 __ mov(input_reg, Operand(0)); |
| 2023 __ b(&done); | 3392 __ b(&done); |
| 2024 | 3393 |
| 2025 __ bind(&heap_number); | 3394 __ bind(&heap_number); |
| 2026 __ sub(ip, input_reg, Operand(kHeapObjectTag)); | 3395 __ sub(ip, input_reg, Operand(kHeapObjectTag)); |
| 2027 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset); | 3396 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset); |
| 2028 __ vcmp(dbl_tmp, 0.0); // Sets overflow bit if NaN. | 3397 __ vcmp(dbl_tmp, 0.0); // Sets overflow bit in FPSCR flags if NaN. |
| 2029 __ vcvt_s32_f64(flt_scratch, dbl_tmp); | 3398 __ vcvt_s32_f64(flt_scratch, dbl_tmp); |
| 2030 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion. | 3399 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion. |
| 2031 __ vmrs(pc); // Move vector status bits to normal status bits. | 3400 __ vmrs(pc); // Move vector status bits to normal status bits. |
| 2032 // Overflow bit is set if dbl_tmp is Nan. | 3401 // Overflow bit is set if dbl_tmp is Nan. |
| 2033 __ cmn(input_reg, Operand(1), vc); // 0x7fffffff + 1 -> overflow. | 3402 __ cmn(input_reg, Operand(1), vc); // 0x7fffffff + 1 -> overflow. |
| 2034 __ cmp(input_reg, Operand(1), vc); // 0x80000000 - 1 -> overflow. | 3403 __ cmp(input_reg, Operand(1), vc); // 0x80000000 - 1 -> overflow. |
| 2035 DeoptimizeIf(vs, instr->environment()); // Saturation may have occured. | 3404 DeoptimizeIf(vs, instr->environment()); // Saturation may have occured. |
| 2036 | 3405 |
| 2037 } else { | 3406 } else { |
| 2038 // Deoptimize if we don't have a heap number. | 3407 // Deoptimize if we don't have a heap number. |
| 2039 DeoptimizeIf(ne, instr->environment()); | 3408 DeoptimizeIf(ne, instr->environment()); |
| 2040 | 3409 |
| 2041 __ sub(ip, input_reg, Operand(kHeapObjectTag)); | 3410 __ sub(ip, input_reg, Operand(kHeapObjectTag)); |
| 2042 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset); | 3411 __ vldr(dbl_tmp, ip, HeapNumber::kValueOffset); |
| 2043 __ vcvt_s32_f64(flt_scratch, dbl_tmp); | 3412 __ vcvt_s32_f64(flt_scratch, dbl_tmp); |
| 2044 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion. | 3413 __ vmov(input_reg, flt_scratch); // 32-bit result of conversion. |
| 2045 // Non-truncating conversion means that we cannot lose bits, so we convert | 3414 // Non-truncating conversion means that we cannot lose bits, so we convert |
| 2046 // back to check; note that using non-overlapping s and d regs would be | 3415 // back to check; note that using non-overlapping s and d regs would be |
| 2047 // slightly faster. | 3416 // slightly faster. |
| 2048 __ vcvt_f64_s32(dbl_scratch, flt_scratch); | 3417 __ vcvt_f64_s32(dbl_scratch, flt_scratch); |
| 2049 __ vcmp(dbl_scratch, dbl_tmp); | 3418 __ VFPCompareAndSetFlags(dbl_scratch, dbl_tmp); |
| 2050 __ vmrs(pc); // Move vector status bits to normal status bits. | |
| 2051 DeoptimizeIf(ne, instr->environment()); // Not equal or unordered. | 3419 DeoptimizeIf(ne, instr->environment()); // Not equal or unordered. |
| 2052 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3420 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 2053 __ tst(input_reg, Operand(input_reg)); | 3421 __ tst(input_reg, Operand(input_reg)); |
| 2054 __ b(ne, &done); | 3422 __ b(ne, &done); |
| 2055 __ vmov(lr, ip, dbl_tmp); | 3423 __ vmov(lr, ip, dbl_tmp); |
| 2056 __ tst(ip, Operand(1 << 31)); // Test sign bit. | 3424 __ tst(ip, Operand(1 << 31)); // Test sign bit. |
| 2057 DeoptimizeIf(ne, instr->environment()); | 3425 DeoptimizeIf(ne, instr->environment()); |
| 2058 } | 3426 } |
| 2059 } | 3427 } |
| 2060 __ bind(&done); | 3428 __ bind(&done); |
| 2061 } | 3429 } |
| 2062 | 3430 |
| 2063 | 3431 |
| 2064 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 3432 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
| 2065 LOperand* input = instr->input(); | 3433 LOperand* input = instr->InputAt(0); |
| 2066 ASSERT(input->IsRegister()); | 3434 ASSERT(input->IsRegister()); |
| 2067 ASSERT(input->Equals(instr->result())); | 3435 ASSERT(input->Equals(instr->result())); |
| 2068 | 3436 |
| 2069 Register input_reg = ToRegister(input); | 3437 Register input_reg = ToRegister(input); |
| 2070 | 3438 |
| 2071 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); | 3439 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); |
| 2072 | 3440 |
| 2073 // Smi check. | 3441 // Smi check. |
| 2074 __ tst(input_reg, Operand(kSmiTagMask)); | 3442 __ tst(input_reg, Operand(kSmiTagMask)); |
| 2075 __ b(ne, deferred->entry()); | 3443 __ b(ne, deferred->entry()); |
| 2076 | 3444 |
| 2077 // Smi to int32 conversion | 3445 // Smi to int32 conversion |
| 2078 __ SmiUntag(input_reg); // Untag smi. | 3446 __ SmiUntag(input_reg); // Untag smi. |
| 2079 | 3447 |
| 2080 __ bind(deferred->exit()); | 3448 __ bind(deferred->exit()); |
| 2081 } | 3449 } |
| 2082 | 3450 |
| 2083 | 3451 |
| 2084 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 3452 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
| 2085 LOperand* input = instr->input(); | 3453 LOperand* input = instr->InputAt(0); |
| 2086 ASSERT(input->IsRegister()); | 3454 ASSERT(input->IsRegister()); |
| 2087 LOperand* result = instr->result(); | 3455 LOperand* result = instr->result(); |
| 2088 ASSERT(result->IsDoubleRegister()); | 3456 ASSERT(result->IsDoubleRegister()); |
| 2089 | 3457 |
| 2090 Register input_reg = ToRegister(input); | 3458 Register input_reg = ToRegister(input); |
| 2091 DoubleRegister result_reg = ToDoubleRegister(result); | 3459 DoubleRegister result_reg = ToDoubleRegister(result); |
| 2092 | 3460 |
| 2093 EmitNumberUntagD(input_reg, result_reg, instr->environment()); | 3461 EmitNumberUntagD(input_reg, result_reg, instr->environment()); |
| 2094 } | 3462 } |
| 2095 | 3463 |
| 2096 | 3464 |
| 2097 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 3465 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
| 2098 Abort("DoDoubleToI unimplemented."); | 3466 LOperand* input = instr->InputAt(0); |
| 3467 ASSERT(input->IsDoubleRegister()); |
| 3468 LOperand* result = instr->result(); |
| 3469 ASSERT(result->IsRegister()); |
| 3470 |
| 3471 DoubleRegister double_input = ToDoubleRegister(input); |
| 3472 Register result_reg = ToRegister(result); |
| 3473 SwVfpRegister single_scratch = double_scratch0().low(); |
| 3474 Register scratch1 = scratch0(); |
| 3475 Register scratch2 = ToRegister(instr->TempAt(0)); |
| 3476 |
| 3477 VFPRoundingMode rounding_mode = instr->truncating() ? kRoundToMinusInf |
| 3478 : kRoundToNearest; |
| 3479 |
| 3480 EmitVFPTruncate(rounding_mode, |
| 3481 single_scratch, |
| 3482 double_input, |
| 3483 scratch1, |
| 3484 scratch2); |
| 3485 // Deoptimize if we had a vfp invalid exception. |
| 3486 DeoptimizeIf(ne, instr->environment()); |
| 3487 // Retrieve the result. |
| 3488 __ vmov(result_reg, single_scratch); |
| 3489 |
| 3490 if (instr->truncating() && |
| 3491 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 3492 Label done; |
| 3493 __ cmp(result_reg, Operand(0)); |
| 3494 __ b(ne, &done); |
| 3495 // Check for -0. |
| 3496 __ vmov(scratch1, double_input.high()); |
| 3497 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| 3498 DeoptimizeIf(ne, instr->environment()); |
| 3499 |
| 3500 __ bind(&done); |
| 3501 } |
| 2099 } | 3502 } |
| 2100 | 3503 |
| 2101 | 3504 |
| 2102 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { | 3505 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { |
| 2103 LOperand* input = instr->input(); | 3506 LOperand* input = instr->InputAt(0); |
| 2104 ASSERT(input->IsRegister()); | 3507 ASSERT(input->IsRegister()); |
| 2105 __ tst(ToRegister(input), Operand(kSmiTagMask)); | 3508 __ tst(ToRegister(input), Operand(kSmiTagMask)); |
| 2106 DeoptimizeIf(instr->condition(), instr->environment()); | 3509 DeoptimizeIf(instr->condition(), instr->environment()); |
| 2107 } | 3510 } |
| 2108 | 3511 |
| 2109 | 3512 |
| 2110 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { | 3513 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { |
| 2111 Abort("DoCheckInstanceType unimplemented."); | 3514 Register input = ToRegister(instr->InputAt(0)); |
| 3515 Register scratch = scratch0(); |
| 3516 InstanceType first = instr->hydrogen()->first(); |
| 3517 InstanceType last = instr->hydrogen()->last(); |
| 3518 |
| 3519 __ ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); |
| 3520 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
| 3521 __ cmp(scratch, Operand(first)); |
| 3522 |
| 3523 // If there is only one type in the interval check for equality. |
| 3524 if (first == last) { |
| 3525 DeoptimizeIf(ne, instr->environment()); |
| 3526 } else { |
| 3527 DeoptimizeIf(lo, instr->environment()); |
| 3528 // Omit check for the last type. |
| 3529 if (last != LAST_TYPE) { |
| 3530 __ cmp(scratch, Operand(last)); |
| 3531 DeoptimizeIf(hi, instr->environment()); |
| 3532 } |
| 3533 } |
| 2112 } | 3534 } |
| 2113 | 3535 |
| 2114 | 3536 |
| 2115 void LCodeGen::DoCheckFunction(LCheckFunction* instr) { | 3537 void LCodeGen::DoCheckFunction(LCheckFunction* instr) { |
| 2116 ASSERT(instr->input()->IsRegister()); | 3538 ASSERT(instr->InputAt(0)->IsRegister()); |
| 2117 Register reg = ToRegister(instr->input()); | 3539 Register reg = ToRegister(instr->InputAt(0)); |
| 2118 __ cmp(reg, Operand(instr->hydrogen()->target())); | 3540 __ cmp(reg, Operand(instr->hydrogen()->target())); |
| 2119 DeoptimizeIf(ne, instr->environment()); | 3541 DeoptimizeIf(ne, instr->environment()); |
| 2120 } | 3542 } |
| 2121 | 3543 |
| 2122 | 3544 |
| 2123 void LCodeGen::DoCheckMap(LCheckMap* instr) { | 3545 void LCodeGen::DoCheckMap(LCheckMap* instr) { |
| 2124 Register scratch = scratch0(); | 3546 Register scratch = scratch0(); |
| 2125 LOperand* input = instr->input(); | 3547 LOperand* input = instr->InputAt(0); |
| 2126 ASSERT(input->IsRegister()); | 3548 ASSERT(input->IsRegister()); |
| 2127 Register reg = ToRegister(input); | 3549 Register reg = ToRegister(input); |
| 2128 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); | 3550 __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 2129 __ cmp(scratch, Operand(instr->hydrogen()->map())); | 3551 __ cmp(scratch, Operand(instr->hydrogen()->map())); |
| 2130 DeoptimizeIf(ne, instr->environment()); | 3552 DeoptimizeIf(ne, instr->environment()); |
| 2131 } | 3553 } |
| 2132 | 3554 |
| 2133 | 3555 |
| 2134 void LCodeGen::LoadPrototype(Register result, | 3556 void LCodeGen::LoadHeapObject(Register result, |
| 2135 Handle<JSObject> prototype) { | 3557 Handle<HeapObject> object) { |
| 2136 if (Heap::InNewSpace(*prototype)) { | 3558 if (Heap::InNewSpace(*object)) { |
| 2137 Handle<JSGlobalPropertyCell> cell = | 3559 Handle<JSGlobalPropertyCell> cell = |
| 2138 Factory::NewJSGlobalPropertyCell(prototype); | 3560 Factory::NewJSGlobalPropertyCell(object); |
| 2139 __ mov(result, Operand(cell)); | 3561 __ mov(result, Operand(cell)); |
| 3562 __ ldr(result, FieldMemOperand(result, JSGlobalPropertyCell::kValueOffset)); |
| 2140 } else { | 3563 } else { |
| 2141 __ mov(result, Operand(prototype)); | 3564 __ mov(result, Operand(object)); |
| 2142 } | 3565 } |
| 2143 } | 3566 } |
| 2144 | 3567 |
| 2145 | 3568 |
| 2146 void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { | 3569 void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { |
| 2147 Register temp1 = ToRegister(instr->temp1()); | 3570 Register temp1 = ToRegister(instr->TempAt(0)); |
| 2148 Register temp2 = ToRegister(instr->temp2()); | 3571 Register temp2 = ToRegister(instr->TempAt(1)); |
| 2149 | 3572 |
| 2150 Handle<JSObject> holder = instr->holder(); | 3573 Handle<JSObject> holder = instr->holder(); |
| 2151 Handle<Map> receiver_map = instr->receiver_map(); | 3574 Handle<JSObject> current_prototype = instr->prototype(); |
| 2152 Handle<JSObject> current_prototype(JSObject::cast(receiver_map->prototype())); | |
| 2153 | 3575 |
| 2154 // Load prototype object. | 3576 // Load prototype object. |
| 2155 LoadPrototype(temp1, current_prototype); | 3577 LoadHeapObject(temp1, current_prototype); |
| 2156 | 3578 |
| 2157 // Check prototype maps up to the holder. | 3579 // Check prototype maps up to the holder. |
| 2158 while (!current_prototype.is_identical_to(holder)) { | 3580 while (!current_prototype.is_identical_to(holder)) { |
| 2159 __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); | 3581 __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); |
| 2160 __ cmp(temp2, Operand(Handle<Map>(current_prototype->map()))); | 3582 __ cmp(temp2, Operand(Handle<Map>(current_prototype->map()))); |
| 2161 DeoptimizeIf(ne, instr->environment()); | 3583 DeoptimizeIf(ne, instr->environment()); |
| 2162 current_prototype = | 3584 current_prototype = |
| 2163 Handle<JSObject>(JSObject::cast(current_prototype->GetPrototype())); | 3585 Handle<JSObject>(JSObject::cast(current_prototype->GetPrototype())); |
| 2164 // Load next prototype object. | 3586 // Load next prototype object. |
| 2165 LoadPrototype(temp1, current_prototype); | 3587 LoadHeapObject(temp1, current_prototype); |
| 2166 } | 3588 } |
| 2167 | 3589 |
| 2168 // Check the holder map. | 3590 // Check the holder map. |
| 2169 __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); | 3591 __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); |
| 2170 __ cmp(temp2, Operand(Handle<Map>(current_prototype->map()))); | 3592 __ cmp(temp2, Operand(Handle<Map>(current_prototype->map()))); |
| 2171 DeoptimizeIf(ne, instr->environment()); | 3593 DeoptimizeIf(ne, instr->environment()); |
| 2172 } | 3594 } |
| 2173 | 3595 |
| 2174 | 3596 |
| 2175 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 3597 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 // Pick the right runtime function to call. | 3633 // Pick the right runtime function to call. |
| 2212 if (instr->hydrogen()->depth() > 1) { | 3634 if (instr->hydrogen()->depth() > 1) { |
| 2213 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); | 3635 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); |
| 2214 } else { | 3636 } else { |
| 2215 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); | 3637 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); |
| 2216 } | 3638 } |
| 2217 } | 3639 } |
| 2218 | 3640 |
| 2219 | 3641 |
| 2220 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { | 3642 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { |
| 2221 Abort("DoRegExpLiteral unimplemented."); | 3643 Label materialized; |
| 3644 // Registers will be used as follows: |
| 3645 // r3 = JS function. |
| 3646 // r7 = literals array. |
| 3647 // r1 = regexp literal. |
| 3648 // r0 = regexp literal clone. |
| 3649 // r2 and r4-r6 are used as temporaries. |
| 3650 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 3651 __ ldr(r7, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
| 3652 int literal_offset = FixedArray::kHeaderSize + |
| 3653 instr->hydrogen()->literal_index() * kPointerSize; |
| 3654 __ ldr(r1, FieldMemOperand(r7, literal_offset)); |
| 3655 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 3656 __ cmp(r1, ip); |
| 3657 __ b(ne, &materialized); |
| 3658 |
| 3659 // Create regexp literal using runtime function |
| 3660 // Result will be in r0. |
| 3661 __ mov(r6, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); |
| 3662 __ mov(r5, Operand(instr->hydrogen()->pattern())); |
| 3663 __ mov(r4, Operand(instr->hydrogen()->flags())); |
| 3664 __ Push(r7, r6, r5, r4); |
| 3665 CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr); |
| 3666 __ mov(r1, r0); |
| 3667 |
| 3668 __ bind(&materialized); |
| 3669 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; |
| 3670 Label allocated, runtime_allocate; |
| 3671 |
| 3672 __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); |
| 3673 __ jmp(&allocated); |
| 3674 |
| 3675 __ bind(&runtime_allocate); |
| 3676 __ mov(r0, Operand(Smi::FromInt(size))); |
| 3677 __ Push(r1, r0); |
| 3678 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); |
| 3679 __ pop(r1); |
| 3680 |
| 3681 __ bind(&allocated); |
| 3682 // Copy the content into the newly allocated memory. |
| 3683 // (Unroll copy loop once for better throughput). |
| 3684 for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) { |
| 3685 __ ldr(r3, FieldMemOperand(r1, i)); |
| 3686 __ ldr(r2, FieldMemOperand(r1, i + kPointerSize)); |
| 3687 __ str(r3, FieldMemOperand(r0, i)); |
| 3688 __ str(r2, FieldMemOperand(r0, i + kPointerSize)); |
| 3689 } |
| 3690 if ((size % (2 * kPointerSize)) != 0) { |
| 3691 __ ldr(r3, FieldMemOperand(r1, size - kPointerSize)); |
| 3692 __ str(r3, FieldMemOperand(r0, size - kPointerSize)); |
| 3693 } |
| 2222 } | 3694 } |
| 2223 | 3695 |
| 2224 | 3696 |
| 2225 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { | 3697 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { |
| 2226 Abort("DoFunctionLiteral unimplemented."); | 3698 // Use the fast case closure allocation code that allocates in new |
| 3699 // space for nested functions that don't need literals cloning. |
| 3700 Handle<SharedFunctionInfo> shared_info = instr->shared_info(); |
| 3701 bool pretenure = instr->hydrogen()->pretenure(); |
| 3702 if (shared_info->num_literals() == 0 && !pretenure) { |
| 3703 FastNewClosureStub stub; |
| 3704 __ mov(r1, Operand(shared_info)); |
| 3705 __ push(r1); |
| 3706 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 3707 } else { |
| 3708 __ mov(r2, Operand(shared_info)); |
| 3709 __ mov(r1, Operand(pretenure |
| 3710 ? Factory::true_value() |
| 3711 : Factory::false_value())); |
| 3712 __ Push(cp, r2, r1); |
| 3713 CallRuntime(Runtime::kNewClosure, 3, instr); |
| 3714 } |
| 2227 } | 3715 } |
| 2228 | 3716 |
| 2229 | 3717 |
| 2230 void LCodeGen::DoTypeof(LTypeof* instr) { | 3718 void LCodeGen::DoTypeof(LTypeof* instr) { |
| 2231 Abort("DoTypeof unimplemented."); | 3719 Register input = ToRegister(instr->InputAt(0)); |
| 3720 __ push(input); |
| 3721 CallRuntime(Runtime::kTypeof, 1, instr); |
| 2232 } | 3722 } |
| 2233 | 3723 |
| 2234 | 3724 |
| 2235 void LCodeGen::DoTypeofIs(LTypeofIs* instr) { | 3725 void LCodeGen::DoTypeofIs(LTypeofIs* instr) { |
| 2236 Abort("DoTypeofIs unimplemented."); | 3726 Register input = ToRegister(instr->InputAt(0)); |
| 3727 Register result = ToRegister(instr->result()); |
| 3728 Label true_label; |
| 3729 Label false_label; |
| 3730 Label done; |
| 3731 |
| 3732 Condition final_branch_condition = EmitTypeofIs(&true_label, |
| 3733 &false_label, |
| 3734 input, |
| 3735 instr->type_literal()); |
| 3736 __ b(final_branch_condition, &true_label); |
| 3737 __ bind(&false_label); |
| 3738 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 3739 __ b(&done); |
| 3740 |
| 3741 __ bind(&true_label); |
| 3742 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 3743 |
| 3744 __ bind(&done); |
| 2237 } | 3745 } |
| 2238 | 3746 |
| 2239 | 3747 |
| 2240 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) { | 3748 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) { |
| 2241 Register input = ToRegister(instr->input()); | 3749 Register input = ToRegister(instr->InputAt(0)); |
| 2242 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 3750 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 2243 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 3751 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 2244 Label* true_label = chunk_->GetAssemblyLabel(true_block); | 3752 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
| 2245 Label* false_label = chunk_->GetAssemblyLabel(false_block); | 3753 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 2246 | 3754 |
| 2247 Condition final_branch_condition = EmitTypeofIs(true_label, | 3755 Condition final_branch_condition = EmitTypeofIs(true_label, |
| 2248 false_label, | 3756 false_label, |
| 2249 input, | 3757 input, |
| 2250 instr->type_literal()); | 3758 instr->type_literal()); |
| 2251 | 3759 |
| 2252 EmitBranch(true_block, false_block, final_branch_condition); | 3760 EmitBranch(true_block, false_block, final_branch_condition); |
| 2253 } | 3761 } |
| 2254 | 3762 |
| 2255 | 3763 |
| 2256 Condition LCodeGen::EmitTypeofIs(Label* true_label, | 3764 Condition LCodeGen::EmitTypeofIs(Label* true_label, |
| 2257 Label* false_label, | 3765 Label* false_label, |
| 2258 Register input, | 3766 Register input, |
| 2259 Handle<String> type_name) { | 3767 Handle<String> type_name) { |
| 2260 Condition final_branch_condition = no_condition; | 3768 Condition final_branch_condition = kNoCondition; |
| 2261 Register scratch = scratch0(); | 3769 Register scratch = scratch0(); |
| 2262 if (type_name->Equals(Heap::number_symbol())) { | 3770 if (type_name->Equals(Heap::number_symbol())) { |
| 2263 __ tst(input, Operand(kSmiTagMask)); | 3771 __ tst(input, Operand(kSmiTagMask)); |
| 2264 __ b(eq, true_label); | 3772 __ b(eq, true_label); |
| 2265 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); | 3773 __ ldr(input, FieldMemOperand(input, HeapObject::kMapOffset)); |
| 2266 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 3774 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 2267 __ cmp(input, Operand(ip)); | 3775 __ cmp(input, Operand(ip)); |
| 2268 final_branch_condition = eq; | 3776 final_branch_condition = eq; |
| 2269 | 3777 |
| 2270 } else if (type_name->Equals(Heap::string_symbol())) { | 3778 } else if (type_name->Equals(Heap::string_symbol())) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 } else { | 3836 } else { |
| 2329 final_branch_condition = ne; | 3837 final_branch_condition = ne; |
| 2330 __ b(false_label); | 3838 __ b(false_label); |
| 2331 // A dead branch instruction will be generated after this point. | 3839 // A dead branch instruction will be generated after this point. |
| 2332 } | 3840 } |
| 2333 | 3841 |
| 2334 return final_branch_condition; | 3842 return final_branch_condition; |
| 2335 } | 3843 } |
| 2336 | 3844 |
| 2337 | 3845 |
| 3846 void LCodeGen::DoIsConstructCall(LIsConstructCall* instr) { |
| 3847 Register result = ToRegister(instr->result()); |
| 3848 Label true_label; |
| 3849 Label false_label; |
| 3850 Label done; |
| 3851 |
| 3852 EmitIsConstructCall(result, scratch0()); |
| 3853 __ b(eq, &true_label); |
| 3854 |
| 3855 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 3856 __ b(&done); |
| 3857 |
| 3858 |
| 3859 __ bind(&true_label); |
| 3860 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 3861 |
| 3862 __ bind(&done); |
| 3863 } |
| 3864 |
| 3865 |
| 3866 void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) { |
| 3867 Register temp1 = ToRegister(instr->TempAt(0)); |
| 3868 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 3869 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 3870 |
| 3871 EmitIsConstructCall(temp1, scratch0()); |
| 3872 EmitBranch(true_block, false_block, eq); |
| 3873 } |
| 3874 |
| 3875 |
| 3876 void LCodeGen::EmitIsConstructCall(Register temp1, Register temp2) { |
| 3877 ASSERT(!temp1.is(temp2)); |
| 3878 // Get the frame pointer for the calling frame. |
| 3879 __ ldr(temp1, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 3880 |
| 3881 // Skip the arguments adaptor frame if it exists. |
| 3882 Label check_frame_marker; |
| 3883 __ ldr(temp2, MemOperand(temp1, StandardFrameConstants::kContextOffset)); |
| 3884 __ cmp(temp2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 3885 __ b(ne, &check_frame_marker); |
| 3886 __ ldr(temp1, MemOperand(temp1, StandardFrameConstants::kCallerFPOffset)); |
| 3887 |
| 3888 // Check the marker in the calling frame. |
| 3889 __ bind(&check_frame_marker); |
| 3890 __ ldr(temp1, MemOperand(temp1, StandardFrameConstants::kMarkerOffset)); |
| 3891 __ cmp(temp1, Operand(Smi::FromInt(StackFrame::CONSTRUCT))); |
| 3892 } |
| 3893 |
| 3894 |
| 2338 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { | 3895 void LCodeGen::DoLazyBailout(LLazyBailout* instr) { |
| 2339 // No code for lazy bailout instruction. Used to capture environment after a | 3896 // No code for lazy bailout instruction. Used to capture environment after a |
| 2340 // call for populating the safepoint data with deoptimization data. | 3897 // call for populating the safepoint data with deoptimization data. |
| 2341 } | 3898 } |
| 2342 | 3899 |
| 2343 | 3900 |
| 2344 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 3901 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
| 2345 DeoptimizeIf(no_condition, instr->environment()); | 3902 DeoptimizeIf(al, instr->environment()); |
| 2346 } | 3903 } |
| 2347 | 3904 |
| 2348 | 3905 |
| 2349 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { | 3906 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { |
| 2350 Abort("DoDeleteProperty unimplemented."); | 3907 Register object = ToRegister(instr->object()); |
| 3908 Register key = ToRegister(instr->key()); |
| 3909 Register strict = scratch0(); |
| 3910 __ mov(strict, Operand(Smi::FromInt(strict_mode_flag()))); |
| 3911 __ Push(object, key, strict); |
| 3912 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 3913 LPointerMap* pointers = instr->pointer_map(); |
| 3914 LEnvironment* env = instr->deoptimization_environment(); |
| 3915 RecordPosition(pointers->position()); |
| 3916 RegisterEnvironmentForDeoptimization(env); |
| 3917 SafepointGenerator safepoint_generator(this, |
| 3918 pointers, |
| 3919 env->deoptimization_index()); |
| 3920 __ InvokeBuiltin(Builtins::DELETE, CALL_JS, &safepoint_generator); |
| 2351 } | 3921 } |
| 2352 | 3922 |
| 2353 | 3923 |
| 2354 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 3924 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
| 2355 // Perform stack overflow check. | 3925 // Perform stack overflow check. |
| 2356 Label ok; | 3926 Label ok; |
| 2357 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 3927 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 2358 __ cmp(sp, Operand(ip)); | 3928 __ cmp(sp, Operand(ip)); |
| 2359 __ b(hs, &ok); | 3929 __ b(hs, &ok); |
| 2360 StackCheckStub stub; | 3930 StackCheckStub stub; |
| 2361 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 3931 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2362 __ bind(&ok); | 3932 __ bind(&ok); |
| 2363 } | 3933 } |
| 2364 | 3934 |
| 2365 | 3935 |
| 2366 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 3936 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
| 2367 Abort("DoOsrEntry unimplemented."); | 3937 // This is a pseudo-instruction that ensures that the environment here is |
| 3938 // properly registered for deoptimization and records the assembler's PC |
| 3939 // offset. |
| 3940 LEnvironment* environment = instr->environment(); |
| 3941 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), |
| 3942 instr->SpilledDoubleRegisterArray()); |
| 3943 |
| 3944 // If the environment were already registered, we would have no way of |
| 3945 // backpatching it with the spill slot operands. |
| 3946 ASSERT(!environment->HasBeenRegistered()); |
| 3947 RegisterEnvironmentForDeoptimization(environment); |
| 3948 ASSERT(osr_pc_offset_ == -1); |
| 3949 osr_pc_offset_ = masm()->pc_offset(); |
| 2368 } | 3950 } |
| 2369 | 3951 |
| 2370 | 3952 |
| 2371 #undef __ | 3953 #undef __ |
| 2372 | 3954 |
| 2373 } } // namespace v8::internal | 3955 } } // namespace v8::internal |
| OLD | NEW |