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

Side by Side Diff: src/hydrogen-instructions.h

Issue 141653015: Simplify HUnaryMathOperation::Canonicalize. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback Created 6 years, 11 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/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 28 matching lines...) Expand all
39 #include "unique.h" 39 #include "unique.h"
40 #include "v8conversions.h" 40 #include "v8conversions.h"
41 #include "v8utils.h" 41 #include "v8utils.h"
42 #include "zone.h" 42 #include "zone.h"
43 43
44 namespace v8 { 44 namespace v8 {
45 namespace internal { 45 namespace internal {
46 46
47 // Forward declarations. 47 // Forward declarations.
48 class HBasicBlock; 48 class HBasicBlock;
49 class HDiv;
49 class HEnvironment; 50 class HEnvironment;
50 class HInferRepresentationPhase; 51 class HInferRepresentationPhase;
51 class HInstruction; 52 class HInstruction;
52 class HLoopInformation; 53 class HLoopInformation;
53 class HStoreNamedField; 54 class HStoreNamedField;
54 class HValue; 55 class HValue;
55 class LInstruction; 56 class LInstruction;
56 class LChunkBuilder; 57 class LChunkBuilder;
57 58
58 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ 59 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 class HInstruction : public HValue { 1201 class HInstruction : public HValue {
1201 public: 1202 public:
1202 HInstruction* next() const { return next_; } 1203 HInstruction* next() const { return next_; }
1203 HInstruction* previous() const { return previous_; } 1204 HInstruction* previous() const { return previous_; }
1204 1205
1205 virtual void PrintTo(StringStream* stream) V8_OVERRIDE; 1206 virtual void PrintTo(StringStream* stream) V8_OVERRIDE;
1206 virtual void PrintDataTo(StringStream* stream); 1207 virtual void PrintDataTo(StringStream* stream);
1207 1208
1208 bool IsLinked() const { return block() != NULL; } 1209 bool IsLinked() const { return block() != NULL; }
1209 void Unlink(); 1210 void Unlink();
1211
1210 void InsertBefore(HInstruction* next); 1212 void InsertBefore(HInstruction* next);
1213
1214 template<class T> T* Prepend(T* instr) {
1215 instr->InsertBefore(this);
1216 return instr;
1217 }
1218
1211 void InsertAfter(HInstruction* previous); 1219 void InsertAfter(HInstruction* previous);
1212 1220
1221 template<class T> T* Append(T* instr) {
1222 instr->InsertAfter(this);
1223 return instr;
1224 }
1225
1213 // The position is a write-once variable. 1226 // The position is a write-once variable.
1214 virtual int position() const V8_OVERRIDE { 1227 virtual int position() const V8_OVERRIDE {
1215 return position_.position(); 1228 return position_.position();
1216 } 1229 }
1217 bool has_position() const { 1230 bool has_position() const {
1218 return position_.position() != RelocInfo::kNoPosition; 1231 return position_.position() != RelocInfo::kNoPosition;
1219 } 1232 }
1220 void set_position(int position) { 1233 void set_position(int position) {
1221 ASSERT(!has_position()); 1234 ASSERT(!has_position());
1222 ASSERT(position != RelocInfo::kNoPosition); 1235 ASSERT(position != RelocInfo::kNoPosition);
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 break; 2712 break;
2700 default: 2713 default:
2701 UNREACHABLE(); 2714 UNREACHABLE();
2702 } 2715 }
2703 SetFlag(kUseGVN); 2716 SetFlag(kUseGVN);
2704 SetFlag(kAllowUndefinedAsNaN); 2717 SetFlag(kAllowUndefinedAsNaN);
2705 } 2718 }
2706 2719
2707 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 2720 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2708 2721
2722 HValue* SimplifiedDividendForMathFloorOfDiv(HDiv* hdiv);
2723 HValue* SimplifiedDivisorForMathFloorOfDiv(HDiv* hdiv);
2724
2709 BuiltinFunctionId op_; 2725 BuiltinFunctionId op_;
2710 }; 2726 };
2711 2727
2712 2728
2713 class HLoadRoot V8_FINAL : public HTemplateInstruction<0> { 2729 class HLoadRoot V8_FINAL : public HTemplateInstruction<0> {
2714 public: 2730 public:
2715 DECLARE_INSTRUCTION_FACTORY_P1(HLoadRoot, Heap::RootListIndex); 2731 DECLARE_INSTRUCTION_FACTORY_P1(HLoadRoot, Heap::RootListIndex);
2716 DECLARE_INSTRUCTION_FACTORY_P2(HLoadRoot, Heap::RootListIndex, HType); 2732 DECLARE_INSTRUCTION_FACTORY_P2(HLoadRoot, Heap::RootListIndex, HType);
2717 2733
2718 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 2734 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3469 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); 3485 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation);
3470 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); 3486 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double);
3471 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); 3487 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>);
3472 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); 3488 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference);
3473 3489
3474 static HConstant* CreateAndInsertAfter(Zone* zone, 3490 static HConstant* CreateAndInsertAfter(Zone* zone,
3475 HValue* context, 3491 HValue* context,
3476 int32_t value, 3492 int32_t value,
3477 Representation representation, 3493 Representation representation,
3478 HInstruction* instruction) { 3494 HInstruction* instruction) {
3479 HConstant* new_constant = 3495 return instruction->Append(HConstant::New(
3480 HConstant::New(zone, context, value, representation); 3496 zone, context, value, representation));
3481 new_constant->InsertAfter(instruction);
3482 return new_constant;
3483 } 3497 }
3484 3498
3485 static HConstant* CreateAndInsertBefore(Zone* zone, 3499 static HConstant* CreateAndInsertBefore(Zone* zone,
3486 HValue* context, 3500 HValue* context,
3487 int32_t value, 3501 int32_t value,
3488 Representation representation, 3502 Representation representation,
3489 HInstruction* instruction) { 3503 HInstruction* instruction) {
3490 HConstant* new_constant = 3504 return instruction->Prepend(HConstant::New(
3491 HConstant::New(zone, context, value, representation); 3505 zone, context, value, representation));
3492 new_constant->InsertBefore(instruction);
3493 return new_constant;
3494 } 3506 }
3495 3507
3496 static HConstant* CreateAndInsertBefore(Zone* zone, 3508 static HConstant* CreateAndInsertBefore(Zone* zone,
3497 Unique<Object> unique, 3509 Unique<Object> unique,
3498 bool is_not_in_new_space, 3510 bool is_not_in_new_space,
3499 HInstruction* instruction) { 3511 HInstruction* instruction) {
3500 HConstant* new_constant = new(zone) HConstant(unique, 3512 return instruction->Prepend(new(zone) HConstant(
3501 Representation::Tagged(), HType::Tagged(), false, is_not_in_new_space, 3513 unique, Representation::Tagged(), HType::Tagged(), false,
3502 false, false); 3514 is_not_in_new_space, false, false));
3503 new_constant->InsertBefore(instruction);
3504 return new_constant;
3505 } 3515 }
3506 3516
3507 Handle<Object> handle(Isolate* isolate) { 3517 Handle<Object> handle(Isolate* isolate) {
3508 if (object_.handle().is_null()) { 3518 if (object_.handle().is_null()) {
3509 // Default arguments to is_not_in_new_space depend on this heap number 3519 // Default arguments to is_not_in_new_space depend on this heap number
3510 // to be tenured so that it's guaranteed not to be located in new space. 3520 // to be tenured so that it's guaranteed not to be located in new space.
3511 object_ = Unique<Object>::CreateUninitialized( 3521 object_ = Unique<Object>::CreateUninitialized(
3512 isolate->factory()->NewNumber(double_value_, TENURED)); 3522 isolate->factory()->NewNumber(double_value_, TENURED));
3513 } 3523 }
3514 AllowDeferredHandleDereference smi_check; 3524 AllowDeferredHandleDereference smi_check;
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
4181 if (to.IsTagged() && 4191 if (to.IsTagged() &&
4182 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) { 4192 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) {
4183 SetAllSideEffects(); 4193 SetAllSideEffects();
4184 ClearFlag(kUseGVN); 4194 ClearFlag(kUseGVN);
4185 } else { 4195 } else {
4186 ClearAllSideEffects(); 4196 ClearAllSideEffects();
4187 SetFlag(kUseGVN); 4197 SetFlag(kUseGVN);
4188 } 4198 }
4189 } 4199 }
4190 4200
4201 bool RightIsPowerOf2() {
4202 if (!right()->IsInteger32Constant()) return false;
4203 int32_t value = right()->GetInteger32Constant();
4204 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
4205 }
4206
4191 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) 4207 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation)
4208
4192 private: 4209 private:
4193 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 4210 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
4194 }; 4211 };
4195 4212
4196 4213
4197 class HCompareGeneric V8_FINAL : public HBinaryOperation { 4214 class HCompareGeneric V8_FINAL : public HBinaryOperation {
4198 public: 4215 public:
4199 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HCompareGeneric, HValue*, 4216 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P3(HCompareGeneric, HValue*,
4200 HValue*, Token::Value); 4217 HValue*, Token::Value);
4201 4218
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
4880 }; 4897 };
4881 4898
4882 4899
4883 class HMod V8_FINAL : public HArithmeticBinaryOperation { 4900 class HMod V8_FINAL : public HArithmeticBinaryOperation {
4884 public: 4901 public:
4885 static HInstruction* New(Zone* zone, 4902 static HInstruction* New(Zone* zone,
4886 HValue* context, 4903 HValue* context,
4887 HValue* left, 4904 HValue* left,
4888 HValue* right); 4905 HValue* right);
4889 4906
4890 bool HasPowerOf2Divisor() {
4891 if (right()->IsConstant() &&
4892 HConstant::cast(right())->HasInteger32Value()) {
4893 int32_t value = HConstant::cast(right())->Integer32Value();
4894 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
4895 }
4896
4897 return false;
4898 }
4899
4900 virtual HValue* EnsureAndPropagateNotMinusZero( 4907 virtual HValue* EnsureAndPropagateNotMinusZero(
4901 BitVector* visited) V8_OVERRIDE; 4908 BitVector* visited) V8_OVERRIDE;
4902 4909
4903 virtual HValue* Canonicalize() V8_OVERRIDE; 4910 virtual HValue* Canonicalize() V8_OVERRIDE;
4904 4911
4905 virtual void UpdateRepresentation(Representation new_rep, 4912 virtual void UpdateRepresentation(Representation new_rep,
4906 HInferRepresentationPhase* h_infer, 4913 HInferRepresentationPhase* h_infer,
4907 const char* reason) V8_OVERRIDE { 4914 const char* reason) V8_OVERRIDE {
4908 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4915 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4909 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4916 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
(...skipping 16 matching lines...) Expand all
4926 }; 4933 };
4927 4934
4928 4935
4929 class HDiv V8_FINAL : public HArithmeticBinaryOperation { 4936 class HDiv V8_FINAL : public HArithmeticBinaryOperation {
4930 public: 4937 public:
4931 static HInstruction* New(Zone* zone, 4938 static HInstruction* New(Zone* zone,
4932 HValue* context, 4939 HValue* context,
4933 HValue* left, 4940 HValue* left,
4934 HValue* right); 4941 HValue* right);
4935 4942
4936 bool HasPowerOf2Divisor() {
4937 if (right()->IsInteger32Constant()) {
4938 int32_t value = right()->GetInteger32Constant();
4939 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
4940 }
4941
4942 return false;
4943 }
4944
4945 virtual HValue* EnsureAndPropagateNotMinusZero( 4943 virtual HValue* EnsureAndPropagateNotMinusZero(
4946 BitVector* visited) V8_OVERRIDE; 4944 BitVector* visited) V8_OVERRIDE;
4947 4945
4948 virtual HValue* Canonicalize() V8_OVERRIDE; 4946 virtual HValue* Canonicalize() V8_OVERRIDE;
4949 4947
4950 virtual void UpdateRepresentation(Representation new_rep, 4948 virtual void UpdateRepresentation(Representation new_rep,
4951 HInferRepresentationPhase* h_infer, 4949 HInferRepresentationPhase* h_infer,
4952 const char* reason) V8_OVERRIDE { 4950 const char* reason) V8_OVERRIDE {
4953 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4951 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4954 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4952 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
(...skipping 2600 matching lines...) Expand 10 before | Expand all | Expand 10 after
7555 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7553 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7556 }; 7554 };
7557 7555
7558 7556
7559 #undef DECLARE_INSTRUCTION 7557 #undef DECLARE_INSTRUCTION
7560 #undef DECLARE_CONCRETE_INSTRUCTION 7558 #undef DECLARE_CONCRETE_INSTRUCTION
7561 7559
7562 } } // namespace v8::internal 7560 } } // namespace v8::internal
7563 7561
7564 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7562 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698