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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 void EmitLoadGlobalCheckExtensions(Variable* var, | 463 void EmitLoadGlobalCheckExtensions(Variable* var, |
464 TypeofState typeof_state, | 464 TypeofState typeof_state, |
465 Label* slow); | 465 Label* slow); |
466 MemOperand ContextSlotOperandCheckExtensions(Variable* var, Label* slow); | 466 MemOperand ContextSlotOperandCheckExtensions(Variable* var, Label* slow); |
467 void EmitDynamicLookupFastCase(Variable* var, | 467 void EmitDynamicLookupFastCase(Variable* var, |
468 TypeofState typeof_state, | 468 TypeofState typeof_state, |
469 Label* slow, | 469 Label* slow, |
470 Label* done); | 470 Label* done); |
471 void EmitVariableLoad(VariableProxy* proxy); | 471 void EmitVariableLoad(VariableProxy* proxy); |
472 | 472 |
473 void EmitAccessor(Expression* expression); | |
474 | |
473 // Expects the arguments and the function already pushed. | 475 // Expects the arguments and the function already pushed. |
474 void EmitResolvePossiblyDirectEval(int arg_count); | 476 void EmitResolvePossiblyDirectEval(int arg_count); |
475 | 477 |
476 // Platform-specific support for allocating a new closure based on | 478 // Platform-specific support for allocating a new closure based on |
477 // the given function info. | 479 // the given function info. |
478 void EmitNewClosure(Handle<SharedFunctionInfo> info, bool pretenure); | 480 void EmitNewClosure(Handle<SharedFunctionInfo> info, bool pretenure); |
479 | 481 |
480 // Platform-specific support for compiling assignments. | 482 // Platform-specific support for compiling assignments. |
481 | 483 |
482 // Load a value from a named property. | 484 // Load a value from a named property. |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 bool has_self_optimization_header_; | 799 bool has_self_optimization_header_; |
798 Handle<FixedArray> handler_table_; | 800 Handle<FixedArray> handler_table_; |
799 Handle<JSGlobalPropertyCell> profiling_counter_; | 801 Handle<JSGlobalPropertyCell> profiling_counter_; |
800 | 802 |
801 friend class NestedStatement; | 803 friend class NestedStatement; |
802 | 804 |
803 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 805 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
804 }; | 806 }; |
805 | 807 |
806 | 808 |
809 // A map from property names to getter/setter pairs with an STL-like iterator | |
810 // interface. In STL speak, an AccessorTable is roughly something like a | |
811 // zone-allocated map<Literal*, pair<Expression*,Expression*> >. Note that only | |
812 // a subset of the usual iterator functions/operators are defined below, but the | |
813 // rest would be easy to add when required. | |
814 class AccessorTable { | |
815 public: | |
816 class Accessors: public ZoneObject { | |
rossberg
2012/03/13 13:59:10
This is just a simple pair, not abstracting anythi
Sven Panne
2012/03/14 15:26:56
I'm perfectly fine with this, and as Uncle Bob say
| |
817 public: | |
818 Accessors() : getter_(NULL), setter_(NULL) { } | |
819 Expression* getter() const { return getter_; } | |
820 void set_getter(Expression* expr) { getter_ = expr; } | |
821 Expression* setter() const { return setter_; } | |
822 void set_setter(Expression* expr) { setter_ = expr; } | |
823 | |
824 private: | |
825 Expression* getter_; | |
826 Expression* setter_; | |
827 }; | |
828 | |
829 class Iterator; | |
830 | |
831 class value_type: private ZoneHashMap::Entry { | |
832 public: | |
833 Literal* first() const { return reinterpret_cast<Literal*>(key); } | |
rossberg
2012/03/13 13:59:10
These can be static_cast's.
Sven Panne
2012/03/14 15:26:56
Done.
| |
834 Accessors* second() const { return reinterpret_cast<Accessors*>(value); } | |
835 | |
836 private: | |
837 static value_type* cast(ZoneHashMap::Entry* entry) { | |
838 return static_cast<value_type*>(entry); | |
839 } | |
840 friend class Iterator; | |
841 }; | |
842 | |
843 class Iterator { | |
844 public: | |
845 Iterator& operator++() { | |
846 entry_ = map_->Next(entry_); | |
847 return *this; | |
848 } | |
849 | |
850 value_type* operator->() { return value_type::cast(entry_); } | |
851 | |
852 bool operator!=(const Iterator& other) { | |
853 return map_ != other.map_ || entry_ != other.entry_; | |
rossberg
2012/03/13 13:59:10
Is the first condition necessary? I believe iterat
Sven Panne
2012/03/14 15:26:56
In a first version, I left the first part out, but
| |
854 } | |
855 | |
856 private: | |
857 Iterator(const ZoneHashMap* map, ZoneHashMap::Entry* entry) : | |
858 map_(map), entry_(entry) { } | |
859 | |
860 const ZoneHashMap* map_; | |
861 ZoneHashMap::Entry* entry_; | |
862 | |
863 friend class AccessorTable; | |
864 }; | |
865 | |
866 explicit AccessorTable(Zone* zone) : map_(Literal::Match), zone_(zone) { } | |
867 Iterator begin() const { return Iterator(&map_, map_.Start()); } | |
868 Iterator end() const { return Iterator(&map_, NULL); } | |
869 | |
870 Iterator find(Literal* key) { | |
871 ZoneHashMap::Entry* entry = map_.Lookup(key, key->Hash(), true); | |
872 if (entry->value == NULL) entry->value = new(zone_) Accessors(); | |
873 return Iterator(&map_, entry); | |
874 } | |
875 | |
876 private: | |
877 ZoneHashMap map_; | |
878 Zone* zone_; | |
879 | |
880 DISALLOW_COPY_AND_ASSIGN(AccessorTable); | |
881 }; | |
882 | |
883 | |
807 } } // namespace v8::internal | 884 } } // namespace v8::internal |
808 | 885 |
809 #endif // V8_FULL_CODEGEN_H_ | 886 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |