OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 : expr_(expr), parent_(parent) { } | 267 : expr_(expr), parent_(parent) { } |
268 | 268 |
269 Expression* expr() const { return expr_; } | 269 Expression* expr() const { return expr_; } |
270 ForwardBailoutStack* parent() const { return parent_; } | 270 ForwardBailoutStack* parent() const { return parent_; } |
271 | 271 |
272 private: | 272 private: |
273 Expression* const expr_; | 273 Expression* const expr_; |
274 ForwardBailoutStack* const parent_; | 274 ForwardBailoutStack* const parent_; |
275 }; | 275 }; |
276 | 276 |
277 enum ConstantOperand { | |
278 kNoConstants, | |
279 kLeftConstant, | |
280 kRightConstant | |
281 }; | |
282 | |
283 // Type of a member function that generates inline code for a native function. | 277 // Type of a member function that generates inline code for a native function. |
284 typedef void (FullCodeGenerator::*InlineFunctionGenerator) | 278 typedef void (FullCodeGenerator::*InlineFunctionGenerator) |
285 (ZoneList<Expression*>*); | 279 (ZoneList<Expression*>*); |
286 | 280 |
287 static const InlineFunctionGenerator kInlineFunctionGenerators[]; | 281 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
288 | 282 |
289 // A platform-specific utility to overwrite the accumulator register | 283 // A platform-specific utility to overwrite the accumulator register |
290 // with a GC-safe value. | 284 // with a GC-safe value. |
291 void ClearAccumulator(); | 285 void ClearAccumulator(); |
292 | 286 |
293 // Compute the frame pointer relative offset for a given local or | 287 // Compute the frame pointer relative offset for a given local or |
294 // parameter slot. | 288 // parameter slot. |
295 int SlotOffset(Slot* slot); | 289 int SlotOffset(Slot* slot); |
296 | 290 |
297 // Determine whether or not to inline the smi case for the given | 291 // Determine whether or not to inline the smi case for the given |
298 // operation. | 292 // operation. |
299 bool ShouldInlineSmiCase(Token::Value op); | 293 bool ShouldInlineSmiCase(Token::Value op); |
300 | 294 |
301 // Compute which (if any) of the operands is a compile-time constant. | |
302 ConstantOperand GetConstantOperand(Token::Value op, | |
303 Expression* left, | |
304 Expression* right); | |
305 | |
306 // Helper function to convert a pure value into a test context. The value | 295 // Helper function to convert a pure value into a test context. The value |
307 // is expected on the stack or the accumulator, depending on the platform. | 296 // is expected on the stack or the accumulator, depending on the platform. |
308 // See the platform-specific implementation for details. | 297 // See the platform-specific implementation for details. |
309 void DoTest(Label* if_true, Label* if_false, Label* fall_through); | 298 void DoTest(Label* if_true, Label* if_false, Label* fall_through); |
310 | 299 |
311 // Helper function to split control flow and avoid a branch to the | 300 // Helper function to split control flow and avoid a branch to the |
312 // fall-through label if it is set up. | 301 // fall-through label if it is set up. |
313 void Split(Condition cc, | 302 void Split(Condition cc, |
314 Label* if_true, | 303 Label* if_true, |
315 Label* if_false, | 304 Label* if_false, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // of the stack and the right one in the accumulator. | 439 // of the stack and the right one in the accumulator. |
451 void EmitBinaryOp(Token::Value op, | 440 void EmitBinaryOp(Token::Value op, |
452 OverwriteMode mode); | 441 OverwriteMode mode); |
453 | 442 |
454 // Helper functions for generating inlined smi code for certain | 443 // Helper functions for generating inlined smi code for certain |
455 // binary operations. | 444 // binary operations. |
456 void EmitInlineSmiBinaryOp(Expression* expr, | 445 void EmitInlineSmiBinaryOp(Expression* expr, |
457 Token::Value op, | 446 Token::Value op, |
458 OverwriteMode mode, | 447 OverwriteMode mode, |
459 Expression* left, | 448 Expression* left, |
460 Expression* right, | 449 Expression* right); |
461 ConstantOperand constant); | |
462 | |
463 void EmitConstantSmiBinaryOp(Expression* expr, | |
464 Token::Value op, | |
465 OverwriteMode mode, | |
466 bool left_is_constant_smi, | |
467 Smi* value); | |
468 | |
469 void EmitConstantSmiBitOp(Expression* expr, | |
470 Token::Value op, | |
471 OverwriteMode mode, | |
472 Smi* value); | |
473 | |
474 void EmitConstantSmiShiftOp(Expression* expr, | |
475 Token::Value op, | |
476 OverwriteMode mode, | |
477 Smi* value); | |
478 | |
479 void EmitConstantSmiAdd(Expression* expr, | |
480 OverwriteMode mode, | |
481 bool left_is_constant_smi, | |
482 Smi* value); | |
483 | |
484 void EmitConstantSmiSub(Expression* expr, | |
485 OverwriteMode mode, | |
486 bool left_is_constant_smi, | |
487 Smi* value); | |
488 | 450 |
489 // Assign to the given expression as if via '='. The right-hand-side value | 451 // Assign to the given expression as if via '='. The right-hand-side value |
490 // is expected in the accumulator. | 452 // is expected in the accumulator. |
491 void EmitAssignment(Expression* expr, int bailout_ast_id); | 453 void EmitAssignment(Expression* expr, int bailout_ast_id); |
492 | 454 |
493 // Complete a variable assignment. The right-hand-side value is expected | 455 // Complete a variable assignment. The right-hand-side value is expected |
494 // in the accumulator. | 456 // in the accumulator. |
495 void EmitVariableAssignment(Variable* var, | 457 void EmitVariableAssignment(Variable* var, |
496 Token::Value op); | 458 Token::Value op); |
497 | 459 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 | 734 |
773 friend class NestedStatement; | 735 friend class NestedStatement; |
774 | 736 |
775 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 737 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
776 }; | 738 }; |
777 | 739 |
778 | 740 |
779 } } // namespace v8::internal | 741 } } // namespace v8::internal |
780 | 742 |
781 #endif // V8_FULL_CODEGEN_H_ | 743 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |