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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 // Fast support for Math.random(). | 352 // Fast support for Math.random(). |
353 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); | 353 void GenerateRandomPositiveSmi(ZoneList<Expression*>* args); |
354 | 354 |
355 // Fast support for Math.sin and Math.cos. | 355 // Fast support for Math.sin and Math.cos. |
356 enum MathOp { SIN, COS }; | 356 enum MathOp { SIN, COS }; |
357 void GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args); | 357 void GenerateFastMathOp(MathOp op, ZoneList<Expression*>* args); |
358 inline void GenerateMathSin(ZoneList<Expression*>* args); | 358 inline void GenerateMathSin(ZoneList<Expression*>* args); |
359 inline void GenerateMathCos(ZoneList<Expression*>* args); | 359 inline void GenerateMathCos(ZoneList<Expression*>* args); |
360 | 360 |
361 // Methods and constants for fast case switch statement support. | |
362 // | |
363 // Only allow fast-case switch if the range of labels is at most | |
364 // this factor times the number of case labels. | |
365 // Value is derived from comparing the size of code generated by the normal | |
366 // switch code for Smi-labels to the size of a single pointer. If code | |
367 // quality increases this number should be decreased to match. | |
368 static const int kFastSwitchMaxOverheadFactor = 10; | |
369 | |
370 // Minimal number of switch cases required before we allow jump-table | |
371 // optimization. | |
372 static const int kFastSwitchMinCaseCount = 5; | |
373 | |
374 // The limit of the range of a fast-case switch, as a factor of the number | |
375 // of cases of the switch. Each platform should return a value that | |
376 // is optimal compared to the default code generated for a switch statement | |
377 // on that platform. | |
378 int FastCaseSwitchMaxOverheadFactor(); | |
379 | |
380 // The minimal number of cases in a switch before the fast-case switch | |
381 // optimization is enabled. Each platform should return a value that | |
382 // is optimal compared to the default code generated for a switch statement | |
383 // on that platform. | |
384 int FastCaseSwitchMinCaseCount(); | |
385 | |
386 // Allocate a jump table and create code to jump through it. | |
387 // Should call GenerateFastCaseSwitchCases to generate the code for | |
388 // all the cases at the appropriate point. | |
389 void GenerateFastCaseSwitchJumpTable(SwitchStatement* node, | |
390 int min_index, | |
391 int range, | |
392 Label* default_label, | |
393 Vector<Label*> case_targets, | |
394 Vector<Label> case_labels); | |
395 | |
396 // Generate the code for cases for the fast case switch. | |
397 // Called by GenerateFastCaseSwitchJumpTable. | |
398 void GenerateFastCaseSwitchCases(SwitchStatement* node, | |
399 Vector<Label> case_labels, | |
400 VirtualFrame* start_frame); | |
401 | |
402 // Fast support for constant-Smi switches. | |
403 void GenerateFastCaseSwitchStatement(SwitchStatement* node, | |
404 int min_index, | |
405 int range, | |
406 int default_index); | |
407 | |
408 // Fast support for constant-Smi switches. Tests whether switch statement | |
409 // permits optimization and calls GenerateFastCaseSwitch if it does. | |
410 // Returns true if the fast-case switch was generated, and false if not. | |
411 bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node); | |
412 | |
413 | |
414 // Methods used to indicate which source code is generated for. Source | 361 // Methods used to indicate which source code is generated for. Source |
415 // positions are collected by the assembler and emitted with the relocation | 362 // positions are collected by the assembler and emitted with the relocation |
416 // information. | 363 // information. |
417 void CodeForFunctionPosition(FunctionLiteral* fun); | 364 void CodeForFunctionPosition(FunctionLiteral* fun); |
418 void CodeForReturnPosition(FunctionLiteral* fun); | 365 void CodeForReturnPosition(FunctionLiteral* fun); |
419 void CodeForStatementPosition(Node* node); | 366 void CodeForStatementPosition(Node* node); |
420 void CodeForSourcePosition(int pos); | 367 void CodeForSourcePosition(int pos); |
421 | 368 |
422 #ifdef DEBUG | 369 #ifdef DEBUG |
423 // True if the registers are valid for entry to a block. | 370 // True if the registers are valid for entry to a block. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 friend class JumpTarget; | 406 friend class JumpTarget; |
460 friend class Reference; | 407 friend class Reference; |
461 | 408 |
462 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 409 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
463 }; | 410 }; |
464 | 411 |
465 | 412 |
466 } } // namespace v8::internal | 413 } } // namespace v8::internal |
467 | 414 |
468 #endif // V8_ARM_CODEGEN_ARM_H_ | 415 #endif // V8_ARM_CODEGEN_ARM_H_ |
OLD | NEW |