| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 virtual ~CodeGenerator() { delete masm_; } | 214 virtual ~CodeGenerator() { delete masm_; } |
| 215 | 215 |
| 216 // Accessors | 216 // Accessors |
| 217 Scope* scope() const { return scope_; } | 217 Scope* scope() const { return scope_; } |
| 218 | 218 |
| 219 void ProcessDeferred(); | 219 void ProcessDeferred(); |
| 220 | 220 |
| 221 bool is_eval() { return is_eval_; } | 221 bool is_eval() { return is_eval_; } |
| 222 | 222 |
| 223 // State | 223 // State |
| 224 bool has_cc() const { return cc_reg_ >= 0; } | |
| 225 TypeofState typeof_state() const { return state_->typeof_state(); } | 224 TypeofState typeof_state() const { return state_->typeof_state(); } |
| 226 JumpTarget* true_target() const { return state_->true_target(); } | 225 JumpTarget* true_target() const { return state_->true_target(); } |
| 227 JumpTarget* false_target() const { return state_->false_target(); } | 226 JumpTarget* false_target() const { return state_->false_target(); } |
| 228 | 227 |
| 229 // Track loop nesting level. | 228 // Track loop nesting level. |
| 230 int loop_nesting() const { return loop_nesting_; } | 229 int loop_nesting() const { return loop_nesting_; } |
| 231 void IncrementLoopNesting() { loop_nesting_++; } | 230 void IncrementLoopNesting() { loop_nesting_++; } |
| 232 void DecrementLoopNesting() { loop_nesting_--; } | 231 void DecrementLoopNesting() { loop_nesting_--; } |
| 233 | 232 |
| 234 | 233 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 287 |
| 289 // Expressions | 288 // Expressions |
| 290 Operand GlobalObject() const { | 289 Operand GlobalObject() const { |
| 291 return ContextOperand(esi, Context::GLOBAL_INDEX); | 290 return ContextOperand(esi, Context::GLOBAL_INDEX); |
| 292 } | 291 } |
| 293 | 292 |
| 294 void LoadCondition(Expression* x, | 293 void LoadCondition(Expression* x, |
| 295 TypeofState typeof_state, | 294 TypeofState typeof_state, |
| 296 JumpTarget* true_target, | 295 JumpTarget* true_target, |
| 297 JumpTarget* false_target, | 296 JumpTarget* false_target, |
| 298 bool force_cc); | 297 bool force_control); |
| 299 void Load(Expression* x, TypeofState typeof_state = NOT_INSIDE_TYPEOF); | 298 void Load(Expression* x, TypeofState typeof_state = NOT_INSIDE_TYPEOF); |
| 300 void LoadGlobal(); | 299 void LoadGlobal(); |
| 301 void LoadGlobalReceiver(); | 300 void LoadGlobalReceiver(); |
| 302 | 301 |
| 303 // Generate code to push the value of an expression on top of the frame | 302 // Generate code to push the value of an expression on top of the frame |
| 304 // and then spill the frame fully to memory. This function is used | 303 // and then spill the frame fully to memory. This function is used |
| 305 // temporarily while the code generator is being transformed. | 304 // temporarily while the code generator is being transformed. |
| 306 void LoadAndSpill(Expression* expression, | 305 void LoadAndSpill(Expression* expression, |
| 307 TypeofState typeof_state = NOT_INSIDE_TYPEOF) { | 306 TypeofState typeof_state = NOT_INSIDE_TYPEOF) { |
| 308 ASSERT(in_spilled_code()); | 307 ASSERT(in_spilled_code()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // look like an explicit property access, instead of an access | 343 // look like an explicit property access, instead of an access |
| 345 // through the context chain. | 344 // through the context chain. |
| 346 void LoadTypeofExpression(Expression* x); | 345 void LoadTypeofExpression(Expression* x); |
| 347 | 346 |
| 348 void ToBoolean(JumpTarget* true_target, JumpTarget* false_target); | 347 void ToBoolean(JumpTarget* true_target, JumpTarget* false_target); |
| 349 | 348 |
| 350 void GenericBinaryOperation(Token::Value op, | 349 void GenericBinaryOperation(Token::Value op, |
| 351 StaticType* type, | 350 StaticType* type, |
| 352 const OverwriteMode overwrite_mode = NO_OVERWRITE); | 351 const OverwriteMode overwrite_mode = NO_OVERWRITE); |
| 353 | 352 |
| 354 void Comparison(Condition cc, bool strict = false); | 353 void Comparison(Condition cc, |
| 354 bool strict, |
| 355 JumpTarget* true_target, |
| 356 JumpTarget* false_target); |
| 355 | 357 |
| 356 // Inline small integer literals. To prevent long attacker-controlled byte | 358 // Inline small integer literals. To prevent long attacker-controlled byte |
| 357 // sequences, we only inline small Smis. | 359 // sequences, we only inline small Smis. |
| 358 static const int kMaxSmiInlinedBits = 16; | 360 static const int kMaxSmiInlinedBits = 16; |
| 359 bool IsInlineSmi(Literal* literal); | 361 bool IsInlineSmi(Literal* literal); |
| 360 void SmiComparison(Condition cc, Handle<Object> value, bool strict = false); | 362 void SmiComparison(Condition cc, Handle<Object> value, bool strict = false); |
| 361 void SmiOperation(Token::Value op, | 363 void SmiOperation(Token::Value op, |
| 362 StaticType* type, | 364 StaticType* type, |
| 363 Handle<Object> value, | 365 Handle<Object> value, |
| 364 bool reversed, | 366 bool reversed, |
| 365 OverwriteMode overwrite_mode); | 367 OverwriteMode overwrite_mode); |
| 366 | 368 |
| 367 void CallWithArguments(ZoneList<Expression*>* arguments, int position); | 369 void CallWithArguments(ZoneList<Expression*>* arguments, int position); |
| 368 | 370 |
| 369 // Control flow | |
| 370 void Branch(bool if_true, JumpTarget* target); | |
| 371 void CheckStack(); | 371 void CheckStack(); |
| 372 void CleanStack(int num_bytes); | 372 void CleanStack(int num_bytes); |
| 373 | 373 |
| 374 bool CheckForInlineRuntimeCall(CallRuntime* node); | 374 bool CheckForInlineRuntimeCall(CallRuntime* node); |
| 375 Handle<JSFunction> BuildBoilerplate(FunctionLiteral* node); | 375 Handle<JSFunction> BuildBoilerplate(FunctionLiteral* node); |
| 376 void ProcessDeclarations(ZoneList<Declaration*>* declarations); | 376 void ProcessDeclarations(ZoneList<Declaration*>* declarations); |
| 377 | 377 |
| 378 Handle<Code> ComputeCallInitialize(int argc); | 378 Handle<Code> ComputeCallInitialize(int argc); |
| 379 Handle<Code> ComputeCallInitializeInLoop(int argc); | 379 Handle<Code> ComputeCallInitializeInLoop(int argc); |
| 380 | 380 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 Handle<Script> script_; | 476 Handle<Script> script_; |
| 477 List<DeferredCode*> deferred_; | 477 List<DeferredCode*> deferred_; |
| 478 | 478 |
| 479 // Assembler | 479 // Assembler |
| 480 MacroAssembler* masm_; // to generate code | 480 MacroAssembler* masm_; // to generate code |
| 481 | 481 |
| 482 // Code generation state | 482 // Code generation state |
| 483 Scope* scope_; | 483 Scope* scope_; |
| 484 VirtualFrame* frame_; | 484 VirtualFrame* frame_; |
| 485 RegisterAllocator* allocator_; | 485 RegisterAllocator* allocator_; |
| 486 Condition cc_reg_; | |
| 487 CodeGenState* state_; | 486 CodeGenState* state_; |
| 488 int break_stack_height_; | 487 int break_stack_height_; |
| 489 int loop_nesting_; | 488 int loop_nesting_; |
| 490 | 489 |
| 491 // Jump targets. | 490 // Jump targets. |
| 492 // The target of the return from the function. | 491 // The target of the return from the function. |
| 493 JumpTarget function_return_; | 492 JumpTarget function_return_; |
| 494 | 493 |
| 495 // True if the function return is shadowed (ie, jumping to the target | 494 // True if the function return is shadowed (ie, jumping to the target |
| 496 // function_return_ does not jump to the true function return, but rather | 495 // function_return_ does not jump to the true function return, but rather |
| (...skipping 19 matching lines...) Expand all Loading... |
| 516 cgen_->set_in_spilled_code(false); | 515 cgen_->set_in_spilled_code(false); |
| 517 GetValue(typeof_state); | 516 GetValue(typeof_state); |
| 518 cgen_->frame()->SpillAll(); | 517 cgen_->frame()->SpillAll(); |
| 519 cgen_->set_in_spilled_code(true); | 518 cgen_->set_in_spilled_code(true); |
| 520 } | 519 } |
| 521 | 520 |
| 522 | 521 |
| 523 } } // namespace v8::internal | 522 } } // namespace v8::internal |
| 524 | 523 |
| 525 #endif // V8_CODEGEN_IA32_H_ | 524 #endif // V8_CODEGEN_IA32_H_ |
| OLD | NEW |