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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 void ProcessDeferred(); | 231 void ProcessDeferred(); |
232 | 232 |
233 bool is_eval() { return is_eval_; } | 233 bool is_eval() { return is_eval_; } |
234 | 234 |
235 // State | 235 // State |
236 bool has_cc() const { return cc_reg_ >= 0; } | 236 bool has_cc() const { return cc_reg_ >= 0; } |
237 TypeofState typeof_state() const { return state_->typeof_state(); } | 237 TypeofState typeof_state() const { return state_->typeof_state(); } |
238 Label* true_target() const { return state_->true_target(); } | 238 Label* true_target() const { return state_->true_target(); } |
239 Label* false_target() const { return state_->false_target(); } | 239 Label* false_target() const { return state_->false_target(); } |
240 | 240 |
| 241 // Track loop nesting level. |
| 242 int loop_nesting() const { return loop_nesting_; } |
| 243 void IncrementLoopNesting() { loop_nesting_++; } |
| 244 void DecrementLoopNesting() { loop_nesting_--; } |
| 245 |
241 | 246 |
242 // Node visitors. | 247 // Node visitors. |
243 #define DEF_VISIT(type) \ | 248 #define DEF_VISIT(type) \ |
244 void Visit##type(type* node); | 249 void Visit##type(type* node); |
245 NODE_LIST(DEF_VISIT) | 250 NODE_LIST(DEF_VISIT) |
246 #undef DEF_VISIT | 251 #undef DEF_VISIT |
247 | 252 |
248 // Main code generation function | 253 // Main code generation function |
249 void GenCode(FunctionLiteral* fun); | 254 void GenCode(FunctionLiteral* fun); |
250 | 255 |
(...skipping 29 matching lines...) Expand all Loading... |
280 // be careful when loading the expression in 'typeof' | 285 // be careful when loading the expression in 'typeof' |
281 // expressions. We are not allowed to throw reference errors for | 286 // expressions. We are not allowed to throw reference errors for |
282 // non-existing properties of the global object, so we must make it | 287 // non-existing properties of the global object, so we must make it |
283 // look like an explicit property access, instead of an access | 288 // look like an explicit property access, instead of an access |
284 // through the context chain. | 289 // through the context chain. |
285 void LoadTypeofExpression(Expression* x); | 290 void LoadTypeofExpression(Expression* x); |
286 | 291 |
287 void ToBoolean(Label* true_target, Label* false_target); | 292 void ToBoolean(Label* true_target, Label* false_target); |
288 | 293 |
289 void GenericBinaryOperation(Token::Value op, | 294 void GenericBinaryOperation(Token::Value op, |
| 295 StaticType* type, |
290 const OverwriteMode overwrite_mode = NO_OVERWRITE); | 296 const OverwriteMode overwrite_mode = NO_OVERWRITE); |
291 | 297 |
292 void Comparison(Condition cc, bool strict = false); | 298 void Comparison(Condition cc, bool strict = false); |
293 | 299 |
294 // Inline small integer literals. To prevent long attacker-controlled byte | 300 // Inline small integer literals. To prevent long attacker-controlled byte |
295 // sequences, we only inline small Smis. | 301 // sequences, we only inline small Smis. |
296 static const int kMaxSmiInlinedBits = 16; | 302 static const int kMaxSmiInlinedBits = 16; |
297 bool IsInlineSmi(Literal* literal); | 303 bool IsInlineSmi(Literal* literal); |
298 void SmiComparison(Condition cc, Handle<Object> value, bool strict = false); | 304 void SmiComparison(Condition cc, Handle<Object> value, bool strict = false); |
299 void SmiOperation(Token::Value op, | 305 void SmiOperation(Token::Value op, |
| 306 StaticType* type, |
300 Handle<Object> value, | 307 Handle<Object> value, |
301 bool reversed, | 308 bool reversed, |
302 OverwriteMode overwrite_mode); | 309 OverwriteMode overwrite_mode); |
303 | 310 |
304 void CallWithArguments(ZoneList<Expression*>* arguments, int position); | 311 void CallWithArguments(ZoneList<Expression*>* arguments, int position); |
305 | 312 |
306 // Control flow | 313 // Control flow |
307 void Branch(bool if_true, Label* L); | 314 void Branch(bool if_true, Label* L); |
308 void CheckStack(); | 315 void CheckStack(); |
309 void CleanStack(int num_bytes); | 316 void CleanStack(int num_bytes); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // Assembler | 412 // Assembler |
406 MacroAssembler* masm_; // to generate code | 413 MacroAssembler* masm_; // to generate code |
407 | 414 |
408 // Code generation state | 415 // Code generation state |
409 Scope* scope_; | 416 Scope* scope_; |
410 VirtualFrame* frame_; | 417 VirtualFrame* frame_; |
411 Condition cc_reg_; | 418 Condition cc_reg_; |
412 CodeGenState* state_; | 419 CodeGenState* state_; |
413 bool is_inside_try_; | 420 bool is_inside_try_; |
414 int break_stack_height_; | 421 int break_stack_height_; |
| 422 int loop_nesting_; |
415 | 423 |
416 // Labels | 424 // Labels |
417 Label function_return_; | 425 Label function_return_; |
418 | 426 |
419 friend class VirtualFrame; | 427 friend class VirtualFrame; |
420 friend class Reference; | 428 friend class Reference; |
421 | 429 |
422 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 430 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
423 }; | 431 }; |
424 | 432 |
425 | 433 |
426 } } // namespace v8::internal | 434 } } // namespace v8::internal |
427 | 435 |
428 #endif // V8_CODEGEN_IA32_H_ | 436 #endif // V8_CODEGEN_IA32_H_ |
OLD | NEW |