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

Side by Side Diff: src/virtual-frame-arm.cc

Issue 11406: Simplify virtual frame by removing the virtual stack pointer, which... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 12 years, 1 month 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/virtual-frame-arm.h ('k') | src/virtual-frame-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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 23 matching lines...) Expand all
34 namespace v8 { namespace internal { 34 namespace v8 { namespace internal {
35 35
36 // ------------------------------------------------------------------------- 36 // -------------------------------------------------------------------------
37 // VirtualFrame implementation. 37 // VirtualFrame implementation.
38 38
39 #define __ masm_-> 39 #define __ masm_->
40 40
41 VirtualFrame::VirtualFrame(CodeGenerator* cgen) 41 VirtualFrame::VirtualFrame(CodeGenerator* cgen)
42 : masm_(cgen->masm()), 42 : masm_(cgen->masm()),
43 elements_(0), 43 elements_(0),
44 virtual_stack_pointer_(-1),
45 virtual_frame_pointer_(-1),
46 parameter_count_(cgen->scope()->num_parameters()), 44 parameter_count_(cgen->scope()->num_parameters()),
47 local_count_(0) { 45 local_count_(0),
46 frame_pointer_(-1) {
iposva 2008/11/17 17:11:53 Ideally you could define an illegal index and use
48 // The virtual frame contains a receiver and the parameters (all in 47 // The virtual frame contains a receiver and the parameters (all in
49 // memory) when it is created. 48 // memory) when it is created.
50 Adjust(parameter_count_ + 1); 49 Adjust(parameter_count_ + 1);
51 } 50 }
52 51
53 52
54 VirtualFrame::VirtualFrame(VirtualFrame* original) 53 VirtualFrame::VirtualFrame(VirtualFrame* original)
55 : masm_(original->masm_), 54 : masm_(original->masm_),
56 elements_(original->elements_.length()), 55 elements_(original->elements_.length()),
57 virtual_stack_pointer_(original->virtual_stack_pointer_),
58 virtual_frame_pointer_(original->virtual_frame_pointer_),
59 parameter_count_(original->parameter_count_), 56 parameter_count_(original->parameter_count_),
60 local_count_(original->local_count_) { 57 local_count_(original->local_count_),
58 frame_pointer_(original->frame_pointer_) {
61 // Copy all the elements. 59 // Copy all the elements.
62 for (int i = 0; i <= virtual_stack_pointer_; i++) { 60 for (int i = 0; i < original->elements_.length(); i++) {
63 elements_.Add(original->elements_[i]); 61 elements_.Add(original->elements_[i]);
64 } 62 }
65 } 63 }
66 64
67 65
68 void VirtualFrame::Adjust(int count) { 66 void VirtualFrame::Adjust(int count) {
69 ASSERT(count >= 0); 67 ASSERT(count >= 0);
70 for (int i = 0; i < count; i++) { 68 for (int i = 0; i < count; i++) {
71 AddElement(Element()); 69 elements_.Add(Element());
72 } 70 }
73 } 71 }
74 72
75 73
76 void VirtualFrame::Forget(int count) { 74 void VirtualFrame::Forget(int count) {
77 ASSERT(count >= 0); 75 ASSERT(count >= 0);
78 ASSERT(virtual_stack_pointer_ >= count); 76 ASSERT(elements_.length() >= count);
79 for (int i = 0; i < count; i++) { 77 for (int i = 0; i < count; i++) {
80 RemoveElement(); 78 elements_.RemoveLast();
81 } 79 }
82 } 80 }
83 81
84 82
85 void VirtualFrame::MergeTo(VirtualFrame* expected) { 83 void VirtualFrame::MergeTo(VirtualFrame* expected) {
86 ASSERT(masm_ == expected->masm_); 84 ASSERT(masm_ == expected->masm_);
87 ASSERT(elements_.length() == expected->elements_.length()); 85 ASSERT(elements_.length() == expected->elements_.length());
88 ASSERT(virtual_frame_pointer_ == expected->virtual_frame_pointer_);
89 ASSERT(virtual_stack_pointer_ == expected->virtual_stack_pointer_);
90 ASSERT(parameter_count_ == expected->parameter_count_); 86 ASSERT(parameter_count_ == expected->parameter_count_);
91 ASSERT(local_count_ == expected->local_count_); 87 ASSERT(local_count_ == expected->local_count_);
92 for (int i = 0; i <= virtual_stack_pointer_; i++) { 88 ASSERT(frame_pointer_ == expected->frame_pointer_);
89 for (int i = 0; i < elements_.length(); i++) {
93 ASSERT(elements_[i].matches(expected->elements_[i])); 90 ASSERT(elements_[i].matches(expected->elements_[i]));
94 } 91 }
95 } 92 }
96 93
97 94
98 void VirtualFrame::Enter() { 95 void VirtualFrame::Enter() {
99 Comment cmnt(masm_, "[ Enter JS frame"); 96 Comment cmnt(masm_, "[ Enter JS frame");
100 #ifdef DEBUG 97 #ifdef DEBUG
101 { Label done, fail; 98 { Label done, fail;
102 __ tst(r1, Operand(kSmiTagMask)); 99 __ tst(r1, Operand(kSmiTagMask));
103 __ b(eq, &fail); 100 __ b(eq, &fail);
104 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); 101 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset));
105 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); 102 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset));
106 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); 103 __ cmp(r2, Operand(JS_FUNCTION_TYPE));
107 __ b(eq, &done); 104 __ b(eq, &done);
108 __ bind(&fail); 105 __ bind(&fail);
109 __ stop("CodeGenerator::EnterJSFrame - r1 not a function"); 106 __ stop("CodeGenerator::EnterJSFrame - r1 not a function");
110 __ bind(&done); 107 __ bind(&done);
111 } 108 }
112 #endif // DEBUG 109 #endif // DEBUG
113 110
114 Adjust(4); 111 Adjust(4);
iposva 2008/11/17 17:11:53 Can you please document the magic numbers in this
115 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); 112 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
116 // Adjust FP to point to saved FP. 113 // Adjust FP to point to saved FP.
117 virtual_frame_pointer_ = virtual_stack_pointer_ - 1; 114 frame_pointer_ = elements_.length() - 2;
118 __ add(fp, sp, Operand(2 * kPointerSize)); 115 __ add(fp, sp, Operand(2 * kPointerSize));
119 } 116 }
120 117
121 118
122 void VirtualFrame::Exit() { 119 void VirtualFrame::Exit() {
123 Comment cmnt(masm_, "[ Exit JS frame"); 120 Comment cmnt(masm_, "[ Exit JS frame");
124 // Drop the execution stack down to the frame pointer and restore the caller 121 // Drop the execution stack down to the frame pointer and restore the caller
125 // frame pointer and return address. 122 // frame pointer and return address.
126 __ mov(sp, fp); 123 __ mov(sp, fp);
127 __ ldm(ia_w, sp, fp.bit() | lr.bit()); 124 __ ldm(ia_w, sp, fp.bit() | lr.bit());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 207
211 void VirtualFrame::Push(Register reg) { 208 void VirtualFrame::Push(Register reg) {
212 Adjust(1); 209 Adjust(1);
213 __ push(reg); 210 __ push(reg);
214 } 211 }
215 212
216 213
217 #undef __ 214 #undef __
218 215
219 } } // namespace v8::internal 216 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/virtual-frame-arm.h ('k') | src/virtual-frame-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698