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

Side by Side Diff: src/codegen.cc

Issue 118226: Simplify the processing of deferred code in the code generator. Our... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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/codegen.h ('k') | src/codegen-inl.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 27 matching lines...) Expand all
38 #include "scopeinfo.h" 38 #include "scopeinfo.h"
39 #include "stub-cache.h" 39 #include "stub-cache.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44 44
45 CodeGenerator* CodeGeneratorScope::top_ = NULL; 45 CodeGenerator* CodeGeneratorScope::top_ = NULL;
46 46
47 47
48 DeferredCode::DeferredCode() : exit_(JumpTarget::BIDIRECTIONAL) { 48 DeferredCode::DeferredCode()
49 MacroAssembler* masm = cgen()->masm(); 49 : masm_(CodeGeneratorScope::Current()->masm()),
50 statement_position_ = masm->current_statement_position(); 50 statement_position_(masm_->current_statement_position()),
51 position_ = masm->current_position(); 51 position_(masm_->current_position()) {
52 ASSERT(statement_position_ != RelocInfo::kNoPosition); 52 ASSERT(statement_position_ != RelocInfo::kNoPosition);
53 ASSERT(position_ != RelocInfo::kNoPosition); 53 ASSERT(position_ != RelocInfo::kNoPosition);
54 54
55 cgen()->AddDeferred(this); 55 CodeGeneratorScope::Current()->AddDeferred(this);
56 #ifdef DEBUG 56 #ifdef DEBUG
57 comment_ = ""; 57 comment_ = "";
58 #endif 58 #endif
59
60 // Copy the register locations from the code generator's frame.
61 // These are the registers that will be spilled on entry to the
62 // deferred code and restored on exit.
63 VirtualFrame* frame = CodeGeneratorScope::Current()->frame();
64 int sp_offset = frame->fp_relative(frame->stack_pointer_);
65 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
66 int loc = frame->register_location(i);
67 if (loc == VirtualFrame::kIllegalIndex) {
68 registers_[i] = kIgnore;
69 } else if (frame->elements_[loc].is_synced()) {
70 // Needs to be restored on exit but not saved on entry.
71 registers_[i] = frame->fp_relative(loc) | kSyncedFlag;
72 } else {
73 int offset = frame->fp_relative(loc);
74 registers_[i] = (offset < sp_offset) ? kPush : offset;
75 }
76 }
59 } 77 }
60 78
61 79
62 void CodeGenerator::ProcessDeferred() { 80 void CodeGenerator::ProcessDeferred() {
63 while (!deferred_.is_empty()) { 81 while (!deferred_.is_empty()) {
64 DeferredCode* code = deferred_.RemoveLast(); 82 DeferredCode* code = deferred_.RemoveLast();
65 MacroAssembler* masm = code->cgen()->masm(); 83 ASSERT(masm_ == code->masm());
66 // Record position of deferred code stub. 84 // Record position of deferred code stub.
67 masm->RecordStatementPosition(code->statement_position()); 85 masm_->RecordStatementPosition(code->statement_position());
68 if (code->position() != RelocInfo::kNoPosition) { 86 if (code->position() != RelocInfo::kNoPosition) {
69 masm->RecordPosition(code->position()); 87 masm_->RecordPosition(code->position());
70 } 88 }
71 // Generate the code. 89 // Generate the code.
72 Comment cmnt(masm, code->comment()); 90 Comment cmnt(masm_, code->comment());
91 masm_->bind(code->entry_label());
92 code->SaveRegisters();
73 code->Generate(); 93 code->Generate();
74 ASSERT(code->enter()->is_bound()); 94 code->RestoreRegisters();
95 masm_->jmp(code->exit_label());
75 } 96 }
76 } 97 }
77 98
78 99
79 void CodeGenerator::SetFrame(VirtualFrame* new_frame, 100 void CodeGenerator::SetFrame(VirtualFrame* new_frame,
80 RegisterFile* non_frame_registers) { 101 RegisterFile* non_frame_registers) {
81 RegisterFile saved_counts; 102 RegisterFile saved_counts;
82 if (has_valid_frame()) { 103 if (has_valid_frame()) {
83 frame_->DetachFromCodeGenerator(); 104 frame_->DetachFromCodeGenerator();
84 // The remaining register reference counts are the non-frame ones. 105 // The remaining register reference counts are the non-frame ones.
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { 647 void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
627 switch (type_) { 648 switch (type_) {
628 case READ_LENGTH: GenerateReadLength(masm); break; 649 case READ_LENGTH: GenerateReadLength(masm); break;
629 case READ_ELEMENT: GenerateReadElement(masm); break; 650 case READ_ELEMENT: GenerateReadElement(masm); break;
630 case NEW_OBJECT: GenerateNewObject(masm); break; 651 case NEW_OBJECT: GenerateNewObject(masm); break;
631 } 652 }
632 } 653 }
633 654
634 655
635 } } // namespace v8::internal 656 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/codegen-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698