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

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

Issue 7212025: Add support for lazy deoptimization from deferred stack checks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 for (int i = 0; i < jump_table_.length(); i++) { 268 for (int i = 0; i < jump_table_.length(); i++) {
269 __ bind(&jump_table_[i].label); 269 __ bind(&jump_table_[i].label);
270 __ Jump(jump_table_[i].address, RelocInfo::RUNTIME_ENTRY); 270 __ Jump(jump_table_[i].address, RelocInfo::RUNTIME_ENTRY);
271 } 271 }
272 return !is_aborted(); 272 return !is_aborted();
273 } 273 }
274 274
275 275
276 bool LCodeGen::GenerateDeferredCode() { 276 bool LCodeGen::GenerateDeferredCode() {
277 ASSERT(is_generating()); 277 ASSERT(is_generating());
278 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { 278 Label last_jump;
279 LDeferredCode* code = deferred_[i]; 279 if (deferred_.length() > 0) {
280 __ bind(code->entry()); 280 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
281 code->Generate(); 281 LDeferredCode* code = deferred_[i];
282 __ jmp(code->exit()); 282 __ bind(code->entry());
283 code->Generate();
284 #ifdef DEBUG
285 if (i == (deferred_.length() - 1)) {
286 __ bind(&last_jump);
287 }
288 #endif
289 __ jmp(code->exit());
290 }
291
292 // Reserve some space to ensure that the last piece of deferred code
293 // have room for lazy bailout.
294 int padding =
295 Deoptimizer::patch_size() - masm_->SizeOfCodeGeneratedSince(&last_jump);
296 if (padding > 0) {
297 while (padding > 9) {
298 __ nop(9);
299 padding -= 9;
300 }
301 __ nop(padding);
302 }
303
304 ASSERT(Deoptimizer::patch_size() <=
305 masm_->SizeOfCodeGeneratedSince(&last_jump));
283 } 306 }
284 307
285 // Deferred code is the last part of the instruction sequence. Mark 308 // Deferred code is the last part of the instruction sequence. Mark
286 // the generated code as done unless we bailed out. 309 // the generated code as done unless we bailed out.
287 if (!is_aborted()) status_ = DONE; 310 if (!is_aborted()) status_ = DONE;
288 return !is_aborted(); 311 return !is_aborted();
289 } 312 }
290 313
291 314
292 bool LCodeGen::GenerateSafepointTable() { 315 bool LCodeGen::GenerateSafepointTable() {
(...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 // reloc info for patching in deoptimization (since this is invoking a 4003 // reloc info for patching in deoptimization (since this is invoking a
3981 // builtin) 4004 // builtin)
3982 SafepointGenerator safepoint_generator(this, 4005 SafepointGenerator safepoint_generator(this,
3983 pointers, 4006 pointers,
3984 env->deoptimization_index()); 4007 env->deoptimization_index());
3985 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4008 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
3986 } 4009 }
3987 4010
3988 4011
3989 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) { 4012 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) {
3990 PushSafepointRegistersScope scope(this); 4013 {
3991 CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr); 4014 PushSafepointRegistersScope scope(this);
4015 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
4016 __ CallRuntimeSaveDoubles(Runtime::kStackGuard);
4017 RegisterLazyDeoptimization(instr, RECORD_SAFEPOINT_WITH_REGISTERS, 0);
4018 }
4019
4020 // The gap code includes the restoring of the safepoint registers.
4021 int pc = masm()->pc_offset();
4022 safepoints_.SetPcAfterGap(pc);
3992 } 4023 }
3993 4024
3994 4025
3995 void LCodeGen::DoStackCheck(LStackCheck* instr) { 4026 void LCodeGen::DoStackCheck(LStackCheck* instr) {
3996 class DeferredStackCheck: public LDeferredCode { 4027 class DeferredStackCheck: public LDeferredCode {
3997 public: 4028 public:
3998 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) 4029 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr)
3999 : LDeferredCode(codegen), instr_(instr) { } 4030 : LDeferredCode(codegen), instr_(instr) { }
4000 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } 4031 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
4001 private: 4032 private:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 RegisterEnvironmentForDeoptimization(environment); 4068 RegisterEnvironmentForDeoptimization(environment);
4038 ASSERT(osr_pc_offset_ == -1); 4069 ASSERT(osr_pc_offset_ == -1);
4039 osr_pc_offset_ = masm()->pc_offset(); 4070 osr_pc_offset_ = masm()->pc_offset();
4040 } 4071 }
4041 4072
4042 #undef __ 4073 #undef __
4043 4074
4044 } } // namespace v8::internal 4075 } } // namespace v8::internal
4045 4076
4046 #endif // V8_TARGET_ARCH_X64 4077 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698