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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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, 6 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/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 __ push(reg); 1416 __ push(reg);
1417 __ CallStub(&stub); 1417 __ CallStub(&stub);
1418 __ test(eax, Operand(eax)); 1418 __ test(eax, Operand(eax));
1419 __ popad(); 1419 __ popad();
1420 EmitBranch(true_block, false_block, not_zero); 1420 EmitBranch(true_block, false_block, not_zero);
1421 } 1421 }
1422 } 1422 }
1423 } 1423 }
1424 1424
1425 1425
1426 void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { 1426 void LCodeGen::EmitGoto(int block) {
1427 block = chunk_->LookupDestination(block); 1427 block = chunk_->LookupDestination(block);
1428 int next_block = GetNextEmittedBlock(current_block_); 1428 int next_block = GetNextEmittedBlock(current_block_);
1429 if (block != next_block) { 1429 if (block != next_block) {
1430 // Perform stack overflow check if this goto needs it before jumping. 1430 __ jmp(chunk_->GetAssemblyLabel(block));
1431 if (deferred_stack_check != NULL) {
1432 ExternalReference stack_limit =
1433 ExternalReference::address_of_stack_limit(isolate());
1434 __ cmp(esp, Operand::StaticVariable(stack_limit));
1435 __ j(above_equal, chunk_->GetAssemblyLabel(block));
1436 __ jmp(deferred_stack_check->entry());
1437 deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block));
1438 } else {
1439 __ jmp(chunk_->GetAssemblyLabel(block));
1440 }
1441 } 1431 }
1442 } 1432 }
1443 1433
1444 1434
1445 void LCodeGen::DoDeferredStackCheck(LGoto* instr) {
1446 PushSafepointRegistersScope scope(this);
1447 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr);
1448 }
1449
1450 void LCodeGen::DoGoto(LGoto* instr) { 1435 void LCodeGen::DoGoto(LGoto* instr) {
1451 class DeferredStackCheck: public LDeferredCode { 1436 EmitGoto(instr->block_id());
1452 public:
1453 DeferredStackCheck(LCodeGen* codegen, LGoto* instr)
1454 : LDeferredCode(codegen), instr_(instr) { }
1455 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
1456 private:
1457 LGoto* instr_;
1458 };
1459
1460 DeferredStackCheck* deferred = NULL;
1461 if (instr->include_stack_check()) {
1462 deferred = new DeferredStackCheck(this, instr);
1463 }
1464 EmitGoto(instr->block_id(), deferred);
1465 } 1437 }
1466 1438
1467 1439
1468 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { 1440 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
1469 Condition cond = no_condition; 1441 Condition cond = no_condition;
1470 switch (op) { 1442 switch (op) {
1471 case Token::EQ: 1443 case Token::EQ:
1472 case Token::EQ_STRICT: 1444 case Token::EQ_STRICT:
1473 cond = equal; 1445 cond = equal;
1474 break; 1446 break;
(...skipping 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 // builtin) 4400 // builtin)
4429 SafepointGenerator safepoint_generator(this, 4401 SafepointGenerator safepoint_generator(this,
4430 pointers, 4402 pointers,
4431 env->deoptimization_index()); 4403 env->deoptimization_index());
4432 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4404 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4433 __ push(Immediate(Smi::FromInt(strict_mode_flag()))); 4405 __ push(Immediate(Smi::FromInt(strict_mode_flag())));
4434 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, safepoint_generator); 4406 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, safepoint_generator);
4435 } 4407 }
4436 4408
4437 4409
4410 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) {
4411 PushSafepointRegistersScope scope(this);
4412 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr);
4413 }
4414
4415
4438 void LCodeGen::DoStackCheck(LStackCheck* instr) { 4416 void LCodeGen::DoStackCheck(LStackCheck* instr) {
4439 // Perform stack overflow check. 4417 class DeferredStackCheck: public LDeferredCode {
4440 Label done; 4418 public:
4441 ExternalReference stack_limit = 4419 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr)
4442 ExternalReference::address_of_stack_limit(isolate()); 4420 : LDeferredCode(codegen), instr_(instr) { }
4443 __ cmp(esp, Operand::StaticVariable(stack_limit)); 4421 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
4444 __ j(above_equal, &done, Label::kNear); 4422 private:
4423 LStackCheck* instr_;
4424 };
4445 4425
4446 StackCheckStub stub; 4426 if (instr->hydrogen()->is_function_entry()) {
4447 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT); 4427 // Perform stack overflow check.
4448 __ bind(&done); 4428 Label done;
4429 ExternalReference stack_limit =
4430 ExternalReference::address_of_stack_limit(isolate());
4431 __ cmp(esp, Operand::StaticVariable(stack_limit));
4432 __ j(above_equal, &done, Label::kNear);
4433
4434 StackCheckStub stub;
4435 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT);
4436 __ bind(&done);
4437 } else {
4438 ASSERT(instr->hydrogen()->is_backwards_branch());
4439 // Perform stack overflow check if this goto needs it before jumping.
4440 DeferredStackCheck* deferred_stack_check =
4441 new DeferredStackCheck(this, instr);
4442 ExternalReference stack_limit =
4443 ExternalReference::address_of_stack_limit(isolate());
4444 __ cmp(esp, Operand::StaticVariable(stack_limit));
4445 __ j(below, deferred_stack_check->entry());
4446 __ bind(instr->done_label());
4447 deferred_stack_check->SetExit(instr->done_label());
4448 }
4449 } 4449 }
4450 4450
4451 4451
4452 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { 4452 void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
4453 // This is a pseudo-instruction that ensures that the environment here is 4453 // This is a pseudo-instruction that ensures that the environment here is
4454 // properly registered for deoptimization and records the assembler's PC 4454 // properly registered for deoptimization and records the assembler's PC
4455 // offset. 4455 // offset.
4456 LEnvironment* environment = instr->environment(); 4456 LEnvironment* environment = instr->environment();
4457 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), 4457 environment->SetSpilledRegisters(instr->SpilledRegisterArray(),
4458 instr->SpilledDoubleRegisterArray()); 4458 instr->SpilledDoubleRegisterArray());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4493 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4493 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4494 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4494 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4495 } 4495 }
4496 4496
4497 4497
4498 #undef __ 4498 #undef __
4499 4499
4500 } } // namespace v8::internal 4500 } } // namespace v8::internal
4501 4501
4502 #endif // V8_TARGET_ARCH_IA32 4502 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698