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

Side by Side Diff: src/codegen.cc

Issue 13746: Experimental: thread live register references to deferred code.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years 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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 22 matching lines...) Expand all
33 #include "prettyprinter.h" 33 #include "prettyprinter.h"
34 #include "scopeinfo.h" 34 #include "scopeinfo.h"
35 #include "runtime.h" 35 #include "runtime.h"
36 #include "stub-cache.h" 36 #include "stub-cache.h"
37 37
38 namespace v8 { namespace internal { 38 namespace v8 { namespace internal {
39 39
40 DeferredCode::DeferredCode(CodeGenerator* generator) 40 DeferredCode::DeferredCode(CodeGenerator* generator)
41 : masm_(generator->masm()), 41 : masm_(generator->masm()),
42 generator_(generator), 42 generator_(generator),
43 enter_(generator), 43 frame_(NULL),
44 exit_(generator), 44 exit_(generator),
45 statement_position_(masm_->last_statement_position()), 45 statement_position_(masm_->last_statement_position()),
46 position_(masm_->last_position()) { 46 position_(masm_->last_position()) {
47 generator->AddDeferred(this); 47 generator->AddDeferred(this);
48 #ifdef DEBUG 48 #ifdef DEBUG
49 comment_ = ""; 49 comment_ = "";
50 #endif 50 #endif
51 } 51 }
52 52
53 53
54 void DeferredCode::BranchTo(Condition cc) {
55 // Set the register file and frame based on the first branch to the
56 // deferred code.
57 if (frame_ == NULL) {
58 generator()->allocator()->SaveTo(&registers_);
59 frame_ = new VirtualFrame(generator()->frame());
60 } else {
61 // The frame and register file must match the existing ones.
62 ASSERT(generator()->allocator()->Matches(&registers_));
63 ASSERT(generator()->frame()->Equals(frame_));
64 }
65
66 // Emit the branch.
67 masm_->j(cc, &enter_, not_taken);
68 }
69
70
71 void DeferredCode::BindExit() {
72 exit_.Bind();
73 }
74
75 void DeferredCode::ExitIfBound() {
76 if (exit_.is_bound()) {
77 // This backward jump will emit code to merge the code generator's
78 // current frame to the exit frame and then delete the current frame.
79 exit_.Jump();
80 } else {
81 // Don't leak the code generator's current frame.
82 generator()->DeleteFrame();
83 }
84 }
85
86
54 void CodeGenerator::ProcessDeferred() { 87 void CodeGenerator::ProcessDeferred() {
55 while (!deferred_.is_empty()) { 88 while (!deferred_.is_empty()) {
56 DeferredCode* code = deferred_.RemoveLast(); 89 DeferredCode* code = deferred_.RemoveLast();
57 MacroAssembler* masm = code->masm(); 90 MacroAssembler* masm = code->masm();
58 // Record position of deferred code stub. 91 // Record position of deferred code stub.
59 if (code->statement_position() != RelocInfo::kNoPosition) { 92 if (code->statement_position() != RelocInfo::kNoPosition) {
60 masm->RecordStatementPosition(code->statement_position()); 93 masm->RecordStatementPosition(code->statement_position());
61 } 94 }
62 if (code->position() != RelocInfo::kNoPosition) { 95 if (code->position() != RelocInfo::kNoPosition) {
63 masm->RecordPosition(code->position()); 96 masm->RecordPosition(code->position());
64 } 97 }
65 // Bind labels and generate the code. 98 // Bind labels and generate the code.
66 code->enter()->Bind(); 99 masm->bind(code->enter());
100 allocator()->RestoreFrom(code->registers());
101 // Transfer ownership of the deferred code's expected frame to the code
102 // generator.
103 SetFrame(code->frame());
104 code->clear_frame();
105 // For now, we spill before entering any deferred code.
67 frame_->SpillAll(); 106 frame_->SpillAll();
68 Comment cmnt(masm, code->comment()); 107 Comment cmnt(masm, code->comment());
69 code->Generate(); 108 code->Generate();
70 if (code->exit()->is_bound()) { 109 code->ExitIfBound();
William Hesse 2008/12/16 09:10:54 Do we have any deferred code objects that don't re
71 code->exit()->Jump();
72 }
73 } 110 }
74 } 111 }
75 112
76 113
77 // Generate the code. Takes a function literal, generates code for it, assemble 114 // Generate the code. Takes a function literal, generates code for it, assemble
78 // all the pieces into a Code object. This function is only to be called by 115 // all the pieces into a Code object. This function is only to be called by
79 // the compiler.cc code. 116 // the compiler.cc code.
80 Handle<Code> CodeGenerator::MakeCode(FunctionLiteral* flit, 117 Handle<Code> CodeGenerator::MakeCode(FunctionLiteral* flit,
81 Handle<Script> script, 118 Handle<Script> script,
82 bool is_eval) { 119 bool is_eval) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { 528 void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
492 switch (type_) { 529 switch (type_) {
493 case READ_LENGTH: GenerateReadLength(masm); break; 530 case READ_LENGTH: GenerateReadLength(masm); break;
494 case READ_ELEMENT: GenerateReadElement(masm); break; 531 case READ_ELEMENT: GenerateReadElement(masm); break;
495 case NEW_OBJECT: GenerateNewObject(masm); break; 532 case NEW_OBJECT: GenerateNewObject(masm); break;
496 } 533 }
497 } 534 }
498 535
499 536
500 } } // namespace v8::internal 537 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/codegen-ia32.cc » ('j') | src/codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698