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 10103035: Share optimized code for closures. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: rebased on r11394 Created 8 years, 8 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
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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 } 1453 }
1454 1454
1455 HValue* argument() { return OperandAt(0); } 1455 HValue* argument() { return OperandAt(0); }
1456 1456
1457 DECLARE_CONCRETE_INSTRUCTION(PushArgument) 1457 DECLARE_CONCRETE_INSTRUCTION(PushArgument)
1458 }; 1458 };
1459 1459
1460 1460
1461 class HThisFunction: public HTemplateInstruction<0> { 1461 class HThisFunction: public HTemplateInstruction<0> {
1462 public: 1462 public:
1463 explicit HThisFunction(Handle<JSFunction> closure) : closure_(closure) { 1463 HThisFunction() {
1464 set_representation(Representation::Tagged()); 1464 set_representation(Representation::Tagged());
1465 SetFlag(kUseGVN); 1465 SetFlag(kUseGVN);
1466 } 1466 }
1467 1467
1468 virtual Representation RequiredInputRepresentation(int index) { 1468 virtual Representation RequiredInputRepresentation(int index) {
1469 return Representation::None(); 1469 return Representation::None();
1470 } 1470 }
1471 1471
1472 Handle<JSFunction> closure() const { return closure_; }
1473
1474 DECLARE_CONCRETE_INSTRUCTION(ThisFunction) 1472 DECLARE_CONCRETE_INSTRUCTION(ThisFunction)
1475 1473
1476 protected: 1474 protected:
1477 virtual bool DataEquals(HValue* other) { 1475 virtual bool DataEquals(HValue* other) { return true; }
1478 HThisFunction* b = HThisFunction::cast(other);
1479 return *closure() == *b->closure();
1480 }
1481
1482 private:
1483 Handle<JSFunction> closure_;
1484 }; 1476 };
1485 1477
1486 1478
1487 class HContext: public HTemplateInstruction<0> { 1479 class HContext: public HTemplateInstruction<0> {
1488 public: 1480 public:
1489 HContext() { 1481 HContext() {
1490 set_representation(Representation::Tagged()); 1482 set_representation(Representation::Tagged());
1491 SetFlag(kUseGVN); 1483 SetFlag(kUseGVN);
1492 } 1484 }
1493 1485
(...skipping 3068 matching lines...) Expand 10 before | Expand all | Expand 10 after
4562 int total_size_; 4554 int total_size_;
4563 }; 4555 };
4564 4556
4565 4557
4566 class HArrayLiteral: public HMaterializedLiteral<1> { 4558 class HArrayLiteral: public HMaterializedLiteral<1> {
4567 public: 4559 public:
4568 HArrayLiteral(HValue* context, 4560 HArrayLiteral(HValue* context,
4569 Handle<HeapObject> boilerplate_object, 4561 Handle<HeapObject> boilerplate_object,
4570 int length, 4562 int length,
4571 int literal_index, 4563 int literal_index,
4572 int depth) 4564 int depth,
4565 Handle<FixedArray> constant_elements)
4573 : HMaterializedLiteral<1>(literal_index, depth), 4566 : HMaterializedLiteral<1>(literal_index, depth),
4574 length_(length), 4567 length_(length),
4575 boilerplate_object_(boilerplate_object) { 4568 boilerplate_object_(boilerplate_object),
4569 constant_elements_(constant_elements) {
4576 SetOperandAt(0, context); 4570 SetOperandAt(0, context);
4577 SetGVNFlag(kChangesNewSpacePromotion); 4571 SetGVNFlag(kChangesNewSpacePromotion);
4578 } 4572 }
4579 4573
4580 HValue* context() { return OperandAt(0); } 4574 HValue* context() { return OperandAt(0); }
4581 ElementsKind boilerplate_elements_kind() const { 4575 ElementsKind boilerplate_elements_kind() const {
4582 if (!boilerplate_object_->IsJSObject()) { 4576 if (!boilerplate_object_->IsJSObject()) {
4583 return FAST_ELEMENTS; 4577 return FAST_ELEMENTS;
4584 } 4578 }
4585 return Handle<JSObject>::cast(boilerplate_object_)->GetElementsKind(); 4579 return Handle<JSObject>::cast(boilerplate_object_)->GetElementsKind();
4586 } 4580 }
4587 Handle<HeapObject> boilerplate_object() const { return boilerplate_object_; } 4581 Handle<HeapObject> boilerplate_object() const { return boilerplate_object_; }
4582 Handle<FixedArray> constant_elements() const { return constant_elements_; }
4588 int length() const { return length_; } 4583 int length() const { return length_; }
4589 4584
4590 bool IsCopyOnWrite() const; 4585 bool IsCopyOnWrite() const;
4591 4586
4592 virtual Representation RequiredInputRepresentation(int index) { 4587 virtual Representation RequiredInputRepresentation(int index) {
4593 return Representation::Tagged(); 4588 return Representation::Tagged();
4594 } 4589 }
4595 virtual HType CalculateInferredType(); 4590 virtual HType CalculateInferredType();
4596 4591
4597 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral) 4592 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral)
4598 4593
4599 private: 4594 private:
4600 int length_; 4595 int length_;
4601 Handle<HeapObject> boilerplate_object_; 4596 Handle<HeapObject> boilerplate_object_;
4597 Handle<FixedArray> constant_elements_;
4602 }; 4598 };
4603 4599
4604 4600
4605 class HObjectLiteral: public HMaterializedLiteral<1> { 4601 class HObjectLiteral: public HMaterializedLiteral<1> {
4606 public: 4602 public:
4607 HObjectLiteral(HValue* context, 4603 HObjectLiteral(HValue* context,
4608 Handle<FixedArray> constant_properties, 4604 Handle<FixedArray> constant_properties,
4609 bool fast_elements, 4605 bool fast_elements,
4610 int literal_index, 4606 int literal_index,
4611 int depth, 4607 int depth,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
4947 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); 4943 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex);
4948 }; 4944 };
4949 4945
4950 4946
4951 #undef DECLARE_INSTRUCTION 4947 #undef DECLARE_INSTRUCTION
4952 #undef DECLARE_CONCRETE_INSTRUCTION 4948 #undef DECLARE_CONCRETE_INSTRUCTION
4953 4949
4954 } } // namespace v8::internal 4950 } } // namespace v8::internal
4955 4951
4956 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4952 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698