| 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 520 |
| 521 // Fast support for Math.random(). | 521 // Fast support for Math.random(). |
| 522 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); | 522 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); |
| 523 | 523 |
| 524 // Fast support for Math.sin and Math.cos. | 524 // Fast support for Math.sin and Math.cos. |
| 525 enum MathOp { SIN, COS }; | 525 enum MathOp { SIN, COS }; |
| 526 void GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args); | 526 void GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args); |
| 527 inline void GenerateMathSin(ZoneList<Expression*>* args); | 527 inline void GenerateMathSin(ZoneList<Expression*>* args); |
| 528 inline void GenerateMathCos(ZoneList<Expression*>* args); | 528 inline void GenerateMathCos(ZoneList<Expression*>* args); |
| 529 | 529 |
| 530 // Methods and constants for fast case switch statement support. | |
| 531 // | |
| 532 // Only allow fast-case switch if the range of labels is at most | |
| 533 // this factor times the number of case labels. | |
| 534 // Value is derived from comparing the size of code generated by the normal | |
| 535 // switch code for Smi-labels to the size of a single pointer. If code | |
| 536 // quality increases this number should be decreased to match. | |
| 537 static const int kFastSwitchMaxOverheadFactor = 5; | |
| 538 | |
| 539 // Minimal number of switch cases required before we allow jump-table | |
| 540 // optimization. | |
| 541 static const int kFastSwitchMinCaseCount = 5; | |
| 542 | |
| 543 // The limit of the range of a fast-case switch, as a factor of the number | |
| 544 // of cases of the switch. Each platform should return a value that | |
| 545 // is optimal compared to the default code generated for a switch statement | |
| 546 // on that platform. | |
| 547 int FastCaseSwitchMaxOverheadFactor(); | |
| 548 | |
| 549 // The minimal number of cases in a switch before the fast-case switch | |
| 550 // optimization is enabled. Each platform should return a value that | |
| 551 // is optimal compared to the default code generated for a switch statement | |
| 552 // on that platform. | |
| 553 int FastCaseSwitchMinCaseCount(); | |
| 554 | |
| 555 // Allocate a jump table and create code to jump through it. | |
| 556 // Should call GenerateFastCaseSwitchCases to generate the code for | |
| 557 // all the cases at the appropriate point. | |
| 558 void GenerateFastCaseSwitchJumpTable(SwitchStatement* node, | |
| 559 int min_index, | |
| 560 int range, | |
| 561 Label* fail_label, | |
| 562 Vector<Label*> case_targets, | |
| 563 Vector<Label> case_labels); | |
| 564 | |
| 565 // Generate the code for cases for the fast case switch. | |
| 566 // Called by GenerateFastCaseSwitchJumpTable. | |
| 567 void GenerateFastCaseSwitchCases(SwitchStatement* node, | |
| 568 Vector<Label> case_labels, | |
| 569 VirtualFrame* start_frame); | |
| 570 | |
| 571 // Fast support for constant-Smi switches. | |
| 572 void GenerateFastCaseSwitchStatement(SwitchStatement* node, | |
| 573 int min_index, | |
| 574 int range, | |
| 575 int default_index); | |
| 576 | |
| 577 // Fast support for constant-Smi switches. Tests whether switch statement | |
| 578 // permits optimization and calls GenerateFastCaseSwitch if it does. | |
| 579 // Returns true if the fast-case switch was generated, and false if not. | |
| 580 bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node); | |
| 581 | |
| 582 // Methods used to indicate which source code is generated for. Source | 530 // Methods used to indicate which source code is generated for. Source |
| 583 // positions are collected by the assembler and emitted with the relocation | 531 // positions are collected by the assembler and emitted with the relocation |
| 584 // information. | 532 // information. |
| 585 void CodeForFunctionPosition(FunctionLiteral* fun); | 533 void CodeForFunctionPosition(FunctionLiteral* fun); |
| 586 void CodeForReturnPosition(FunctionLiteral* fun); | 534 void CodeForReturnPosition(FunctionLiteral* fun); |
| 587 void CodeForStatementPosition(Node* node); | 535 void CodeForStatementPosition(Node* node); |
| 588 void CodeForSourcePosition(int pos); | 536 void CodeForSourcePosition(int pos); |
| 589 | 537 |
| 590 #ifdef DEBUG | 538 #ifdef DEBUG |
| 591 // True if the registers are valid for entry to a block. There should | 539 // True if the registers are valid for entry to a block. There should |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 579 |
| 632 friend class CodeGeneratorPatcher; // Used in test-log-ia32.cc | 580 friend class CodeGeneratorPatcher; // Used in test-log-ia32.cc |
| 633 | 581 |
| 634 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 582 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 635 }; | 583 }; |
| 636 | 584 |
| 637 | 585 |
| 638 } } // namespace v8::internal | 586 } } // namespace v8::internal |
| 639 | 587 |
| 640 #endif // V8_IA32_CODEGEN_IA32_H_ | 588 #endif // V8_IA32_CODEGEN_IA32_H_ |
| OLD | NEW |