Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 7216009: Change the handling of stack check on backward branches (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Changed stack check elimination to remove the stack check instruction Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 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
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 __ stm(db_w, sp, saved_regs); 1582 __ stm(db_w, sp, saved_regs);
1583 __ CallStub(&stub); 1583 __ CallStub(&stub);
1584 __ cmp(reg, Operand(0)); 1584 __ cmp(reg, Operand(0));
1585 __ ldm(ia_w, sp, saved_regs); 1585 __ ldm(ia_w, sp, saved_regs);
1586 EmitBranch(true_block, false_block, ne); 1586 EmitBranch(true_block, false_block, ne);
1587 } 1587 }
1588 } 1588 }
1589 } 1589 }
1590 1590
1591 1591
1592 void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { 1592 void LCodeGen::EmitGoto(int block) {
1593 block = chunk_->LookupDestination(block); 1593 block = chunk_->LookupDestination(block);
1594 int next_block = GetNextEmittedBlock(current_block_); 1594 int next_block = GetNextEmittedBlock(current_block_);
1595 if (block != next_block) { 1595 if (block != next_block) {
1596 // Perform stack overflow check if this goto needs it before jumping. 1596 __ jmp(chunk_->GetAssemblyLabel(block));
1597 if (deferred_stack_check != NULL) {
1598 __ LoadRoot(ip, Heap::kStackLimitRootIndex);
1599 __ cmp(sp, Operand(ip));
1600 __ b(hs, chunk_->GetAssemblyLabel(block));
1601 __ jmp(deferred_stack_check->entry());
1602 deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block));
1603 } else {
1604 __ jmp(chunk_->GetAssemblyLabel(block));
1605 }
1606 } 1597 }
1607 } 1598 }
1608 1599
1609 1600
1610 void LCodeGen::DoDeferredStackCheck(LGoto* instr) { 1601 void LCodeGen::DoGoto(LGoto* instr) {
1611 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); 1602 EmitGoto(instr->block_id());
1612 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr);
1613 } 1603 }
1614 1604
1615 1605
1616 void LCodeGen::DoGoto(LGoto* instr) {
1617 class DeferredStackCheck: public LDeferredCode {
1618 public:
1619 DeferredStackCheck(LCodeGen* codegen, LGoto* instr)
1620 : LDeferredCode(codegen), instr_(instr) { }
1621 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
1622 private:
1623 LGoto* instr_;
1624 };
1625
1626 DeferredStackCheck* deferred = NULL;
1627 if (instr->include_stack_check()) {
1628 deferred = new DeferredStackCheck(this, instr);
1629 }
1630 EmitGoto(instr->block_id(), deferred);
1631 }
1632
1633
1634 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { 1606 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
1635 Condition cond = kNoCondition; 1607 Condition cond = kNoCondition;
1636 switch (op) { 1608 switch (op) {
1637 case Token::EQ: 1609 case Token::EQ:
1638 case Token::EQ_STRICT: 1610 case Token::EQ_STRICT:
1639 cond = eq; 1611 cond = eq;
1640 break; 1612 break;
1641 case Token::LT: 1613 case Token::LT:
1642 cond = is_unsigned ? lo : lt; 1614 cond = is_unsigned ? lo : lt;
1643 break; 1615 break;
(...skipping 2946 matching lines...) Expand 10 before | Expand all | Expand 10 after
4590 LEnvironment* env = instr->deoptimization_environment(); 4562 LEnvironment* env = instr->deoptimization_environment();
4591 RecordPosition(pointers->position()); 4563 RecordPosition(pointers->position());
4592 RegisterEnvironmentForDeoptimization(env); 4564 RegisterEnvironmentForDeoptimization(env);
4593 SafepointGenerator safepoint_generator(this, 4565 SafepointGenerator safepoint_generator(this,
4594 pointers, 4566 pointers,
4595 env->deoptimization_index()); 4567 env->deoptimization_index());
4596 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4568 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4597 } 4569 }
4598 4570
4599 4571
4572 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) {
4573 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters);
4574 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr);
4575 }
4576
4577
4600 void LCodeGen::DoStackCheck(LStackCheck* instr) { 4578 void LCodeGen::DoStackCheck(LStackCheck* instr) {
4601 // Perform stack overflow check. 4579 class DeferredStackCheck: public LDeferredCode {
4602 Label ok; 4580 public:
4603 __ LoadRoot(ip, Heap::kStackLimitRootIndex); 4581 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr)
4604 __ cmp(sp, Operand(ip)); 4582 : LDeferredCode(codegen), instr_(instr) { }
4605 __ b(hs, &ok); 4583 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
4606 StackCheckStub stub; 4584 private:
4607 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 4585 LStackCheck* instr_;
4608 __ bind(&ok); 4586 };
4587
4588 if (instr->hydrogen()->is_function_entry()) {
4589 // Perform stack overflow check.
4590 Label done;
4591 __ LoadRoot(ip, Heap::kStackLimitRootIndex);
4592 __ cmp(sp, Operand(ip));
4593 __ b(hs, &done);
4594 StackCheckStub stub;
4595 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4596 __ bind(&done);
4597 } else {
4598 ASSERT(instr->hydrogen()->is_backwards_branch());
4599 // Perform stack overflow check if this goto needs it before jumping.
4600 DeferredStackCheck* deferred_stack_check =
4601 new DeferredStackCheck(this, instr);
4602 __ LoadRoot(ip, Heap::kStackLimitRootIndex);
4603 __ cmp(sp, Operand(ip));
4604 __ b(lo, deferred_stack_check->entry());
4605 __ bind(instr->done_label());
4606 deferred_stack_check->SetExit(instr->done_label());
4607 }
4609 } 4608 }
4610 4609
4611 4610
4612 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { 4611 void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
4613 // This is a pseudo-instruction that ensures that the environment here is 4612 // This is a pseudo-instruction that ensures that the environment here is
4614 // properly registered for deoptimization and records the assembler's PC 4613 // properly registered for deoptimization and records the assembler's PC
4615 // offset. 4614 // offset.
4616 LEnvironment* environment = instr->environment(); 4615 LEnvironment* environment = instr->environment();
4617 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), 4616 environment->SetSpilledRegisters(instr->SpilledRegisterArray(),
4618 instr->SpilledDoubleRegisterArray()); 4617 instr->SpilledDoubleRegisterArray());
4619 4618
4620 // If the environment were already registered, we would have no way of 4619 // If the environment were already registered, we would have no way of
4621 // backpatching it with the spill slot operands. 4620 // backpatching it with the spill slot operands.
4622 ASSERT(!environment->HasBeenRegistered()); 4621 ASSERT(!environment->HasBeenRegistered());
4623 RegisterEnvironmentForDeoptimization(environment); 4622 RegisterEnvironmentForDeoptimization(environment);
4624 ASSERT(osr_pc_offset_ == -1); 4623 ASSERT(osr_pc_offset_ == -1);
4625 osr_pc_offset_ = masm()->pc_offset(); 4624 osr_pc_offset_ = masm()->pc_offset();
4626 } 4625 }
4627 4626
4628 4627
4629 4628
4630 4629
4631 #undef __ 4630 #undef __
4632 4631
4633 } } // namespace v8::internal 4632 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698