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

Side by Side Diff: src/codegen-arm.h

Issue 7302: Initial port of VirtualFrame to the ARM architecture. To reduce the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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 | « no previous file | src/codegen-arm.cc » ('j') | src/codegen-arm.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 20 matching lines...) Expand all
31 #include "scopes.h" 31 #include "scopes.h"
32 32
33 namespace v8 { namespace internal { 33 namespace v8 { namespace internal {
34 34
35 // Forward declarations 35 // Forward declarations
36 class DeferredCode; 36 class DeferredCode;
37 37
38 // Mode to overwrite BinaryExpression values. 38 // Mode to overwrite BinaryExpression values.
39 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; 39 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT };
40 40
41 enum InitState { CONST_INIT, NOT_CONST_INIT };
42 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
41 43
42 // ----------------------------------------------------------------------------- 44
45 // -------------------------------------------------------------------------
46 // Virtual frame
47
48 class VirtualFrame BASE_EMBEDDED {
49 public:
50 explicit VirtualFrame(CodeGenerator* cgen);
51
52 MemOperand Top() const { return MemOperand(sp, 0); }
53
54 MemOperand Element(int index) const {
55 return MemOperand(sp, index * kPointerSize);
56 }
57
58 MemOperand Local(int index) const {
59 ASSERT(0 <= index && index < frame_local_count_);
60 return MemOperand(fp, kLocal0Offset - index * kPointerSize);
61 }
62
63 MemOperand Function() const { return MemOperand(fp, kFunctionOffset); }
64
65 MemOperand Context() const { return MemOperand(fp, kContextOffset); }
66
67 MemOperand Parameter(int index) const {
68 // Index -1 corresponds to the receiver.
69 ASSERT(-1 <= index && index <= parameter_count_);
70 return MemOperand(fp, (1 + parameter_count_ - index) * kPointerSize);
71 }
72
73 private:
74 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
75 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset;
76 static const int kContextOffset = StandardFrameConstants::kContextOffset;
77
78 MacroAssembler* masm_;
79 int frame_local_count_;
80 int parameter_count_;
81 };
82
83
84 // -------------------------------------------------------------------------
43 // Reference support 85 // Reference support
44 86
45 // A reference is a C++ stack-allocated object that keeps an ECMA 87 // A reference is a C++ stack-allocated object that keeps an ECMA
46 // reference on the execution stack while in scope. For variables 88 // reference on the execution stack while in scope. For variables
47 // the reference is empty, indicating that it isn't necessary to 89 // the reference is empty, indicating that it isn't necessary to
48 // store state on the stack for keeping track of references to those. 90 // store state on the stack for keeping track of references to those.
49 // For properties, we keep either one (named) or two (indexed) values 91 // For properties, we keep either one (named) or two (indexed) values
50 // on the execution stack to represent the reference. 92 // on the execution stack to represent the reference.
51 93
52 enum InitState { CONST_INIT, NOT_CONST_INIT };
53 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
54
55 class Reference BASE_EMBEDDED { 94 class Reference BASE_EMBEDDED {
56 public: 95 public:
57 // The values of the types is important, see size(). 96 // The values of the types is important, see size().
58 enum Type { ILLEGAL = -1, SLOT = 0, NAMED = 1, KEYED = 2 }; 97 enum Type { ILLEGAL = -1, SLOT = 0, NAMED = 1, KEYED = 2 };
59 Reference(CodeGenerator* cgen, Expression* expression); 98 Reference(CodeGenerator* cgen, Expression* expression);
60 ~Reference(); 99 ~Reference();
61 100
62 Expression* expression() const { return expression_; } 101 Expression* expression() const { return expression_; }
63 Type type() const { return type_; } 102 Type type() const { return type_; }
64 void set_type(Type value) { 103 void set_type(Type value) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 165
127 private: 166 private:
128 CodeGenerator* owner_; 167 CodeGenerator* owner_;
129 TypeofState typeof_state_; 168 TypeofState typeof_state_;
130 Label* true_target_; 169 Label* true_target_;
131 Label* false_target_; 170 Label* false_target_;
132 CodeGenState* previous_; 171 CodeGenState* previous_;
133 }; 172 };
134 173
135 174
136 // ----------------------------------------------------------------------------- 175 // -------------------------------------------------------------------------
137 // CodeGenerator 176 // CodeGenerator
138 177
139 class CodeGenerator: public Visitor { 178 class CodeGenerator: public Visitor {
140 public: 179 public:
141 // Takes a function literal, generates code for it. This function should only 180 // Takes a function literal, generates code for it. This function should only
142 // be called by compiler.cc. 181 // be called by compiler.cc.
143 static Handle<Code> MakeCode(FunctionLiteral* fun, 182 static Handle<Code> MakeCode(FunctionLiteral* fun,
144 Handle<Script> script, 183 Handle<Script> script,
145 bool is_eval); 184 bool is_eval);
146 185
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 NODE_LIST(DEF_VISIT) 225 NODE_LIST(DEF_VISIT)
187 #undef DEF_VISIT 226 #undef DEF_VISIT
188 227
189 // Main code generation function 228 // Main code generation function
190 void GenCode(FunctionLiteral* fun); 229 void GenCode(FunctionLiteral* fun);
191 230
192 // The following are used by class Reference. 231 // The following are used by class Reference.
193 void LoadReference(Reference* ref); 232 void LoadReference(Reference* ref);
194 void UnloadReference(Reference* ref); 233 void UnloadReference(Reference* ref);
195 234
196 // Support functions for accessing parameters and other operands.
197 MemOperand ParameterOperand(int index) const {
198 int num_parameters = scope()->num_parameters();
199 // index -2 corresponds to the activated closure, -1 corresponds
200 // to the receiver
201 ASSERT(-2 <= index && index < num_parameters);
202 int offset = (1 + num_parameters - index) * kPointerSize;
203 return MemOperand(fp, offset);
204 }
205
206 MemOperand FunctionOperand() const {
207 return MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset);
208 }
209
210 MemOperand ContextOperand(Register context, int index) const { 235 MemOperand ContextOperand(Register context, int index) const {
211 return MemOperand(context, Context::SlotOffset(index)); 236 return MemOperand(context, Context::SlotOffset(index));
212 } 237 }
213 238
214 MemOperand SlotOperand(Slot* slot, Register tmp); 239 MemOperand SlotOperand(Slot* slot, Register tmp);
215 240
216 // Expressions 241 // Expressions
217 MemOperand GlobalObject() const { 242 MemOperand GlobalObject() const {
218 return ContextOperand(cp, Context::GLOBAL_INDEX); 243 return ContextOperand(cp, Context::GLOBAL_INDEX);
219 } 244 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 373
349 bool is_eval_; // Tells whether code is generated for eval. 374 bool is_eval_; // Tells whether code is generated for eval.
350 Handle<Script> script_; 375 Handle<Script> script_;
351 List<DeferredCode*> deferred_; 376 List<DeferredCode*> deferred_;
352 377
353 // Assembler 378 // Assembler
354 MacroAssembler* masm_; // to generate code 379 MacroAssembler* masm_; // to generate code
355 380
356 // Code generation state 381 // Code generation state
357 Scope* scope_; 382 Scope* scope_;
383 VirtualFrame* frame_;
358 Condition cc_reg_; 384 Condition cc_reg_;
359 CodeGenState* state_; 385 CodeGenState* state_;
360 bool is_inside_try_; 386 bool is_inside_try_;
361 int break_stack_height_; 387 int break_stack_height_;
362 388
363 // Labels 389 // Labels
364 Label function_return_; 390 Label function_return_;
365 391
392 friend class VirtualFrame;
366 friend class Reference; 393 friend class Reference;
367 friend class Property;
368 friend class VariableProxy;
369 friend class Slot;
370 394
371 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); 395 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
372 }; 396 };
373 397
374 } } // namespace v8::internal 398 } } // namespace v8::internal
375 399
376 #endif // V8_CODEGEN_ARM_H_ 400 #endif // V8_CODEGEN_ARM_H_
OLDNEW
« no previous file with comments | « no previous file | src/codegen-arm.cc » ('j') | src/codegen-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698