OLD | NEW |
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 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 | 2439 |
2440 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) | 2440 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) |
2441 | 2441 |
2442 protected: | 2442 protected: |
2443 virtual bool DataEquals(HValue* other) { return true; } | 2443 virtual bool DataEquals(HValue* other) { return true; } |
2444 }; | 2444 }; |
2445 | 2445 |
2446 | 2446 |
2447 class HCheckPrototypeMaps: public HTemplateInstruction<0> { | 2447 class HCheckPrototypeMaps: public HTemplateInstruction<0> { |
2448 public: | 2448 public: |
2449 HCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder) | 2449 HCheckPrototypeMaps(Handle<JSObject> prototype, |
2450 : prototype_(prototype), holder_(holder) { | 2450 Handle<JSObject> holder, |
| 2451 Zone* zone) : prototypes_(2, zone), maps_(2, zone) { |
2451 SetFlag(kUseGVN); | 2452 SetFlag(kUseGVN); |
2452 SetGVNFlag(kDependsOnMaps); | 2453 SetGVNFlag(kDependsOnMaps); |
| 2454 // Keep a list of all objects on the prototype chain up to the holder |
| 2455 // and the expected maps. |
| 2456 while (true) { |
| 2457 prototypes_.Add(prototype, zone); |
| 2458 maps_.Add(Handle<Map>(prototype->map()), zone); |
| 2459 if (prototype.is_identical_to(holder)) break; |
| 2460 prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype())); |
| 2461 } |
2453 } | 2462 } |
2454 | 2463 |
2455 Handle<JSObject> prototype() const { return prototype_; } | 2464 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; } |
2456 Handle<JSObject> holder() const { return holder_; } | 2465 |
| 2466 ZoneList<Handle<Map> >* maps() { return &maps_; } |
2457 | 2467 |
2458 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) | 2468 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) |
2459 | 2469 |
2460 virtual Representation RequiredInputRepresentation(int index) { | 2470 virtual Representation RequiredInputRepresentation(int index) { |
2461 return Representation::None(); | 2471 return Representation::None(); |
2462 } | 2472 } |
2463 | 2473 |
2464 virtual void PrintDataTo(StringStream* stream); | 2474 virtual void PrintDataTo(StringStream* stream); |
2465 | 2475 |
2466 virtual intptr_t Hashcode() { | 2476 virtual intptr_t Hashcode() { |
2467 ASSERT_ALLOCATION_DISABLED; | 2477 ASSERT_ALLOCATION_DISABLED; |
2468 intptr_t hash = reinterpret_cast<intptr_t>(*prototype()); | 2478 intptr_t hash = 0; |
2469 hash = 17 * hash + reinterpret_cast<intptr_t>(*holder()); | 2479 for (int i = 0; i < prototypes_.length(); i++) { |
| 2480 hash = 17 * hash + reinterpret_cast<intptr_t>(*prototypes_[i]); |
| 2481 hash = 17 * hash + reinterpret_cast<intptr_t>(*maps_[i]); |
| 2482 } |
2470 return hash; | 2483 return hash; |
2471 } | 2484 } |
2472 | 2485 |
2473 protected: | 2486 protected: |
2474 virtual bool DataEquals(HValue* other) { | 2487 virtual bool DataEquals(HValue* other) { |
2475 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); | 2488 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); |
2476 return prototype_.is_identical_to(b->prototype()) && | 2489 if (prototypes_.length() != b->prototypes()->length()) return false; |
2477 holder_.is_identical_to(b->holder()); | 2490 for (int i = 0; i < prototypes_.length(); i++) { |
| 2491 if (!prototypes_[i].is_identical_to(b->prototypes()->at(i))) return false; |
| 2492 if (!maps_[i].is_identical_to(b->maps()->at(i))) return false; |
| 2493 } |
| 2494 return true; |
2478 } | 2495 } |
2479 | 2496 |
2480 private: | 2497 private: |
2481 Handle<JSObject> prototype_; | 2498 ZoneList<Handle<JSObject> > prototypes_; |
2482 Handle<JSObject> holder_; | 2499 ZoneList<Handle<Map> > maps_; |
2483 }; | 2500 }; |
2484 | 2501 |
2485 | 2502 |
2486 class HCheckSmi: public HUnaryOperation { | 2503 class HCheckSmi: public HUnaryOperation { |
2487 public: | 2504 public: |
2488 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { | 2505 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { |
2489 set_representation(Representation::Tagged()); | 2506 set_representation(Representation::Tagged()); |
2490 SetFlag(kUseGVN); | 2507 SetFlag(kUseGVN); |
2491 } | 2508 } |
2492 | 2509 |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3607 HSub(HValue* context, HValue* left, HValue* right) | 3624 HSub(HValue* context, HValue* left, HValue* right) |
3608 : HArithmeticBinaryOperation(context, left, right) { | 3625 : HArithmeticBinaryOperation(context, left, right) { |
3609 SetFlag(kCanOverflow); | 3626 SetFlag(kCanOverflow); |
3610 } | 3627 } |
3611 | 3628 |
3612 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3629 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3613 | 3630 |
3614 virtual HValue* Canonicalize(); | 3631 virtual HValue* Canonicalize(); |
3615 | 3632 |
3616 static HInstruction* NewHSub(Zone* zone, | 3633 static HInstruction* NewHSub(Zone* zone, |
3617 HValue* context, | 3634 HValue* context, |
3618 HValue* left, | 3635 HValue* left, |
3619 HValue* right); | 3636 HValue* right); |
3620 | 3637 |
3621 DECLARE_CONCRETE_INSTRUCTION(Sub) | 3638 DECLARE_CONCRETE_INSTRUCTION(Sub) |
3622 | 3639 |
3623 protected: | 3640 protected: |
3624 virtual bool DataEquals(HValue* other) { return true; } | 3641 virtual bool DataEquals(HValue* other) { return true; } |
3625 | 3642 |
3626 virtual Range* InferRange(Zone* zone); | 3643 virtual Range* InferRange(Zone* zone); |
3627 }; | 3644 }; |
3628 | 3645 |
3629 | 3646 |
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5481 virtual bool IsDeletable() const { return true; } | 5498 virtual bool IsDeletable() const { return true; } |
5482 }; | 5499 }; |
5483 | 5500 |
5484 | 5501 |
5485 #undef DECLARE_INSTRUCTION | 5502 #undef DECLARE_INSTRUCTION |
5486 #undef DECLARE_CONCRETE_INSTRUCTION | 5503 #undef DECLARE_CONCRETE_INSTRUCTION |
5487 | 5504 |
5488 } } // namespace v8::internal | 5505 } } // namespace v8::internal |
5489 | 5506 |
5490 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5507 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |