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

Side by Side Diff: src/x64/lithium-codegen-x64.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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 __ push(reg); 1418 __ push(reg);
1419 __ CallStub(&stub); 1419 __ CallStub(&stub);
1420 __ testq(rax, rax); 1420 __ testq(rax, rax);
1421 __ Popad(); 1421 __ Popad();
1422 EmitBranch(true_block, false_block, not_zero); 1422 EmitBranch(true_block, false_block, not_zero);
1423 } 1423 }
1424 } 1424 }
1425 } 1425 }
1426 1426
1427 1427
1428 void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { 1428 void LCodeGen::EmitGoto(int block) {
1429 block = chunk_->LookupDestination(block); 1429 block = chunk_->LookupDestination(block);
1430 int next_block = GetNextEmittedBlock(current_block_); 1430 int next_block = GetNextEmittedBlock(current_block_);
1431 if (block != next_block) { 1431 if (block != next_block) {
1432 // Perform stack overflow check if this goto needs it before jumping. 1432 __ jmp(chunk_->GetAssemblyLabel(block));
1433 if (deferred_stack_check != NULL) {
1434 __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
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 } 1433 }
1442 } 1434 }
1443 1435
1444 1436
1445 void LCodeGen::DoDeferredStackCheck(LGoto* instr) { 1437 void LCodeGen::DoGoto(LGoto* instr) {
1446 PushSafepointRegistersScope scope(this); 1438 EmitGoto(instr->block_id());
1447 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr);
1448 } 1439 }
1449 1440
1450 1441
1451 void LCodeGen::DoGoto(LGoto* instr) {
1452 class DeferredStackCheck: public LDeferredCode {
1453 public:
1454 DeferredStackCheck(LCodeGen* codegen, LGoto* instr)
1455 : LDeferredCode(codegen), instr_(instr) { }
1456 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
1457 private:
1458 LGoto* instr_;
1459 };
1460
1461 DeferredStackCheck* deferred = NULL;
1462 if (instr->include_stack_check()) {
1463 deferred = new DeferredStackCheck(this, instr);
1464 }
1465 EmitGoto(instr->block_id(), deferred);
1466 }
1467
1468
1469 inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { 1442 inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
1470 Condition cond = no_condition; 1443 Condition cond = no_condition;
1471 switch (op) { 1444 switch (op) {
1472 case Token::EQ: 1445 case Token::EQ:
1473 case Token::EQ_STRICT: 1446 case Token::EQ_STRICT:
1474 cond = equal; 1447 cond = equal;
1475 break; 1448 break;
1476 case Token::LT: 1449 case Token::LT:
1477 cond = is_unsigned ? below : less; 1450 cond = is_unsigned ? below : less;
1478 break; 1451 break;
(...skipping 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after
4283 // Create safepoint generator that will also ensure enough space in the 4256 // Create safepoint generator that will also ensure enough space in the
4284 // reloc info for patching in deoptimization (since this is invoking a 4257 // reloc info for patching in deoptimization (since this is invoking a
4285 // builtin) 4258 // builtin)
4286 SafepointGenerator safepoint_generator(this, 4259 SafepointGenerator safepoint_generator(this,
4287 pointers, 4260 pointers,
4288 env->deoptimization_index()); 4261 env->deoptimization_index());
4289 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4262 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4290 } 4263 }
4291 4264
4292 4265
4266 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) {
4267 PushSafepointRegistersScope scope(this);
4268 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr);
4269 }
4270
4271
4293 void LCodeGen::DoStackCheck(LStackCheck* instr) { 4272 void LCodeGen::DoStackCheck(LStackCheck* instr) {
4294 // Perform stack overflow check. 4273 class DeferredStackCheck: public LDeferredCode {
4295 Label done; 4274 public:
4296 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); 4275 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr)
4297 __ j(above_equal, &done, Label::kNear); 4276 : LDeferredCode(codegen), instr_(instr) { }
4277 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
4278 private:
4279 LStackCheck* instr_;
4280 };
4298 4281
4299 StackCheckStub stub; 4282 if (instr->hydrogen()->is_function_entry()) {
4300 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 4283 // Perform stack overflow check.
4301 __ bind(&done); 4284 Label done;
4285 __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
4286 __ j(above_equal, &done, Label::kNear);
4287 StackCheckStub stub;
4288 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4289 __ bind(&done);
4290 } else {
4291 ASSERT(instr->hydrogen()->is_backwards_branch());
4292 // Perform stack overflow check if this goto needs it before jumping.
4293 DeferredStackCheck* deferred_stack_check =
4294 new DeferredStackCheck(this, instr);
4295 __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
4296 __ j(below, deferred_stack_check->entry());
4297 __ bind(instr->done_label());
4298 deferred_stack_check->SetExit(instr->done_label());
4299 }
4302 } 4300 }
4303 4301
4304 4302
4305 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { 4303 void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
4306 // This is a pseudo-instruction that ensures that the environment here is 4304 // This is a pseudo-instruction that ensures that the environment here is
4307 // properly registered for deoptimization and records the assembler's PC 4305 // properly registered for deoptimization and records the assembler's PC
4308 // offset. 4306 // offset.
4309 LEnvironment* environment = instr->environment(); 4307 LEnvironment* environment = instr->environment();
4310 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), 4308 environment->SetSpilledRegisters(instr->SpilledRegisterArray(),
4311 instr->SpilledDoubleRegisterArray()); 4309 instr->SpilledDoubleRegisterArray());
4312 4310
4313 // If the environment were already registered, we would have no way of 4311 // If the environment were already registered, we would have no way of
4314 // backpatching it with the spill slot operands. 4312 // backpatching it with the spill slot operands.
4315 ASSERT(!environment->HasBeenRegistered()); 4313 ASSERT(!environment->HasBeenRegistered());
4316 RegisterEnvironmentForDeoptimization(environment); 4314 RegisterEnvironmentForDeoptimization(environment);
4317 ASSERT(osr_pc_offset_ == -1); 4315 ASSERT(osr_pc_offset_ == -1);
4318 osr_pc_offset_ = masm()->pc_offset(); 4316 osr_pc_offset_ = masm()->pc_offset();
4319 } 4317 }
4320 4318
4321 #undef __ 4319 #undef __
4322 4320
4323 } } // namespace v8::internal 4321 } } // namespace v8::internal
4324 4322
4325 #endif // V8_TARGET_ARCH_X64 4323 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698