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