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

Side by Side Diff: src/objects.h

Issue 9152001: Introduce a new AccessorPair type for handling JavaScript accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // - ExternalAsciiString 100 // - ExternalAsciiString
101 // - ExternalTwoByteString 101 // - ExternalTwoByteString
102 // - HeapNumber 102 // - HeapNumber
103 // - Code 103 // - Code
104 // - Map 104 // - Map
105 // - Oddball 105 // - Oddball
106 // - Foreign 106 // - Foreign
107 // - SharedFunctionInfo 107 // - SharedFunctionInfo
108 // - Struct 108 // - Struct
109 // - AccessorInfo 109 // - AccessorInfo
110 // - AccessorPair
110 // - AccessCheckInfo 111 // - AccessCheckInfo
111 // - InterceptorInfo 112 // - InterceptorInfo
112 // - CallHandlerInfo 113 // - CallHandlerInfo
113 // - TemplateInfo 114 // - TemplateInfo
114 // - FunctionTemplateInfo 115 // - FunctionTemplateInfo
115 // - ObjectTemplateInfo 116 // - ObjectTemplateInfo
116 // - Script 117 // - Script
117 // - SignatureInfo 118 // - SignatureInfo
118 // - TypeSwitchInfo 119 // - TypeSwitchInfo
119 // - DebugInfo 120 // - DebugInfo
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ 269 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
269 V(EXTERNAL_SHORT_ARRAY_TYPE) \ 270 V(EXTERNAL_SHORT_ARRAY_TYPE) \
270 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ 271 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
271 V(EXTERNAL_INT_ARRAY_TYPE) \ 272 V(EXTERNAL_INT_ARRAY_TYPE) \
272 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ 273 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
273 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ 274 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
274 V(EXTERNAL_PIXEL_ARRAY_TYPE) \ 275 V(EXTERNAL_PIXEL_ARRAY_TYPE) \
275 V(FILLER_TYPE) \ 276 V(FILLER_TYPE) \
276 \ 277 \
277 V(ACCESSOR_INFO_TYPE) \ 278 V(ACCESSOR_INFO_TYPE) \
279 V(ACCESSOR_PAIR_TYPE) \
278 V(ACCESS_CHECK_INFO_TYPE) \ 280 V(ACCESS_CHECK_INFO_TYPE) \
279 V(INTERCEPTOR_INFO_TYPE) \ 281 V(INTERCEPTOR_INFO_TYPE) \
280 V(CALL_HANDLER_INFO_TYPE) \ 282 V(CALL_HANDLER_INFO_TYPE) \
281 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 283 V(FUNCTION_TEMPLATE_INFO_TYPE) \
282 V(OBJECT_TEMPLATE_INFO_TYPE) \ 284 V(OBJECT_TEMPLATE_INFO_TYPE) \
283 V(SIGNATURE_INFO_TYPE) \ 285 V(SIGNATURE_INFO_TYPE) \
284 V(TYPE_SWITCH_INFO_TYPE) \ 286 V(TYPE_SWITCH_INFO_TYPE) \
285 V(SCRIPT_TYPE) \ 287 V(SCRIPT_TYPE) \
286 V(CODE_CACHE_TYPE) \ 288 V(CODE_CACHE_TYPE) \
287 V(POLYMORPHIC_CODE_CACHE_TYPE) \ 289 V(POLYMORPHIC_CODE_CACHE_TYPE) \
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // object type in this causes the compiler to generate most of the boilerplate 417 // object type in this causes the compiler to generate most of the boilerplate
416 // code for the class including allocation and garbage collection routines, 418 // code for the class including allocation and garbage collection routines,
417 // casts and predicates. All you need to define is the class, methods and 419 // casts and predicates. All you need to define is the class, methods and
418 // object verification routines. Easy, no? 420 // object verification routines. Easy, no?
419 // 421 //
420 // Note that for subtle reasons related to the ordering or numerical values of 422 // Note that for subtle reasons related to the ordering or numerical values of
421 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST 423 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST
422 // manually. 424 // manually.
423 #define STRUCT_LIST_ALL(V) \ 425 #define STRUCT_LIST_ALL(V) \
424 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \ 426 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \
427 V(ACCESSOR_PAIR, AccessorPair, accessor_pair) \
425 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \ 428 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
426 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \ 429 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
427 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \ 430 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
428 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 431 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
429 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 432 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
430 V(SIGNATURE_INFO, SignatureInfo, signature_info) \ 433 V(SIGNATURE_INFO, SignatureInfo, signature_info) \
431 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 434 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
432 V(SCRIPT, Script, script) \ 435 V(SCRIPT, Script, script) \
433 V(CODE_CACHE, CodeCache, code_cache) \ 436 V(CODE_CACHE, CodeCache, code_cache) \
434 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache) 437 V(POLYMORPHIC_CODE_CACHE, PolymorphicCodeCache, polymorphic_code_cache)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 EXTERNAL_INT_ARRAY_TYPE, 571 EXTERNAL_INT_ARRAY_TYPE,
569 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, 572 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
570 EXTERNAL_FLOAT_ARRAY_TYPE, 573 EXTERNAL_FLOAT_ARRAY_TYPE,
571 EXTERNAL_DOUBLE_ARRAY_TYPE, 574 EXTERNAL_DOUBLE_ARRAY_TYPE,
572 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE 575 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
573 FIXED_DOUBLE_ARRAY_TYPE, 576 FIXED_DOUBLE_ARRAY_TYPE,
574 FILLER_TYPE, // LAST_DATA_TYPE 577 FILLER_TYPE, // LAST_DATA_TYPE
575 578
576 // Structs. 579 // Structs.
577 ACCESSOR_INFO_TYPE, 580 ACCESSOR_INFO_TYPE,
581 ACCESSOR_PAIR_TYPE,
578 ACCESS_CHECK_INFO_TYPE, 582 ACCESS_CHECK_INFO_TYPE,
579 INTERCEPTOR_INFO_TYPE, 583 INTERCEPTOR_INFO_TYPE,
580 CALL_HANDLER_INFO_TYPE, 584 CALL_HANDLER_INFO_TYPE,
581 FUNCTION_TEMPLATE_INFO_TYPE, 585 FUNCTION_TEMPLATE_INFO_TYPE,
582 OBJECT_TEMPLATE_INFO_TYPE, 586 OBJECT_TEMPLATE_INFO_TYPE,
583 SIGNATURE_INFO_TYPE, 587 SIGNATURE_INFO_TYPE,
584 TYPE_SWITCH_INFO_TYPE, 588 TYPE_SWITCH_INFO_TYPE,
585 SCRIPT_TYPE, 589 SCRIPT_TYPE,
586 CODE_CACHE_TYPE, 590 CODE_CACHE_TYPE,
587 POLYMORPHIC_CODE_CACHE_TYPE, 591 POLYMORPHIC_CODE_CACHE_TYPE,
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 int number_of_fast_used_elements_; 2003 int number_of_fast_used_elements_;
2000 int number_of_fast_unused_elements_; 2004 int number_of_fast_unused_elements_;
2001 int number_of_slow_used_elements_; 2005 int number_of_slow_used_elements_;
2002 int number_of_slow_unused_elements_; 2006 int number_of_slow_unused_elements_;
2003 }; 2007 };
2004 2008
2005 void IncrementSpillStatistics(SpillInformation* info); 2009 void IncrementSpillStatistics(SpillInformation* info);
2006 #endif 2010 #endif
2007 Object* SlowReverseLookup(Object* value); 2011 Object* SlowReverseLookup(Object* value);
2008 2012
2009 // Getters and setters are stored in a fixed array property.
2010 // These are constants for their indices.
2011 static const int kGetterIndex = 0;
2012 static const int kSetterIndex = 1;
2013
2014 // Maximal number of fast properties for the JSObject. Used to 2013 // Maximal number of fast properties for the JSObject. Used to
2015 // restrict the number of map transitions to avoid an explosion in 2014 // restrict the number of map transitions to avoid an explosion in
2016 // the number of maps for objects used as dictionaries. 2015 // the number of maps for objects used as dictionaries.
2017 inline int MaxFastProperties(); 2016 inline int MaxFastProperties();
2018 2017
2019 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). 2018 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
2020 // Also maximal value of JSArray's length property. 2019 // Also maximal value of JSArray's length property.
2021 static const uint32_t kMaxElementCount = 0xffffffffu; 2020 static const uint32_t kMaxElementCount = 0xffffffffu;
2022 2021
2023 // Constants for heuristics controlling conversion of fast elements 2022 // Constants for heuristics controlling conversion of fast elements
(...skipping 5559 matching lines...) Expand 10 before | Expand all | Expand 10 after
7583 // Bit positions in flag. 7582 // Bit positions in flag.
7584 static const int kAllCanReadBit = 0; 7583 static const int kAllCanReadBit = 0;
7585 static const int kAllCanWriteBit = 1; 7584 static const int kAllCanWriteBit = 1;
7586 static const int kProhibitsOverwritingBit = 2; 7585 static const int kProhibitsOverwritingBit = 2;
7587 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 7586 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
7588 7587
7589 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo); 7588 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
7590 }; 7589 };
7591 7590
7592 7591
7592 // Support for JavaScript accessors: A pair of a getter and a setter. Each
7593 // accessor can either be
7594 // * a pointer to a JavaScript function or proxy: a real accessor
7595 // * undefined: considered an accessor by the spec, too, strangely enough
7596 // * the hole: an accessor which has not been set
7597 // * a pointer to a map: a transition used to ensure map sharing
7598 class AccessorPair: public Struct {
7599 public:
7600 DECL_ACCESSORS(getter, Object)
7601 DECL_ACCESSORS(setter, Object)
7602
7603 static inline AccessorPair* cast(Object* obj);
7604
7605 #ifdef OBJECT_PRINT
7606 void AccessorPairPrint(FILE* out = stdout);
7607 #endif
7608 #ifdef DEBUG
7609 void AccessorPairVerify();
7610 #endif
7611
7612 static const int kGetterOffset = HeapObject::kHeaderSize;
7613 static const int kSetterOffset = kGetterOffset + kPointerSize;
7614 static const int kSize = kSetterOffset + kPointerSize;
7615
7616 private:
7617 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
7618 };
7619
7620
7593 class AccessCheckInfo: public Struct { 7621 class AccessCheckInfo: public Struct {
7594 public: 7622 public:
7595 DECL_ACCESSORS(named_callback, Object) 7623 DECL_ACCESSORS(named_callback, Object)
7596 DECL_ACCESSORS(indexed_callback, Object) 7624 DECL_ACCESSORS(indexed_callback, Object)
7597 DECL_ACCESSORS(data, Object) 7625 DECL_ACCESSORS(data, Object)
7598 7626
7599 static inline AccessCheckInfo* cast(Object* obj); 7627 static inline AccessCheckInfo* cast(Object* obj);
7600 7628
7601 #ifdef OBJECT_PRINT 7629 #ifdef OBJECT_PRINT
7602 inline void AccessCheckInfoPrint() { 7630 inline void AccessCheckInfoPrint() {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
8077 } else { 8105 } else {
8078 value &= ~(1 << bit_position); 8106 value &= ~(1 << bit_position);
8079 } 8107 }
8080 return value; 8108 return value;
8081 } 8109 }
8082 }; 8110 };
8083 8111
8084 } } // namespace v8::internal 8112 } } // namespace v8::internal
8085 8113
8086 #endif // V8_OBJECTS_H_ 8114 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698