Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: src/arm/codegen-arm.h

Issue 160584: Add support to the CFG builder for non-short-circuited binary... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/cfg-arm.cc ('k') | src/arm/codegen-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 static InlineRuntimeLUT kInlineRuntimeLUT[]; 414 static InlineRuntimeLUT kInlineRuntimeLUT[];
415 415
416 friend class VirtualFrame; 416 friend class VirtualFrame;
417 friend class JumpTarget; 417 friend class JumpTarget;
418 friend class Reference; 418 friend class Reference;
419 419
420 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); 420 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
421 }; 421 };
422 422
423 423
424 class GenericBinaryOpStub : public CodeStub {
425 public:
426 GenericBinaryOpStub(Token::Value op,
427 OverwriteMode mode,
428 int constant_rhs = CodeGenerator::kUnknownIntValue)
429 : op_(op),
430 mode_(mode),
431 constant_rhs_(constant_rhs),
432 specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)) { }
433
434 private:
435 Token::Value op_;
436 OverwriteMode mode_;
437 int constant_rhs_;
438 bool specialized_on_rhs_;
439
440 static const int kMaxKnownRhs = 0x40000000;
441
442 // Minor key encoding in 16 bits.
443 class ModeBits: public BitField<OverwriteMode, 0, 2> {};
444 class OpBits: public BitField<Token::Value, 2, 6> {};
445 class KnownIntBits: public BitField<int, 8, 8> {};
446
447 Major MajorKey() { return GenericBinaryOp; }
448 int MinorKey() {
449 // Encode the parameters in a unique 16 bit value.
450 return OpBits::encode(op_)
451 | ModeBits::encode(mode_)
452 | KnownIntBits::encode(MinorKeyForKnownInt());
453 }
454
455 void Generate(MacroAssembler* masm);
456 void HandleNonSmiBitwiseOp(MacroAssembler* masm);
457
458 static bool RhsIsOneWeWantToOptimizeFor(Token::Value op, int constant_rhs) {
459 if (constant_rhs == CodeGenerator::kUnknownIntValue) return false;
460 if (op == Token::DIV) return constant_rhs >= 2 && constant_rhs <= 3;
461 if (op == Token::MOD) {
462 if (constant_rhs <= 1) return false;
463 if (constant_rhs <= 10) return true;
464 if (constant_rhs <= kMaxKnownRhs && IsPowerOf2(constant_rhs)) return true;
465 return false;
466 }
467 return false;
468 }
469
470 int MinorKeyForKnownInt() {
471 if (!specialized_on_rhs_) return 0;
472 if (constant_rhs_ <= 10) return constant_rhs_ + 1;
473 ASSERT(IsPowerOf2(constant_rhs_));
474 int key = 12;
475 int d = constant_rhs_;
476 while ((d & 1) == 0) {
477 key++;
478 d >>= 1;
479 }
480 return key;
481 }
482
483 const char* GetName() {
484 switch (op_) {
485 case Token::ADD: return "GenericBinaryOpStub_ADD";
486 case Token::SUB: return "GenericBinaryOpStub_SUB";
487 case Token::MUL: return "GenericBinaryOpStub_MUL";
488 case Token::DIV: return "GenericBinaryOpStub_DIV";
489 case Token::MOD: return "GenericBinaryOpStub_MOD";
490 case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR";
491 case Token::BIT_AND: return "GenericBinaryOpStub_BIT_AND";
492 case Token::BIT_XOR: return "GenericBinaryOpStub_BIT_XOR";
493 case Token::SAR: return "GenericBinaryOpStub_SAR";
494 case Token::SHL: return "GenericBinaryOpStub_SHL";
495 case Token::SHR: return "GenericBinaryOpStub_SHR";
496 default: return "GenericBinaryOpStub";
497 }
498 }
499
500 #ifdef DEBUG
501 void Print() {
502 if (!specialized_on_rhs_) {
503 PrintF("GenericBinaryOpStub (%s)\n", Token::String(op_));
504 } else {
505 PrintF("GenericBinaryOpStub (%s by %d)\n",
506 Token::String(op_),
507 constant_rhs_);
508 }
509 }
510 #endif
511 };
512
513
424 } } // namespace v8::internal 514 } } // namespace v8::internal
425 515
426 #endif // V8_ARM_CODEGEN_ARM_H_ 516 #endif // V8_ARM_CODEGEN_ARM_H_
OLDNEW
« no previous file with comments | « src/arm/cfg-arm.cc ('k') | src/arm/codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698