OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; | 42 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
43 | 43 |
44 | 44 |
45 // ------------------------------------------------------------------------- | 45 // ------------------------------------------------------------------------- |
46 // Virtual frame | 46 // Virtual frame |
47 | 47 |
48 class VirtualFrame BASE_EMBEDDED { | 48 class VirtualFrame BASE_EMBEDDED { |
49 public: | 49 public: |
50 explicit VirtualFrame(CodeGenerator* cgen); | 50 explicit VirtualFrame(CodeGenerator* cgen); |
51 | 51 |
| 52 void Enter(); |
| 53 void Exit(); |
| 54 |
| 55 void AllocateLocals(); |
| 56 |
52 MemOperand Top() const { return MemOperand(sp, 0); } | 57 MemOperand Top() const { return MemOperand(sp, 0); } |
53 | 58 |
54 MemOperand Element(int index) const { | 59 MemOperand Element(int index) const { |
55 return MemOperand(sp, index * kPointerSize); | 60 return MemOperand(sp, index * kPointerSize); |
56 } | 61 } |
57 | 62 |
58 MemOperand Local(int index) const { | 63 MemOperand Local(int index) const { |
59 ASSERT(0 <= index && index < frame_local_count_); | 64 ASSERT(0 <= index && index < frame_local_count_); |
60 return MemOperand(fp, kLocal0Offset - index * kPointerSize); | 65 return MemOperand(fp, kLocal0Offset - index * kPointerSize); |
61 } | 66 } |
62 | 67 |
63 MemOperand Function() const { return MemOperand(fp, kFunctionOffset); } | 68 MemOperand Function() const { return MemOperand(fp, kFunctionOffset); } |
64 | 69 |
65 MemOperand Context() const { return MemOperand(fp, kContextOffset); } | 70 MemOperand Context() const { return MemOperand(fp, kContextOffset); } |
66 | 71 |
67 MemOperand Parameter(int index) const { | 72 MemOperand Parameter(int index) const { |
68 // Index -1 corresponds to the receiver. | 73 // Index -1 corresponds to the receiver. |
69 ASSERT(-1 <= index && index <= parameter_count_); | 74 ASSERT(-1 <= index && index <= parameter_count_); |
70 return MemOperand(fp, (1 + parameter_count_ - index) * kPointerSize); | 75 return MemOperand(fp, (1 + parameter_count_ - index) * kPointerSize); |
71 } | 76 } |
72 | 77 |
| 78 inline void Drop(int count); |
| 79 |
| 80 inline void Pop(); |
| 81 inline void Pop(Register reg); |
| 82 |
| 83 inline void Push(Register reg); |
| 84 |
73 private: | 85 private: |
74 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; | 86 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; |
75 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; | 87 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; |
76 static const int kContextOffset = StandardFrameConstants::kContextOffset; | 88 static const int kContextOffset = StandardFrameConstants::kContextOffset; |
77 | 89 |
78 MacroAssembler* masm_; | 90 MacroAssembler* masm_; |
79 int frame_local_count_; | 91 int frame_local_count_; |
80 int parameter_count_; | 92 int parameter_count_; |
81 }; | 93 }; |
82 | 94 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 int function_token_position, | 200 int function_token_position, |
189 int start_position, | 201 int start_position, |
190 int end_position, | 202 int end_position, |
191 bool is_expression, | 203 bool is_expression, |
192 bool is_toplevel, | 204 bool is_toplevel, |
193 Handle<Script> script); | 205 Handle<Script> script); |
194 | 206 |
195 // Accessors | 207 // Accessors |
196 MacroAssembler* masm() { return masm_; } | 208 MacroAssembler* masm() { return masm_; } |
197 | 209 |
| 210 VirtualFrame* frame() const { return frame_; } |
| 211 |
198 CodeGenState* state() { return state_; } | 212 CodeGenState* state() { return state_; } |
199 void set_state(CodeGenState* state) { state_ = state; } | 213 void set_state(CodeGenState* state) { state_ = state; } |
200 | 214 |
201 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } | 215 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
202 | 216 |
203 private: | 217 private: |
204 // Construction/Destruction | 218 // Construction/Destruction |
205 CodeGenerator(int buffer_size, Handle<Script> script, bool is_eval); | 219 CodeGenerator(int buffer_size, Handle<Script> script, bool is_eval); |
206 virtual ~CodeGenerator() { delete masm_; } | 220 virtual ~CodeGenerator() { delete masm_; } |
207 | 221 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // permits optimization and calls GenerateFastCaseSwitch if it does. | 373 // permits optimization and calls GenerateFastCaseSwitch if it does. |
360 // Returns true if the fast-case switch was generated, and false if not. | 374 // Returns true if the fast-case switch was generated, and false if not. |
361 bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node); | 375 bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node); |
362 | 376 |
363 | 377 |
364 // Bottle-neck interface to call the Assembler to generate the statement | 378 // Bottle-neck interface to call the Assembler to generate the statement |
365 // position. This allows us to easily control whether statement positions | 379 // position. This allows us to easily control whether statement positions |
366 // should be generated or not. | 380 // should be generated or not. |
367 void RecordStatementPosition(Node* node); | 381 void RecordStatementPosition(Node* node); |
368 | 382 |
369 // Activation frames. | |
370 void EnterJSFrame(); | |
371 void ExitJSFrame(); | |
372 | |
373 | |
374 bool is_eval_; // Tells whether code is generated for eval. | 383 bool is_eval_; // Tells whether code is generated for eval. |
375 Handle<Script> script_; | 384 Handle<Script> script_; |
376 List<DeferredCode*> deferred_; | 385 List<DeferredCode*> deferred_; |
377 | 386 |
378 // Assembler | 387 // Assembler |
379 MacroAssembler* masm_; // to generate code | 388 MacroAssembler* masm_; // to generate code |
380 | 389 |
381 // Code generation state | 390 // Code generation state |
382 Scope* scope_; | 391 Scope* scope_; |
383 VirtualFrame* frame_; | 392 VirtualFrame* frame_; |
384 Condition cc_reg_; | 393 Condition cc_reg_; |
385 CodeGenState* state_; | 394 CodeGenState* state_; |
386 bool is_inside_try_; | 395 bool is_inside_try_; |
387 int break_stack_height_; | 396 int break_stack_height_; |
388 | 397 |
389 // Labels | 398 // Labels |
390 Label function_return_; | 399 Label function_return_; |
391 | 400 |
392 friend class VirtualFrame; | 401 friend class VirtualFrame; |
393 friend class Reference; | 402 friend class Reference; |
394 | 403 |
395 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 404 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
396 }; | 405 }; |
397 | 406 |
398 } } // namespace v8::internal | 407 } } // namespace v8::internal |
399 | 408 |
400 #endif // V8_CODEGEN_ARM_H_ | 409 #endif // V8_CODEGEN_ARM_H_ |
OLD | NEW |