| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 20 matching lines...) Expand all Loading... |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "builtins.h" | 32 #include "builtins.h" |
| 33 #include "list.h" | 33 #include "list.h" |
| 34 #include "smart-array-pointer.h" | 34 #include "smart-array-pointer.h" |
| 35 #include "unicode-inl.h" | 35 #include "unicode-inl.h" |
| 36 #if V8_TARGET_ARCH_ARM | 36 #if V8_TARGET_ARCH_ARM |
| 37 #include "arm/constants-arm.h" | 37 #include "arm/constants-arm.h" |
| 38 #elif V8_TARGET_ARCH_MIPS | 38 #elif V8_TARGET_ARCH_MIPS |
| 39 #include "mips/constants-mips.h" | 39 #include "mips/constants-mips.h" |
| 40 #endif | 40 #endif |
| 41 #include "v8checks.h" |
| 41 | 42 |
| 42 // | 43 // |
| 43 // Most object types in the V8 JavaScript are described in this file. | 44 // Most object types in the V8 JavaScript are described in this file. |
| 44 // | 45 // |
| 45 // Inheritance hierarchy: | 46 // Inheritance hierarchy: |
| 46 // - MaybeObject (an object or a failure) | 47 // - MaybeObject (an object or a failure) |
| 47 // - Failure (immediate for marking failed operation) | 48 // - Failure (immediate for marking failed operation) |
| 48 // - Object | 49 // - Object |
| 49 // - Smi (immediate small integer) | 50 // - Smi (immediate small integer) |
| 50 // - HeapObject (superclass for everything allocated in the heap) | 51 // - HeapObject (superclass for everything allocated in the heap) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ABSENT = 16 // Used in runtime to indicate a property is absent. | 130 ABSENT = 16 // Used in runtime to indicate a property is absent. |
| 130 // ABSENT can never be stored in or returned from a descriptor's attributes | 131 // ABSENT can never be stored in or returned from a descriptor's attributes |
| 131 // bitfield. It is only used as a return value meaning the attributes of | 132 // bitfield. It is only used as a return value meaning the attributes of |
| 132 // a non-existent property. | 133 // a non-existent property. |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 namespace v8 { | 136 namespace v8 { |
| 136 namespace internal { | 137 namespace internal { |
| 137 | 138 |
| 138 enum ElementsKind { | 139 enum ElementsKind { |
| 139 // The "fast" kind for tagged values. Must be first to make it possible | 140 // The "fast" kind for elements that only contain SMI values. Must be first |
| 140 // to efficiently check maps if they have fast elements. | 141 // to make it possible to efficiently check maps for this kind. |
| 142 FAST_SMI_ONLY_ELEMENTS, |
| 143 |
| 144 // The "fast" kind for tagged values. Must be second to make it possible to |
| 145 // efficiently check maps for this and the FAST_SMI_ONLY_ELEMENTS kind |
| 146 // together at once. |
| 141 FAST_ELEMENTS, | 147 FAST_ELEMENTS, |
| 142 | 148 |
| 143 // The "fast" kind for unwrapped, non-tagged double values. | 149 // The "fast" kind for unwrapped, non-tagged double values. |
| 144 FAST_DOUBLE_ELEMENTS, | 150 FAST_DOUBLE_ELEMENTS, |
| 145 | 151 |
| 146 // The "slow" kind. | 152 // The "slow" kind. |
| 147 DICTIONARY_ELEMENTS, | 153 DICTIONARY_ELEMENTS, |
| 148 NON_STRICT_ARGUMENTS_ELEMENTS, | 154 NON_STRICT_ARGUMENTS_ELEMENTS, |
| 149 // The "fast" kind for external arrays | 155 // The "fast" kind for external arrays |
| 150 EXTERNAL_BYTE_ELEMENTS, | 156 EXTERNAL_BYTE_ELEMENTS, |
| 151 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 157 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
| 152 EXTERNAL_SHORT_ELEMENTS, | 158 EXTERNAL_SHORT_ELEMENTS, |
| 153 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 159 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
| 154 EXTERNAL_INT_ELEMENTS, | 160 EXTERNAL_INT_ELEMENTS, |
| 155 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 161 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
| 156 EXTERNAL_FLOAT_ELEMENTS, | 162 EXTERNAL_FLOAT_ELEMENTS, |
| 157 EXTERNAL_DOUBLE_ELEMENTS, | 163 EXTERNAL_DOUBLE_ELEMENTS, |
| 158 EXTERNAL_PIXEL_ELEMENTS, | 164 EXTERNAL_PIXEL_ELEMENTS, |
| 159 | 165 |
| 160 // Derived constants from ElementsKind | 166 // Derived constants from ElementsKind |
| 161 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, | 167 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, |
| 162 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, | 168 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, |
| 163 FIRST_ELEMENTS_KIND = FAST_ELEMENTS, | 169 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, |
| 164 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS | 170 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS |
| 165 }; | 171 }; |
| 166 | 172 |
| 167 static const int kElementsKindCount = | 173 static const int kElementsKindCount = |
| 168 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | 174 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
| 169 | 175 |
| 170 // PropertyDetails captures type and attributes for a property. | 176 // PropertyDetails captures type and attributes for a property. |
| 171 // They are used both in property dictionaries and instance descriptors. | 177 // They are used both in property dictionaries and instance descriptors. |
| 172 class PropertyDetails BASE_EMBEDDED { | 178 class PropertyDetails BASE_EMBEDDED { |
| 173 public: | 179 public: |
| 174 PropertyDetails(PropertyAttributes attributes, | 180 PropertyDetails(PropertyAttributes attributes, |
| 175 PropertyType type, | 181 PropertyType type, |
| 176 int index = 0) { | 182 int index = 0) { |
| 177 ASSERT(type != ELEMENTS_TRANSITION); | |
| 178 ASSERT(TypeField::is_valid(type)); | 183 ASSERT(TypeField::is_valid(type)); |
| 179 ASSERT(AttributesField::is_valid(attributes)); | 184 ASSERT(AttributesField::is_valid(attributes)); |
| 180 ASSERT(StorageField::is_valid(index)); | 185 ASSERT(StorageField::is_valid(index)); |
| 181 | 186 |
| 182 value_ = TypeField::encode(type) | 187 value_ = TypeField::encode(type) |
| 183 | AttributesField::encode(attributes) | 188 | AttributesField::encode(attributes) |
| 184 | StorageField::encode(index); | 189 | StorageField::encode(index); |
| 185 | 190 |
| 186 ASSERT(type == this->type()); | 191 ASSERT(type == this->type()); |
| 187 ASSERT(attributes == this->attributes()); | 192 ASSERT(attributes == this->attributes()); |
| 188 ASSERT(index == this->index()); | 193 ASSERT(index == this->index()); |
| 189 } | 194 } |
| 190 | 195 |
| 191 PropertyDetails(PropertyAttributes attributes, | |
| 192 PropertyType type, | |
| 193 ElementsKind elements_kind) { | |
| 194 ASSERT(type == ELEMENTS_TRANSITION); | |
| 195 ASSERT(TypeField::is_valid(type)); | |
| 196 ASSERT(AttributesField::is_valid(attributes)); | |
| 197 ASSERT(StorageField::is_valid(static_cast<int>(elements_kind))); | |
| 198 | |
| 199 value_ = TypeField::encode(type) | |
| 200 | AttributesField::encode(attributes) | |
| 201 | StorageField::encode(static_cast<int>(elements_kind)); | |
| 202 | |
| 203 ASSERT(type == this->type()); | |
| 204 ASSERT(attributes == this->attributes()); | |
| 205 ASSERT(elements_kind == this->elements_kind()); | |
| 206 } | |
| 207 | |
| 208 // Conversion for storing details as Object*. | 196 // Conversion for storing details as Object*. |
| 209 explicit inline PropertyDetails(Smi* smi); | 197 explicit inline PropertyDetails(Smi* smi); |
| 210 inline Smi* AsSmi(); | 198 inline Smi* AsSmi(); |
| 211 | 199 |
| 212 PropertyType type() { return TypeField::decode(value_); } | 200 PropertyType type() { return TypeField::decode(value_); } |
| 213 | 201 |
| 214 bool IsTransition() { | 202 bool IsTransition() { |
| 215 PropertyType t = type(); | 203 PropertyType t = type(); |
| 216 ASSERT(t != INTERCEPTOR); | 204 ASSERT(t != INTERCEPTOR); |
| 217 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || | 205 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || |
| 218 t == ELEMENTS_TRANSITION; | 206 t == ELEMENTS_TRANSITION; |
| 219 } | 207 } |
| 220 | 208 |
| 221 bool IsProperty() { | 209 bool IsProperty() { |
| 222 return type() < FIRST_PHANTOM_PROPERTY_TYPE; | 210 return type() < FIRST_PHANTOM_PROPERTY_TYPE; |
| 223 } | 211 } |
| 224 | 212 |
| 225 PropertyAttributes attributes() { return AttributesField::decode(value_); } | 213 PropertyAttributes attributes() { return AttributesField::decode(value_); } |
| 226 | 214 |
| 227 int index() { return StorageField::decode(value_); } | 215 int index() { return StorageField::decode(value_); } |
| 228 | 216 |
| 229 ElementsKind elements_kind() { | |
| 230 ASSERT(type() == ELEMENTS_TRANSITION); | |
| 231 return static_cast<ElementsKind>(StorageField::decode(value_)); | |
| 232 } | |
| 233 | |
| 234 inline PropertyDetails AsDeleted(); | 217 inline PropertyDetails AsDeleted(); |
| 235 | 218 |
| 236 static bool IsValidIndex(int index) { | 219 static bool IsValidIndex(int index) { |
| 237 return StorageField::is_valid(index); | 220 return StorageField::is_valid(index); |
| 238 } | 221 } |
| 239 | 222 |
| 240 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } | 223 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } |
| 241 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } | 224 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } |
| 242 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } | 225 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } |
| 243 bool IsDeleted() { return DeletedField::decode(value_) != 0;} | 226 bool IsDeleted() { return DeletedField::decode(value_) != 0;} |
| (...skipping 25 matching lines...) Expand all Loading... |
| 269 | 252 |
| 270 | 253 |
| 271 // NormalizedMapSharingMode is used to specify whether a map may be shared | 254 // NormalizedMapSharingMode is used to specify whether a map may be shared |
| 272 // by different objects with normalized properties. | 255 // by different objects with normalized properties. |
| 273 enum NormalizedMapSharingMode { | 256 enum NormalizedMapSharingMode { |
| 274 UNIQUE_NORMALIZED_MAP, | 257 UNIQUE_NORMALIZED_MAP, |
| 275 SHARED_NORMALIZED_MAP | 258 SHARED_NORMALIZED_MAP |
| 276 }; | 259 }; |
| 277 | 260 |
| 278 | 261 |
| 262 // Indicates whether a get method should implicitly create the object looked up. |
| 263 enum CreationFlag { |
| 264 ALLOW_CREATION, |
| 265 OMIT_CREATION |
| 266 }; |
| 267 |
| 268 |
| 279 // Instance size sentinel for objects of variable size. | 269 // Instance size sentinel for objects of variable size. |
| 280 static const int kVariableSizeSentinel = 0; | 270 static const int kVariableSizeSentinel = 0; |
| 281 | 271 |
| 282 | 272 |
| 283 // All Maps have a field instance_type containing a InstanceType. | 273 // All Maps have a field instance_type containing a InstanceType. |
| 284 // It describes the type of the instances. | 274 // It describes the type of the instances. |
| 285 // | 275 // |
| 286 // As an example, a JavaScript object is a heap object and its map | 276 // As an example, a JavaScript object is a heap object and its map |
| 287 // instance_type is JS_OBJECT_TYPE. | 277 // instance_type is JS_OBJECT_TYPE. |
| 288 // | 278 // |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 312 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
| 323 \ | 313 \ |
| 324 V(MAP_TYPE) \ | 314 V(MAP_TYPE) \ |
| 325 V(CODE_TYPE) \ | 315 V(CODE_TYPE) \ |
| 326 V(ODDBALL_TYPE) \ | 316 V(ODDBALL_TYPE) \ |
| 327 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 317 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
| 328 \ | 318 \ |
| 329 V(HEAP_NUMBER_TYPE) \ | 319 V(HEAP_NUMBER_TYPE) \ |
| 330 V(FOREIGN_TYPE) \ | 320 V(FOREIGN_TYPE) \ |
| 331 V(BYTE_ARRAY_TYPE) \ | 321 V(BYTE_ARRAY_TYPE) \ |
| 322 V(FREE_SPACE_TYPE) \ |
| 332 /* Note: the order of these external array */ \ | 323 /* Note: the order of these external array */ \ |
| 333 /* types is relied upon in */ \ | 324 /* types is relied upon in */ \ |
| 334 /* Object::IsExternalArray(). */ \ | 325 /* Object::IsExternalArray(). */ \ |
| 335 V(EXTERNAL_BYTE_ARRAY_TYPE) \ | 326 V(EXTERNAL_BYTE_ARRAY_TYPE) \ |
| 336 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ | 327 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ |
| 337 V(EXTERNAL_SHORT_ARRAY_TYPE) \ | 328 V(EXTERNAL_SHORT_ARRAY_TYPE) \ |
| 338 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ | 329 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ |
| 339 V(EXTERNAL_INT_ARRAY_TYPE) \ | 330 V(EXTERNAL_INT_ARRAY_TYPE) \ |
| 340 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ | 331 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ |
| 341 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ | 332 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 569 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
| 579 CODE_TYPE, | 570 CODE_TYPE, |
| 580 ODDBALL_TYPE, | 571 ODDBALL_TYPE, |
| 581 JS_GLOBAL_PROPERTY_CELL_TYPE, | 572 JS_GLOBAL_PROPERTY_CELL_TYPE, |
| 582 | 573 |
| 583 // "Data", objects that cannot contain non-map-word pointers to heap | 574 // "Data", objects that cannot contain non-map-word pointers to heap |
| 584 // objects. | 575 // objects. |
| 585 HEAP_NUMBER_TYPE, | 576 HEAP_NUMBER_TYPE, |
| 586 FOREIGN_TYPE, | 577 FOREIGN_TYPE, |
| 587 BYTE_ARRAY_TYPE, | 578 BYTE_ARRAY_TYPE, |
| 579 FREE_SPACE_TYPE, |
| 588 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 580 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
| 589 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | 581 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
| 590 EXTERNAL_SHORT_ARRAY_TYPE, | 582 EXTERNAL_SHORT_ARRAY_TYPE, |
| 591 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | 583 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
| 592 EXTERNAL_INT_ARRAY_TYPE, | 584 EXTERNAL_INT_ARRAY_TYPE, |
| 593 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | 585 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
| 594 EXTERNAL_FLOAT_ARRAY_TYPE, | 586 EXTERNAL_FLOAT_ARRAY_TYPE, |
| 595 EXTERNAL_DOUBLE_ARRAY_TYPE, | 587 EXTERNAL_DOUBLE_ARRAY_TYPE, |
| 596 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 588 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
| 597 FIXED_DOUBLE_ARRAY_TYPE, | 589 FIXED_DOUBLE_ARRAY_TYPE, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 614 // constants always having them avoids them getting different numbers | 606 // constants always having them avoids them getting different numbers |
| 615 // depending on whether ENABLE_DEBUGGER_SUPPORT is defined or not. | 607 // depending on whether ENABLE_DEBUGGER_SUPPORT is defined or not. |
| 616 DEBUG_INFO_TYPE, | 608 DEBUG_INFO_TYPE, |
| 617 BREAK_POINT_INFO_TYPE, | 609 BREAK_POINT_INFO_TYPE, |
| 618 | 610 |
| 619 FIXED_ARRAY_TYPE, | 611 FIXED_ARRAY_TYPE, |
| 620 SHARED_FUNCTION_INFO_TYPE, | 612 SHARED_FUNCTION_INFO_TYPE, |
| 621 | 613 |
| 622 JS_MESSAGE_OBJECT_TYPE, | 614 JS_MESSAGE_OBJECT_TYPE, |
| 623 | 615 |
| 624 JS_VALUE_TYPE, // FIRST_NON_CALLABLE_OBJECT_TYPE, FIRST_JS_RECEIVER_TYPE | 616 // All the following types are subtypes of JSReceiver, which corresponds to |
| 617 // objects in the JS sense. The first and the last type in this range are |
| 618 // the two forms of function. This organization enables using the same |
| 619 // compares for checking the JS_RECEIVER/SPEC_OBJECT range and the |
| 620 // NONCALLABLE_JS_OBJECT range. |
| 621 JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE |
| 622 JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE |
| 623 |
| 624 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE |
| 625 JS_OBJECT_TYPE, | 625 JS_OBJECT_TYPE, |
| 626 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 626 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
| 627 JS_GLOBAL_OBJECT_TYPE, | 627 JS_GLOBAL_OBJECT_TYPE, |
| 628 JS_BUILTINS_OBJECT_TYPE, | 628 JS_BUILTINS_OBJECT_TYPE, |
| 629 JS_GLOBAL_PROXY_TYPE, | 629 JS_GLOBAL_PROXY_TYPE, |
| 630 JS_ARRAY_TYPE, | 630 JS_ARRAY_TYPE, |
| 631 JS_PROXY_TYPE, | |
| 632 JS_WEAK_MAP_TYPE, | 631 JS_WEAK_MAP_TYPE, |
| 633 | 632 |
| 634 JS_REGEXP_TYPE, // LAST_NONCALLABLE_SPEC_OBJECT_TYPE | 633 JS_REGEXP_TYPE, |
| 635 | 634 |
| 636 JS_FUNCTION_TYPE, // FIRST_CALLABLE_SPEC_OBJECT_TYPE | 635 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE |
| 637 JS_FUNCTION_PROXY_TYPE, // LAST_CALLABLE_SPEC_OBJECT_TYPE | |
| 638 | 636 |
| 639 // Pseudo-types | 637 // Pseudo-types |
| 640 FIRST_TYPE = 0x0, | 638 FIRST_TYPE = 0x0, |
| 641 LAST_TYPE = JS_FUNCTION_PROXY_TYPE, | 639 LAST_TYPE = JS_FUNCTION_TYPE, |
| 642 INVALID_TYPE = FIRST_TYPE - 1, | 640 INVALID_TYPE = FIRST_TYPE - 1, |
| 643 FIRST_NONSTRING_TYPE = MAP_TYPE, | 641 FIRST_NONSTRING_TYPE = MAP_TYPE, |
| 644 // Boundaries for testing for an external array. | 642 // Boundaries for testing for an external array. |
| 645 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, | 643 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, |
| 646 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, | 644 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, |
| 647 // Boundary for promotion to old data space/old pointer space. | 645 // Boundary for promotion to old data space/old pointer space. |
| 648 LAST_DATA_TYPE = FILLER_TYPE, | 646 LAST_DATA_TYPE = FILLER_TYPE, |
| 649 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). | 647 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). |
| 650 // Note that there is no range for JSObject or JSProxy, since their subtypes | 648 // Note that there is no range for JSObject or JSProxy, since their subtypes |
| 651 // are not continuous in this enum! The enum ranges instead reflect the | 649 // are not continuous in this enum! The enum ranges instead reflect the |
| 652 // external class names, where proxies are treated as either ordinary objects, | 650 // external class names, where proxies are treated as either ordinary objects, |
| 653 // or functions. | 651 // or functions. |
| 654 FIRST_JS_RECEIVER_TYPE = JS_VALUE_TYPE, | 652 FIRST_JS_RECEIVER_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 655 LAST_JS_RECEIVER_TYPE = LAST_TYPE, | 653 LAST_JS_RECEIVER_TYPE = LAST_TYPE, |
| 654 // Boundaries for testing the types represented as JSObject |
| 655 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, |
| 656 LAST_JS_OBJECT_TYPE = LAST_TYPE, |
| 657 // Boundaries for testing the types represented as JSProxy |
| 658 FIRST_JS_PROXY_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 659 LAST_JS_PROXY_TYPE = JS_PROXY_TYPE, |
| 660 // Boundaries for testing whether the type is a JavaScript object. |
| 661 FIRST_SPEC_OBJECT_TYPE = FIRST_JS_RECEIVER_TYPE, |
| 662 LAST_SPEC_OBJECT_TYPE = LAST_JS_RECEIVER_TYPE, |
| 656 // Boundaries for testing the types for which typeof is "object". | 663 // Boundaries for testing the types for which typeof is "object". |
| 657 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_VALUE_TYPE, | 664 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_PROXY_TYPE, |
| 658 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE, | 665 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE, |
| 659 // Boundaries for testing the types for which typeof is "function". | 666 // Note that the types for which typeof is "function" are not continuous. |
| 660 FIRST_CALLABLE_SPEC_OBJECT_TYPE = JS_FUNCTION_TYPE, | 667 // Define this so that we can put assertions on discrete checks. |
| 661 LAST_CALLABLE_SPEC_OBJECT_TYPE = JS_FUNCTION_PROXY_TYPE, | 668 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2 |
| 662 // Boundaries for testing whether the type is a JavaScript object. | |
| 663 FIRST_SPEC_OBJECT_TYPE = FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, | |
| 664 LAST_SPEC_OBJECT_TYPE = LAST_CALLABLE_SPEC_OBJECT_TYPE | |
| 665 }; | 669 }; |
| 666 | 670 |
| 667 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE - | 671 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE - |
| 668 FIRST_EXTERNAL_ARRAY_TYPE + 1; | 672 FIRST_EXTERNAL_ARRAY_TYPE + 1; |
| 669 | 673 |
| 670 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType); | 674 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType); |
| 671 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); | 675 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); |
| 672 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType); | 676 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType); |
| 673 | 677 |
| 674 | 678 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 690 inline type* name(); \ | 694 inline type* name(); \ |
| 691 inline void set_##name(type* value, \ | 695 inline void set_##name(type* value, \ |
| 692 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 696 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
| 693 | 697 |
| 694 | 698 |
| 695 class DictionaryElementsAccessor; | 699 class DictionaryElementsAccessor; |
| 696 class ElementsAccessor; | 700 class ElementsAccessor; |
| 697 class FixedArrayBase; | 701 class FixedArrayBase; |
| 698 class ObjectVisitor; | 702 class ObjectVisitor; |
| 699 class StringStream; | 703 class StringStream; |
| 704 class Failure; |
| 700 | 705 |
| 701 struct ValueInfo : public Malloced { | 706 struct ValueInfo : public Malloced { |
| 702 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 707 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
| 703 InstanceType type; | 708 InstanceType type; |
| 704 Object* ptr; | 709 Object* ptr; |
| 705 const char* str; | 710 const char* str; |
| 706 double number; | 711 double number; |
| 707 }; | 712 }; |
| 708 | 713 |
| 709 | 714 |
| 710 // A template-ized version of the IsXXX functions. | 715 // A template-ized version of the IsXXX functions. |
| 711 template <class C> static inline bool Is(Object* obj); | 716 template <class C> static inline bool Is(Object* obj); |
| 712 | 717 |
| 713 class Failure; | |
| 714 | 718 |
| 715 class MaybeObject BASE_EMBEDDED { | 719 class MaybeObject BASE_EMBEDDED { |
| 716 public: | 720 public: |
| 717 inline bool IsFailure(); | 721 inline bool IsFailure(); |
| 718 inline bool IsRetryAfterGC(); | 722 inline bool IsRetryAfterGC(); |
| 719 inline bool IsOutOfMemory(); | 723 inline bool IsOutOfMemory(); |
| 720 inline bool IsException(); | 724 inline bool IsException(); |
| 721 INLINE(bool IsTheHole()); | 725 INLINE(bool IsTheHole()); |
| 722 inline bool ToObject(Object** obj) { | 726 inline bool ToObject(Object** obj) { |
| 723 if (IsFailure()) return false; | 727 if (IsFailure()) return false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 741 inline bool To(T** obj) { | 745 inline bool To(T** obj) { |
| 742 if (IsFailure()) return false; | 746 if (IsFailure()) return false; |
| 743 *obj = T::cast(reinterpret_cast<Object*>(this)); | 747 *obj = T::cast(reinterpret_cast<Object*>(this)); |
| 744 return true; | 748 return true; |
| 745 } | 749 } |
| 746 | 750 |
| 747 #ifdef OBJECT_PRINT | 751 #ifdef OBJECT_PRINT |
| 748 // Prints this object with details. | 752 // Prints this object with details. |
| 749 inline void Print() { | 753 inline void Print() { |
| 750 Print(stdout); | 754 Print(stdout); |
| 751 }; | 755 } |
| 752 inline void PrintLn() { | 756 inline void PrintLn() { |
| 753 PrintLn(stdout); | 757 PrintLn(stdout); |
| 754 } | 758 } |
| 755 void Print(FILE* out); | 759 void Print(FILE* out); |
| 756 void PrintLn(FILE* out); | 760 void PrintLn(FILE* out); |
| 757 #endif | 761 #endif |
| 758 #ifdef DEBUG | 762 #ifdef DEBUG |
| 759 // Verifies the object. | 763 // Verifies the object. |
| 760 void Verify(); | 764 void Verify(); |
| 761 #endif | 765 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 784 V(ExternalByteArray) \ | 788 V(ExternalByteArray) \ |
| 785 V(ExternalUnsignedByteArray) \ | 789 V(ExternalUnsignedByteArray) \ |
| 786 V(ExternalShortArray) \ | 790 V(ExternalShortArray) \ |
| 787 V(ExternalUnsignedShortArray) \ | 791 V(ExternalUnsignedShortArray) \ |
| 788 V(ExternalIntArray) \ | 792 V(ExternalIntArray) \ |
| 789 V(ExternalUnsignedIntArray) \ | 793 V(ExternalUnsignedIntArray) \ |
| 790 V(ExternalFloatArray) \ | 794 V(ExternalFloatArray) \ |
| 791 V(ExternalDoubleArray) \ | 795 V(ExternalDoubleArray) \ |
| 792 V(ExternalPixelArray) \ | 796 V(ExternalPixelArray) \ |
| 793 V(ByteArray) \ | 797 V(ByteArray) \ |
| 798 V(FreeSpace) \ |
| 794 V(JSReceiver) \ | 799 V(JSReceiver) \ |
| 795 V(JSObject) \ | 800 V(JSObject) \ |
| 796 V(JSContextExtensionObject) \ | 801 V(JSContextExtensionObject) \ |
| 797 V(Map) \ | 802 V(Map) \ |
| 798 V(DescriptorArray) \ | 803 V(DescriptorArray) \ |
| 799 V(DeoptimizationInputData) \ | 804 V(DeoptimizationInputData) \ |
| 800 V(DeoptimizationOutputData) \ | 805 V(DeoptimizationOutputData) \ |
| 801 V(FixedArray) \ | 806 V(FixedArray) \ |
| 802 V(FixedDoubleArray) \ | 807 V(FixedDoubleArray) \ |
| 803 V(Context) \ | 808 V(Context) \ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 828 V(MapCache) \ | 833 V(MapCache) \ |
| 829 V(Primitive) \ | 834 V(Primitive) \ |
| 830 V(GlobalObject) \ | 835 V(GlobalObject) \ |
| 831 V(JSGlobalObject) \ | 836 V(JSGlobalObject) \ |
| 832 V(JSBuiltinsObject) \ | 837 V(JSBuiltinsObject) \ |
| 833 V(JSGlobalProxy) \ | 838 V(JSGlobalProxy) \ |
| 834 V(UndetectableObject) \ | 839 V(UndetectableObject) \ |
| 835 V(AccessCheckNeeded) \ | 840 V(AccessCheckNeeded) \ |
| 836 V(JSGlobalPropertyCell) \ | 841 V(JSGlobalPropertyCell) \ |
| 837 | 842 |
| 843 |
| 844 class JSReceiver; |
| 845 |
| 838 // Object is the abstract superclass for all classes in the | 846 // Object is the abstract superclass for all classes in the |
| 839 // object hierarchy. | 847 // object hierarchy. |
| 840 // Object does not use any virtual functions to avoid the | 848 // Object does not use any virtual functions to avoid the |
| 841 // allocation of the C++ vtable. | 849 // allocation of the C++ vtable. |
| 842 // Since Smi and Failure are subclasses of Object no | 850 // Since Smi and Failure are subclasses of Object no |
| 843 // data members can be present in Object. | 851 // data members can be present in Object. |
| 844 class Object : public MaybeObject { | 852 class Object : public MaybeObject { |
| 845 public: | 853 public: |
| 846 // Type testing. | 854 // Type testing. |
| 847 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_(); | 855 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_(); |
| 848 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 856 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
| 849 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 857 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
| 850 #undef IS_TYPE_FUNCTION_DECL | 858 #undef IS_TYPE_FUNCTION_DECL |
| 851 | 859 |
| 852 // Returns true if this object is an instance of the specified | 860 // Returns true if this object is an instance of the specified |
| 853 // function template. | 861 // function template. |
| 854 inline bool IsInstanceOf(FunctionTemplateInfo* type); | 862 inline bool IsInstanceOf(FunctionTemplateInfo* type); |
| 855 | 863 |
| 856 inline bool IsStruct(); | 864 inline bool IsStruct(); |
| 857 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); | 865 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); |
| 858 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 866 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
| 859 #undef DECLARE_STRUCT_PREDICATE | 867 #undef DECLARE_STRUCT_PREDICATE |
| 860 | 868 |
| 861 INLINE(bool IsSpecObject()); | 869 INLINE(bool IsSpecObject()); |
| 870 INLINE(bool IsSpecFunction()); |
| 862 | 871 |
| 863 // Oddball testing. | 872 // Oddball testing. |
| 864 INLINE(bool IsUndefined()); | 873 INLINE(bool IsUndefined()); |
| 865 INLINE(bool IsNull()); | 874 INLINE(bool IsNull()); |
| 866 INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation. | 875 INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation. |
| 867 INLINE(bool IsTrue()); | 876 INLINE(bool IsTrue()); |
| 868 INLINE(bool IsFalse()); | 877 INLINE(bool IsFalse()); |
| 869 inline bool IsArgumentsMarker(); | 878 inline bool IsArgumentsMarker(); |
| 879 inline bool NonFailureIsHeapObject(); |
| 880 |
| 881 // Filler objects (fillers and free space objects). |
| 882 inline bool IsFiller(); |
| 870 | 883 |
| 871 // Extract the number. | 884 // Extract the number. |
| 872 inline double Number(); | 885 inline double Number(); |
| 873 | 886 |
| 874 // Returns true if the object is of the correct type to be used as a | 887 // Returns true if the object is of the correct type to be used as a |
| 875 // implementation of a JSObject's elements. | 888 // implementation of a JSObject's elements. |
| 876 inline bool HasValidElements(); | 889 inline bool HasValidElements(); |
| 877 | 890 |
| 878 inline bool HasSpecificClassOf(String* name); | 891 inline bool HasSpecificClassOf(String* name); |
| 879 | 892 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 896 String* key, | 909 String* key, |
| 897 PropertyAttributes* attributes); | 910 PropertyAttributes* attributes); |
| 898 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver( | 911 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver( |
| 899 Object* receiver, | 912 Object* receiver, |
| 900 String* key, | 913 String* key, |
| 901 PropertyAttributes* attributes); | 914 PropertyAttributes* attributes); |
| 902 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver, | 915 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver, |
| 903 LookupResult* result, | 916 LookupResult* result, |
| 904 String* key, | 917 String* key, |
| 905 PropertyAttributes* attributes); | 918 PropertyAttributes* attributes); |
| 906 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, | |
| 907 Object* structure, | |
| 908 String* name, | |
| 909 Object* holder); | |
| 910 MUST_USE_RESULT MaybeObject* GetPropertyWithHandler(Object* receiver, | |
| 911 String* name, | |
| 912 Object* handler); | |
| 913 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver, | 919 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver, |
| 914 JSFunction* getter); | 920 JSReceiver* getter); |
| 915 | 921 |
| 916 inline MaybeObject* GetElement(uint32_t index); | 922 inline MaybeObject* GetElement(uint32_t index); |
| 917 // For use when we know that no exception can be thrown. | 923 // For use when we know that no exception can be thrown. |
| 918 inline Object* GetElementNoExceptionThrown(uint32_t index); | 924 inline Object* GetElementNoExceptionThrown(uint32_t index); |
| 919 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); | 925 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index); |
| 920 | 926 |
| 921 // Return the object's prototype (might be Heap::null_value()). | 927 // Return the object's prototype (might be Heap::null_value()). |
| 922 Object* GetPrototype(); | 928 Object* GetPrototype(); |
| 923 | 929 |
| 924 // Tries to convert an object to an array index. Returns true and sets | 930 // Tries to convert an object to an array index. Returns true and sets |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 // collection. Only valid during a scavenge collection (specifically, | 1094 // collection. Only valid during a scavenge collection (specifically, |
| 1089 // when all map words are heap object pointers, ie. not during a full GC). | 1095 // when all map words are heap object pointers, ie. not during a full GC). |
| 1090 inline bool IsForwardingAddress(); | 1096 inline bool IsForwardingAddress(); |
| 1091 | 1097 |
| 1092 // Create a map word from a forwarding address. | 1098 // Create a map word from a forwarding address. |
| 1093 static inline MapWord FromForwardingAddress(HeapObject* object); | 1099 static inline MapWord FromForwardingAddress(HeapObject* object); |
| 1094 | 1100 |
| 1095 // View this map word as a forwarding address. | 1101 // View this map word as a forwarding address. |
| 1096 inline HeapObject* ToForwardingAddress(); | 1102 inline HeapObject* ToForwardingAddress(); |
| 1097 | 1103 |
| 1098 // Marking phase of full collection: the map word of live objects is | 1104 static inline MapWord FromRawValue(uintptr_t value) { |
| 1099 // marked, and may be marked as overflowed (eg, the object is live, its | 1105 return MapWord(value); |
| 1100 // children have not been visited, and it does not fit in the marking | 1106 } |
| 1101 // stack). | |
| 1102 | 1107 |
| 1103 // True if this map word's mark bit is set. | 1108 inline uintptr_t ToRawValue() { |
| 1104 inline bool IsMarked(); | 1109 return value_; |
| 1105 | 1110 } |
| 1106 // Return this map word but with its mark bit set. | |
| 1107 inline void SetMark(); | |
| 1108 | |
| 1109 // Return this map word but with its mark bit cleared. | |
| 1110 inline void ClearMark(); | |
| 1111 | |
| 1112 // True if this map word's overflow bit is set. | |
| 1113 inline bool IsOverflowed(); | |
| 1114 | |
| 1115 // Return this map word but with its overflow bit set. | |
| 1116 inline void SetOverflow(); | |
| 1117 | |
| 1118 // Return this map word but with its overflow bit cleared. | |
| 1119 inline void ClearOverflow(); | |
| 1120 | |
| 1121 | |
| 1122 // Compacting phase of a full compacting collection: the map word of live | |
| 1123 // objects contains an encoding of the original map address along with the | |
| 1124 // forwarding address (represented as an offset from the first live object | |
| 1125 // in the same page as the (old) object address). | |
| 1126 | |
| 1127 // Create a map word from a map address and a forwarding address offset. | |
| 1128 static inline MapWord EncodeAddress(Address map_address, int offset); | |
| 1129 | |
| 1130 // Return the map address encoded in this map word. | |
| 1131 inline Address DecodeMapAddress(MapSpace* map_space); | |
| 1132 | |
| 1133 // Return the forwarding offset encoded in this map word. | |
| 1134 inline int DecodeOffset(); | |
| 1135 | |
| 1136 | |
| 1137 // During serialization: the map word is used to hold an encoded | |
| 1138 // address, and possibly a mark bit (set and cleared with SetMark | |
| 1139 // and ClearMark). | |
| 1140 | |
| 1141 // Create a map word from an encoded address. | |
| 1142 static inline MapWord FromEncodedAddress(Address address); | |
| 1143 | |
| 1144 inline Address ToEncodedAddress(); | |
| 1145 | |
| 1146 // Bits used by the marking phase of the garbage collector. | |
| 1147 // | |
| 1148 // The first word of a heap object is normally a map pointer. The last two | |
| 1149 // bits are tagged as '01' (kHeapObjectTag). We reuse the last two bits to | |
| 1150 // mark an object as live and/or overflowed: | |
| 1151 // last bit = 0, marked as alive | |
| 1152 // second bit = 1, overflowed | |
| 1153 // An object is only marked as overflowed when it is marked as live while | |
| 1154 // the marking stack is overflowed. | |
| 1155 static const int kMarkingBit = 0; // marking bit | |
| 1156 static const int kMarkingMask = (1 << kMarkingBit); // marking mask | |
| 1157 static const int kOverflowBit = 1; // overflow bit | |
| 1158 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask | |
| 1159 | |
| 1160 // Forwarding pointers and map pointer encoding. On 32 bit all the bits are | |
| 1161 // used. | |
| 1162 // +-----------------+------------------+-----------------+ | |
| 1163 // |forwarding offset|page offset of map|page index of map| | |
| 1164 // +-----------------+------------------+-----------------+ | |
| 1165 // ^ ^ ^ | |
| 1166 // | | | | |
| 1167 // | | kMapPageIndexBits | |
| 1168 // | kMapPageOffsetBits | |
| 1169 // kForwardingOffsetBits | |
| 1170 static const int kMapPageOffsetBits = kPageSizeBits - kMapAlignmentBits; | |
| 1171 static const int kForwardingOffsetBits = kPageSizeBits - kObjectAlignmentBits; | |
| 1172 #ifdef V8_HOST_ARCH_64_BIT | |
| 1173 static const int kMapPageIndexBits = 16; | |
| 1174 #else | |
| 1175 // Use all the 32-bits to encode on a 32-bit platform. | |
| 1176 static const int kMapPageIndexBits = | |
| 1177 32 - (kMapPageOffsetBits + kForwardingOffsetBits); | |
| 1178 #endif | |
| 1179 | |
| 1180 static const int kMapPageIndexShift = 0; | |
| 1181 static const int kMapPageOffsetShift = | |
| 1182 kMapPageIndexShift + kMapPageIndexBits; | |
| 1183 static const int kForwardingOffsetShift = | |
| 1184 kMapPageOffsetShift + kMapPageOffsetBits; | |
| 1185 | |
| 1186 // Bit masks covering the different parts the encoding. | |
| 1187 static const uintptr_t kMapPageIndexMask = | |
| 1188 (1 << kMapPageOffsetShift) - 1; | |
| 1189 static const uintptr_t kMapPageOffsetMask = | |
| 1190 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; | |
| 1191 static const uintptr_t kForwardingOffsetMask = | |
| 1192 ~(kMapPageIndexMask | kMapPageOffsetMask); | |
| 1193 | 1111 |
| 1194 private: | 1112 private: |
| 1195 // HeapObject calls the private constructor and directly reads the value. | 1113 // HeapObject calls the private constructor and directly reads the value. |
| 1196 friend class HeapObject; | 1114 friend class HeapObject; |
| 1197 | 1115 |
| 1198 explicit MapWord(uintptr_t value) : value_(value) {} | 1116 explicit MapWord(uintptr_t value) : value_(value) {} |
| 1199 | 1117 |
| 1200 uintptr_t value_; | 1118 uintptr_t value_; |
| 1201 }; | 1119 }; |
| 1202 | 1120 |
| 1203 | 1121 |
| 1204 // HeapObject is the superclass for all classes describing heap allocated | 1122 // HeapObject is the superclass for all classes describing heap allocated |
| 1205 // objects. | 1123 // objects. |
| 1206 class HeapObject: public Object { | 1124 class HeapObject: public Object { |
| 1207 public: | 1125 public: |
| 1208 // [map]: Contains a map which contains the object's reflective | 1126 // [map]: Contains a map which contains the object's reflective |
| 1209 // information. | 1127 // information. |
| 1210 inline Map* map(); | 1128 inline Map* map(); |
| 1211 inline void set_map(Map* value); | 1129 inline void set_map(Map* value); |
| 1130 inline void set_map_unsafe(Map* value); |
| 1212 | 1131 |
| 1213 // During garbage collection, the map word of a heap object does not | 1132 // During garbage collection, the map word of a heap object does not |
| 1214 // necessarily contain a map pointer. | 1133 // necessarily contain a map pointer. |
| 1215 inline MapWord map_word(); | 1134 inline MapWord map_word(); |
| 1216 inline void set_map_word(MapWord map_word); | 1135 inline void set_map_word(MapWord map_word); |
| 1217 | 1136 |
| 1218 // The Heap the object was allocated in. Used also to access Isolate. | 1137 // The Heap the object was allocated in. Used also to access Isolate. |
| 1219 // This method can not be used during GC, it ASSERTs this. | |
| 1220 inline Heap* GetHeap(); | 1138 inline Heap* GetHeap(); |
| 1139 |
| 1221 // Convenience method to get current isolate. This method can be | 1140 // Convenience method to get current isolate. This method can be |
| 1222 // accessed only when its result is the same as | 1141 // accessed only when its result is the same as |
| 1223 // Isolate::Current(), it ASSERTs this. See also comment for GetHeap. | 1142 // Isolate::Current(), it ASSERTs this. See also comment for GetHeap. |
| 1224 inline Isolate* GetIsolate(); | 1143 inline Isolate* GetIsolate(); |
| 1225 | 1144 |
| 1226 // Converts an address to a HeapObject pointer. | 1145 // Converts an address to a HeapObject pointer. |
| 1227 static inline HeapObject* FromAddress(Address address); | 1146 static inline HeapObject* FromAddress(Address address); |
| 1228 | 1147 |
| 1229 // Returns the address of this HeapObject. | 1148 // Returns the address of this HeapObject. |
| 1230 inline Address address(); | 1149 inline Address address(); |
| 1231 | 1150 |
| 1232 // Iterates over pointers contained in the object (including the Map) | 1151 // Iterates over pointers contained in the object (including the Map) |
| 1233 void Iterate(ObjectVisitor* v); | 1152 void Iterate(ObjectVisitor* v); |
| 1234 | 1153 |
| 1235 // Iterates over all pointers contained in the object except the | 1154 // Iterates over all pointers contained in the object except the |
| 1236 // first map pointer. The object type is given in the first | 1155 // first map pointer. The object type is given in the first |
| 1237 // parameter. This function does not access the map pointer in the | 1156 // parameter. This function does not access the map pointer in the |
| 1238 // object, and so is safe to call while the map pointer is modified. | 1157 // object, and so is safe to call while the map pointer is modified. |
| 1239 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); | 1158 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); |
| 1240 | 1159 |
| 1241 // Returns the heap object's size in bytes | 1160 // Returns the heap object's size in bytes |
| 1242 inline int Size(); | 1161 inline int Size(); |
| 1243 | 1162 |
| 1244 // Given a heap object's map pointer, returns the heap size in bytes | 1163 // Given a heap object's map pointer, returns the heap size in bytes |
| 1245 // Useful when the map pointer field is used for other purposes. | 1164 // Useful when the map pointer field is used for other purposes. |
| 1246 // GC internal. | 1165 // GC internal. |
| 1247 inline int SizeFromMap(Map* map); | 1166 inline int SizeFromMap(Map* map); |
| 1248 | 1167 |
| 1249 // Support for the marking heap objects during the marking phase of GC. | |
| 1250 // True if the object is marked live. | |
| 1251 inline bool IsMarked(); | |
| 1252 | |
| 1253 // Mutate this object's map pointer to indicate that the object is live. | |
| 1254 inline void SetMark(); | |
| 1255 | |
| 1256 // Mutate this object's map pointer to remove the indication that the | |
| 1257 // object is live (ie, partially restore the map pointer). | |
| 1258 inline void ClearMark(); | |
| 1259 | |
| 1260 // True if this object is marked as overflowed. Overflowed objects have | |
| 1261 // been reached and marked during marking of the heap, but their children | |
| 1262 // have not necessarily been marked and they have not been pushed on the | |
| 1263 // marking stack. | |
| 1264 inline bool IsOverflowed(); | |
| 1265 | |
| 1266 // Mutate this object's map pointer to indicate that the object is | |
| 1267 // overflowed. | |
| 1268 inline void SetOverflow(); | |
| 1269 | |
| 1270 // Mutate this object's map pointer to remove the indication that the | |
| 1271 // object is overflowed (ie, partially restore the map pointer). | |
| 1272 inline void ClearOverflow(); | |
| 1273 | |
| 1274 // Returns the field at offset in obj, as a read/write Object* reference. | 1168 // Returns the field at offset in obj, as a read/write Object* reference. |
| 1275 // Does no checking, and is safe to use during GC, while maps are invalid. | 1169 // Does no checking, and is safe to use during GC, while maps are invalid. |
| 1276 // Does not invoke write barrier, so should only be assigned to | 1170 // Does not invoke write barrier, so should only be assigned to |
| 1277 // during marking GC. | 1171 // during marking GC. |
| 1278 static inline Object** RawField(HeapObject* obj, int offset); | 1172 static inline Object** RawField(HeapObject* obj, int offset); |
| 1279 | 1173 |
| 1280 // Casting. | 1174 // Casting. |
| 1281 static inline HeapObject* cast(Object* obj); | 1175 static inline HeapObject* cast(Object* obj); |
| 1282 | 1176 |
| 1283 // Return the write barrier mode for this. Callers of this function | 1177 // Return the write barrier mode for this. Callers of this function |
| 1284 // must be able to present a reference to an AssertNoAllocation | 1178 // must be able to present a reference to an AssertNoAllocation |
| 1285 // object as a sign that they are not going to use this function | 1179 // object as a sign that they are not going to use this function |
| 1286 // from code that allocates and thus invalidates the returned write | 1180 // from code that allocates and thus invalidates the returned write |
| 1287 // barrier mode. | 1181 // barrier mode. |
| 1288 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); | 1182 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); |
| 1289 | 1183 |
| 1290 // Dispatched behavior. | 1184 // Dispatched behavior. |
| 1291 void HeapObjectShortPrint(StringStream* accumulator); | 1185 void HeapObjectShortPrint(StringStream* accumulator); |
| 1292 #ifdef OBJECT_PRINT | 1186 #ifdef OBJECT_PRINT |
| 1293 inline void HeapObjectPrint() { | 1187 inline void HeapObjectPrint() { |
| 1294 HeapObjectPrint(stdout); | 1188 HeapObjectPrint(stdout); |
| 1295 } | 1189 } |
| 1296 void HeapObjectPrint(FILE* out); | 1190 void HeapObjectPrint(FILE* out); |
| 1191 void PrintHeader(FILE* out, const char* id); |
| 1297 #endif | 1192 #endif |
| 1193 |
| 1298 #ifdef DEBUG | 1194 #ifdef DEBUG |
| 1299 void HeapObjectVerify(); | 1195 void HeapObjectVerify(); |
| 1300 inline void VerifyObjectField(int offset); | 1196 inline void VerifyObjectField(int offset); |
| 1301 inline void VerifySmiField(int offset); | 1197 inline void VerifySmiField(int offset); |
| 1302 #endif | |
| 1303 | 1198 |
| 1304 #ifdef OBJECT_PRINT | |
| 1305 void PrintHeader(FILE* out, const char* id); | |
| 1306 #endif | |
| 1307 | |
| 1308 #ifdef DEBUG | |
| 1309 // Verify a pointer is a valid HeapObject pointer that points to object | 1199 // Verify a pointer is a valid HeapObject pointer that points to object |
| 1310 // areas in the heap. | 1200 // areas in the heap. |
| 1311 static void VerifyHeapPointer(Object* p); | 1201 static void VerifyHeapPointer(Object* p); |
| 1312 #endif | 1202 #endif |
| 1313 | 1203 |
| 1314 // Layout description. | 1204 // Layout description. |
| 1315 // First field in a heap object is map. | 1205 // First field in a heap object is map. |
| 1316 static const int kMapOffset = Object::kHeaderSize; | 1206 static const int kMapOffset = Object::kHeaderSize; |
| 1317 static const int kHeaderSize = kMapOffset + kPointerSize; | 1207 static const int kHeaderSize = kMapOffset + kPointerSize; |
| 1318 | 1208 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 // Can cause GC. | 1331 // Can cause GC. |
| 1442 MUST_USE_RESULT MaybeObject* SetProperty(String* key, | 1332 MUST_USE_RESULT MaybeObject* SetProperty(String* key, |
| 1443 Object* value, | 1333 Object* value, |
| 1444 PropertyAttributes attributes, | 1334 PropertyAttributes attributes, |
| 1445 StrictModeFlag strict_mode); | 1335 StrictModeFlag strict_mode); |
| 1446 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, | 1336 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, |
| 1447 String* key, | 1337 String* key, |
| 1448 Object* value, | 1338 Object* value, |
| 1449 PropertyAttributes attributes, | 1339 PropertyAttributes attributes, |
| 1450 StrictModeFlag strict_mode); | 1340 StrictModeFlag strict_mode); |
| 1341 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter, |
| 1342 Object* value); |
| 1451 | 1343 |
| 1452 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1344 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); |
| 1345 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
| 1346 |
| 1347 // Set the index'th array element. |
| 1348 // Can cause GC, or return failure if GC is required. |
| 1349 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
| 1350 Object* value, |
| 1351 StrictModeFlag strict_mode, |
| 1352 bool check_prototype); |
| 1453 | 1353 |
| 1454 // Returns the class name ([[Class]] property in the specification). | 1354 // Returns the class name ([[Class]] property in the specification). |
| 1455 String* class_name(); | 1355 String* class_name(); |
| 1456 | 1356 |
| 1457 // Returns the constructor name (the name (possibly, inferred name) of the | 1357 // Returns the constructor name (the name (possibly, inferred name) of the |
| 1458 // function that was used to instantiate the object). | 1358 // function that was used to instantiate the object). |
| 1459 String* constructor_name(); | 1359 String* constructor_name(); |
| 1460 | 1360 |
| 1461 inline PropertyAttributes GetPropertyAttribute(String* name); | 1361 inline PropertyAttributes GetPropertyAttribute(String* name); |
| 1462 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, | 1362 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, |
| 1463 String* name); | 1363 String* name); |
| 1464 PropertyAttributes GetLocalPropertyAttribute(String* name); | 1364 PropertyAttributes GetLocalPropertyAttribute(String* name); |
| 1465 | 1365 |
| 1466 // Can cause a GC. | 1366 // Can cause a GC. |
| 1467 inline bool HasProperty(String* name); | 1367 inline bool HasProperty(String* name); |
| 1468 inline bool HasLocalProperty(String* name); | 1368 inline bool HasLocalProperty(String* name); |
| 1369 inline bool HasElement(uint32_t index); |
| 1469 | 1370 |
| 1470 // Return the object's prototype (might be Heap::null_value()). | 1371 // Return the object's prototype (might be Heap::null_value()). |
| 1471 inline Object* GetPrototype(); | 1372 inline Object* GetPrototype(); |
| 1472 | 1373 |
| 1473 // Set the object's prototype (only JSReceiver and null are allowed). | 1374 // Set the object's prototype (only JSReceiver and null are allowed). |
| 1474 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, | 1375 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, |
| 1475 bool skip_hidden_prototypes); | 1376 bool skip_hidden_prototypes); |
| 1476 | 1377 |
| 1378 // Retrieves a permanent object identity hash code. The undefined value might |
| 1379 // be returned in case no has been created yet and OMIT_CREATION was used. |
| 1380 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| 1381 |
| 1477 // Lookup a property. If found, the result is valid and has | 1382 // Lookup a property. If found, the result is valid and has |
| 1478 // detailed information. | 1383 // detailed information. |
| 1479 void LocalLookup(String* name, LookupResult* result); | 1384 void LocalLookup(String* name, LookupResult* result); |
| 1480 void Lookup(String* name, LookupResult* result); | 1385 void Lookup(String* name, LookupResult* result); |
| 1481 | 1386 |
| 1387 protected: |
| 1388 Smi* GenerateIdentityHash(); |
| 1389 |
| 1482 private: | 1390 private: |
| 1483 PropertyAttributes GetPropertyAttribute(JSReceiver* receiver, | 1391 PropertyAttributes GetPropertyAttribute(JSReceiver* receiver, |
| 1484 LookupResult* result, | 1392 LookupResult* result, |
| 1485 String* name, | 1393 String* name, |
| 1486 bool continue_search); | 1394 bool continue_search); |
| 1487 | 1395 |
| 1488 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 1396 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
| 1489 }; | 1397 }; |
| 1490 | 1398 |
| 1491 // The JSObject describes real heap allocated JavaScript objects with | 1399 // The JSObject describes real heap allocated JavaScript objects with |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1518 // EnsureWritableFastElements in this case. | 1426 // EnsureWritableFastElements in this case. |
| 1519 // | 1427 // |
| 1520 // In the slow mode the elements is either a NumberDictionary, an | 1428 // In the slow mode the elements is either a NumberDictionary, an |
| 1521 // ExternalArray, or a FixedArray parameter map for a (non-strict) | 1429 // ExternalArray, or a FixedArray parameter map for a (non-strict) |
| 1522 // arguments object. | 1430 // arguments object. |
| 1523 DECL_ACCESSORS(elements, FixedArrayBase) | 1431 DECL_ACCESSORS(elements, FixedArrayBase) |
| 1524 inline void initialize_elements(); | 1432 inline void initialize_elements(); |
| 1525 MUST_USE_RESULT inline MaybeObject* ResetElements(); | 1433 MUST_USE_RESULT inline MaybeObject* ResetElements(); |
| 1526 inline ElementsKind GetElementsKind(); | 1434 inline ElementsKind GetElementsKind(); |
| 1527 inline ElementsAccessor* GetElementsAccessor(); | 1435 inline ElementsAccessor* GetElementsAccessor(); |
| 1436 inline bool HasFastSmiOnlyElements(); |
| 1528 inline bool HasFastElements(); | 1437 inline bool HasFastElements(); |
| 1438 // Returns if an object has either FAST_ELEMENT or FAST_SMI_ONLY_ELEMENT |
| 1439 // elements. TODO(danno): Rename HasFastTypeElements to HasFastElements() and |
| 1440 // HasFastElements to HasFastObjectElements. |
| 1441 inline bool HasFastTypeElements(); |
| 1529 inline bool HasFastDoubleElements(); | 1442 inline bool HasFastDoubleElements(); |
| 1443 inline bool HasNonStrictArgumentsElements(); |
| 1530 inline bool HasDictionaryElements(); | 1444 inline bool HasDictionaryElements(); |
| 1531 inline bool HasExternalPixelElements(); | 1445 inline bool HasExternalPixelElements(); |
| 1532 inline bool HasExternalArrayElements(); | 1446 inline bool HasExternalArrayElements(); |
| 1533 inline bool HasExternalByteElements(); | 1447 inline bool HasExternalByteElements(); |
| 1534 inline bool HasExternalUnsignedByteElements(); | 1448 inline bool HasExternalUnsignedByteElements(); |
| 1535 inline bool HasExternalShortElements(); | 1449 inline bool HasExternalShortElements(); |
| 1536 inline bool HasExternalUnsignedShortElements(); | 1450 inline bool HasExternalUnsignedShortElements(); |
| 1537 inline bool HasExternalIntElements(); | 1451 inline bool HasExternalIntElements(); |
| 1538 inline bool HasExternalUnsignedIntElements(); | 1452 inline bool HasExternalUnsignedIntElements(); |
| 1539 inline bool HasExternalFloatElements(); | 1453 inline bool HasExternalFloatElements(); |
| 1540 inline bool HasExternalDoubleElements(); | 1454 inline bool HasExternalDoubleElements(); |
| 1541 bool HasFastArgumentsElements(); | 1455 bool HasFastArgumentsElements(); |
| 1542 bool HasDictionaryArgumentsElements(); | 1456 bool HasDictionaryArgumentsElements(); |
| 1543 inline bool AllowsSetElementsLength(); | 1457 inline bool AllowsSetElementsLength(); |
| 1544 inline NumberDictionary* element_dictionary(); // Gets slow elements. | 1458 inline NumberDictionary* element_dictionary(); // Gets slow elements. |
| 1545 | 1459 |
| 1546 // Requires: HasFastElements(). | 1460 // Requires: HasFastElements(). |
| 1547 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); | 1461 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); |
| 1548 | 1462 |
| 1549 // Collects elements starting at index 0. | 1463 // Collects elements starting at index 0. |
| 1550 // Undefined values are placed after non-undefined values. | 1464 // Undefined values are placed after non-undefined values. |
| 1551 // Returns the number of non-undefined values. | 1465 // Returns the number of non-undefined values. |
| 1552 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); | 1466 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); |
| 1553 // As PrepareElementsForSort, but only on objects where elements is | 1467 // As PrepareElementsForSort, but only on objects where elements is |
| 1554 // a dictionary, and it will stay a dictionary. | 1468 // a dictionary, and it will stay a dictionary. |
| 1555 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); | 1469 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); |
| 1556 | 1470 |
| 1471 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, |
| 1472 Object* structure, |
| 1473 String* name); |
| 1474 |
| 1475 // Can cause GC. |
| 1557 MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result, | 1476 MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result, |
| 1558 String* key, | 1477 String* key, |
| 1559 Object* value, | 1478 Object* value, |
| 1560 PropertyAttributes attributes, | 1479 PropertyAttributes attributes, |
| 1561 StrictModeFlag strict_mode); | 1480 StrictModeFlag strict_mode); |
| 1562 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( | 1481 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( |
| 1563 LookupResult* result, | 1482 LookupResult* result, |
| 1564 String* name, | 1483 String* name, |
| 1565 Object* value, | 1484 Object* value, |
| 1566 bool check_prototype, | 1485 bool check_prototype, |
| 1567 StrictModeFlag strict_mode); | 1486 StrictModeFlag strict_mode); |
| 1568 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( | 1487 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( |
| 1569 Object* structure, | 1488 Object* structure, |
| 1570 String* name, | 1489 String* name, |
| 1571 Object* value, | 1490 Object* value, |
| 1572 JSObject* holder, | 1491 JSObject* holder, |
| 1573 StrictModeFlag strict_mode); | 1492 StrictModeFlag strict_mode); |
| 1574 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSFunction* setter, | |
| 1575 Object* value); | |
| 1576 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( | 1493 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( |
| 1577 String* name, | 1494 String* name, |
| 1578 Object* value, | 1495 Object* value, |
| 1579 PropertyAttributes attributes, | 1496 PropertyAttributes attributes, |
| 1580 StrictModeFlag strict_mode); | 1497 StrictModeFlag strict_mode); |
| 1581 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( | 1498 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( |
| 1582 String* name, | 1499 String* name, |
| 1583 Object* value, | 1500 Object* value, |
| 1584 PropertyAttributes attributes, | 1501 PropertyAttributes attributes, |
| 1585 StrictModeFlag strict_mode); | 1502 StrictModeFlag strict_mode); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 // been modified since it was created. May give false positives. | 1570 // been modified since it was created. May give false positives. |
| 1654 bool IsDirty(); | 1571 bool IsDirty(); |
| 1655 | 1572 |
| 1656 // If the receiver is a JSGlobalProxy this method will return its prototype, | 1573 // If the receiver is a JSGlobalProxy this method will return its prototype, |
| 1657 // otherwise the result is the receiver itself. | 1574 // otherwise the result is the receiver itself. |
| 1658 inline Object* BypassGlobalProxy(); | 1575 inline Object* BypassGlobalProxy(); |
| 1659 | 1576 |
| 1660 // Accessors for hidden properties object. | 1577 // Accessors for hidden properties object. |
| 1661 // | 1578 // |
| 1662 // Hidden properties are not local properties of the object itself. | 1579 // Hidden properties are not local properties of the object itself. |
| 1663 // Instead they are stored on an auxiliary JSObject stored as a local | 1580 // Instead they are stored in an auxiliary structure kept as a local |
| 1664 // property with a special name Heap::hidden_symbol(). But if the | 1581 // property with a special name Heap::hidden_symbol(). But if the |
| 1665 // receiver is a JSGlobalProxy then the auxiliary object is a property | 1582 // receiver is a JSGlobalProxy then the auxiliary object is a property |
| 1666 // of its prototype. | 1583 // of its prototype, and if it's a detached proxy, then you can't have |
| 1667 // | 1584 // hidden properties. |
| 1668 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be | |
| 1669 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real | |
| 1670 // holder. | |
| 1671 // | |
| 1672 // These accessors do not touch interceptors or accessors. | |
| 1673 inline bool HasHiddenPropertiesObject(); | |
| 1674 inline Object* GetHiddenPropertiesObject(); | |
| 1675 MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject( | |
| 1676 Object* hidden_obj); | |
| 1677 | 1585 |
| 1678 // Indicates whether the hidden properties object should be created. | 1586 // Sets a hidden property on this object. Returns this object if successful, |
| 1679 enum HiddenPropertiesFlag { ALLOW_CREATION, OMIT_CREATION }; | 1587 // undefined if called on a detached proxy, and a failure if a GC |
| 1588 // is required |
| 1589 MaybeObject* SetHiddenProperty(String* key, Object* value); |
| 1590 // Gets the value of a hidden property with the given key. Returns undefined |
| 1591 // if the property doesn't exist (or if called on a detached proxy), |
| 1592 // otherwise returns the value set for the key. |
| 1593 Object* GetHiddenProperty(String* key); |
| 1594 // Deletes a hidden property. Deleting a non-existing property is |
| 1595 // considered successful. |
| 1596 void DeleteHiddenProperty(String* key); |
| 1597 // Returns true if the object has a property with the hidden symbol as name. |
| 1598 bool HasHiddenProperties(); |
| 1680 | 1599 |
| 1681 // Retrieves the hidden properties object. | 1600 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| 1682 // | 1601 MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag); |
| 1683 // The undefined value might be returned in case no hidden properties object | |
| 1684 // is present and creation was omitted. | |
| 1685 inline bool HasHiddenProperties(); | |
| 1686 MUST_USE_RESULT MaybeObject* GetHiddenProperties(HiddenPropertiesFlag flag); | |
| 1687 | |
| 1688 // Retrieves a permanent object identity hash code. | |
| 1689 // | |
| 1690 // The identity hash is stored as a hidden property. The undefined value might | |
| 1691 // be returned in case no hidden properties object is present and creation was | |
| 1692 // omitted. | |
| 1693 MUST_USE_RESULT MaybeObject* GetIdentityHash(HiddenPropertiesFlag flag); | |
| 1694 | 1602 |
| 1695 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1603 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); |
| 1696 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); | 1604 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
| 1697 | 1605 |
| 1698 // Tests for the fast common case for property enumeration. | 1606 // Tests for the fast common case for property enumeration. |
| 1699 bool IsSimpleEnum(); | 1607 bool IsSimpleEnum(); |
| 1700 | 1608 |
| 1609 inline void ValidateSmiOnlyElements(); |
| 1610 |
| 1611 // Makes sure that this object can contain non-smi Object as elements. |
| 1612 inline MaybeObject* EnsureCanContainNonSmiElements(); |
| 1613 |
| 1614 // Makes sure that this object can contain the specified elements. |
| 1615 inline MaybeObject* EnsureCanContainElements(Object** elements, |
| 1616 uint32_t count); |
| 1617 inline MaybeObject* EnsureCanContainElements(FixedArray* elements); |
| 1618 MaybeObject* EnsureCanContainElements(Arguments* arguments, |
| 1619 uint32_t first_arg, |
| 1620 uint32_t arg_count); |
| 1621 |
| 1701 // Do we want to keep the elements in fast case when increasing the | 1622 // Do we want to keep the elements in fast case when increasing the |
| 1702 // capacity? | 1623 // capacity? |
| 1703 bool ShouldConvertToSlowElements(int new_capacity); | 1624 bool ShouldConvertToSlowElements(int new_capacity); |
| 1704 // Returns true if the backing storage for the slow-case elements of | 1625 // Returns true if the backing storage for the slow-case elements of |
| 1705 // this object takes up nearly as much space as a fast-case backing | 1626 // this object takes up nearly as much space as a fast-case backing |
| 1706 // storage would. In that case the JSObject should have fast | 1627 // storage would. In that case the JSObject should have fast |
| 1707 // elements. | 1628 // elements. |
| 1708 bool ShouldConvertToFastElements(); | 1629 bool ShouldConvertToFastElements(); |
| 1709 // Returns true if the elements of JSObject contains only values that can be | 1630 // Returns true if the elements of JSObject contains only values that can be |
| 1710 // represented in a FixedDoubleArray. | 1631 // represented in a FixedDoubleArray. |
| 1711 bool CanConvertToFastDoubleElements(); | 1632 bool CanConvertToFastDoubleElements(); |
| 1712 | 1633 |
| 1713 // Tells whether the index'th element is present. | 1634 // Tells whether the index'th element is present. |
| 1714 inline bool HasElement(uint32_t index); | |
| 1715 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index); | 1635 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index); |
| 1716 | 1636 |
| 1717 // Computes the new capacity when expanding the elements of a JSObject. | 1637 // Computes the new capacity when expanding the elements of a JSObject. |
| 1718 static int NewElementsCapacity(int old_capacity) { | 1638 static int NewElementsCapacity(int old_capacity) { |
| 1719 // (old_capacity + 50%) + 16 | 1639 // (old_capacity + 50%) + 16 |
| 1720 return old_capacity + (old_capacity >> 1) + 16; | 1640 return old_capacity + (old_capacity >> 1) + 16; |
| 1721 } | 1641 } |
| 1722 | 1642 |
| 1723 // Tells whether the index'th element is present and how it is stored. | 1643 // Tells whether the index'th element is present and how it is stored. |
| 1724 enum LocalElementType { | 1644 enum LocalElementType { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1740 | 1660 |
| 1741 LocalElementType HasLocalElement(uint32_t index); | 1661 LocalElementType HasLocalElement(uint32_t index); |
| 1742 | 1662 |
| 1743 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index); | 1663 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index); |
| 1744 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index); | 1664 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index); |
| 1745 | 1665 |
| 1746 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 1666 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
| 1747 Object* value, | 1667 Object* value, |
| 1748 StrictModeFlag strict_mode, | 1668 StrictModeFlag strict_mode, |
| 1749 bool check_prototype); | 1669 bool check_prototype); |
| 1670 |
| 1750 MUST_USE_RESULT MaybeObject* SetDictionaryElement(uint32_t index, | 1671 MUST_USE_RESULT MaybeObject* SetDictionaryElement(uint32_t index, |
| 1751 Object* value, | 1672 Object* value, |
| 1752 StrictModeFlag strict_mode, | 1673 StrictModeFlag strict_mode, |
| 1753 bool check_prototype); | 1674 bool check_prototype); |
| 1754 | 1675 |
| 1755 MUST_USE_RESULT MaybeObject* SetFastDoubleElement( | 1676 MUST_USE_RESULT MaybeObject* SetFastDoubleElement( |
| 1756 uint32_t index, | 1677 uint32_t index, |
| 1757 Object* value, | 1678 Object* value, |
| 1758 StrictModeFlag strict_mode, | 1679 StrictModeFlag strict_mode, |
| 1759 bool check_prototype = true); | 1680 bool check_prototype = true); |
| 1760 | 1681 |
| 1761 // Set the index'th array element. | 1682 // Set the index'th array element. |
| 1762 // A Failure object is returned if GC is needed. | 1683 // A Failure object is returned if GC is needed. |
| 1763 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, | 1684 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
| 1764 Object* value, | 1685 Object* value, |
| 1765 StrictModeFlag strict_mode, | 1686 StrictModeFlag strict_mode, |
| 1766 bool check_prototype); | 1687 bool check_prototype); |
| 1767 | 1688 |
| 1768 // Returns the index'th element. | 1689 // Returns the index'th element. |
| 1769 // The undefined object if index is out of bounds. | 1690 // The undefined object if index is out of bounds. |
| 1770 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); | 1691 MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); |
| 1771 | 1692 |
| 1693 enum SetFastElementsCapacityMode { |
| 1694 kAllowSmiOnlyElements, |
| 1695 kDontAllowSmiOnlyElements |
| 1696 }; |
| 1697 |
| 1772 // Replace the elements' backing store with fast elements of the given | 1698 // Replace the elements' backing store with fast elements of the given |
| 1773 // capacity. Update the length for JSArrays. Returns the new backing | 1699 // capacity. Update the length for JSArrays. Returns the new backing |
| 1774 // store. | 1700 // store. |
| 1775 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity, | 1701 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength( |
| 1776 int length); | 1702 int capacity, |
| 1703 int length, |
| 1704 SetFastElementsCapacityMode set_capacity_mode); |
| 1777 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( | 1705 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
| 1778 int capacity, | 1706 int capacity, |
| 1779 int length); | 1707 int length); |
| 1780 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length); | 1708 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length); |
| 1781 | 1709 |
| 1782 // Lookup interceptors are used for handling properties controlled by host | 1710 // Lookup interceptors are used for handling properties controlled by host |
| 1783 // objects. | 1711 // objects. |
| 1784 inline bool HasNamedInterceptor(); | 1712 inline bool HasNamedInterceptor(); |
| 1785 inline bool HasIndexedInterceptor(); | 1713 inline bool HasIndexedInterceptor(); |
| 1786 | 1714 |
| 1787 // Support functions for v8 api (needed for correct interceptor behavior). | 1715 // Support functions for v8 api (needed for correct interceptor behavior). |
| 1788 bool HasRealNamedProperty(String* key); | 1716 bool HasRealNamedProperty(String* key); |
| 1789 bool HasRealElementProperty(uint32_t index); | 1717 bool HasRealElementProperty(uint32_t index); |
| 1790 bool HasRealNamedCallbackProperty(String* key); | 1718 bool HasRealNamedCallbackProperty(String* key); |
| 1791 | 1719 |
| 1792 // Initializes the array to a certain length | 1720 // Initializes the array to a certain length |
| 1793 MUST_USE_RESULT MaybeObject* SetElementsLength(Object* length); | 1721 MUST_USE_RESULT MaybeObject* SetElementsLength(Object* length); |
| 1794 | 1722 |
| 1795 // Get the header size for a JSObject. Used to compute the index of | 1723 // Get the header size for a JSObject. Used to compute the index of |
| 1796 // internal fields as well as the number of internal fields. | 1724 // internal fields as well as the number of internal fields. |
| 1797 inline int GetHeaderSize(); | 1725 inline int GetHeaderSize(); |
| 1798 | 1726 |
| 1799 inline int GetInternalFieldCount(); | 1727 inline int GetInternalFieldCount(); |
| 1800 inline int GetInternalFieldOffset(int index); | 1728 inline int GetInternalFieldOffset(int index); |
| 1801 inline Object* GetInternalField(int index); | 1729 inline Object* GetInternalField(int index); |
| 1802 inline void SetInternalField(int index, Object* value); | 1730 inline void SetInternalField(int index, Object* value); |
| 1803 | 1731 |
| 1804 // Lookup a property. If found, the result is valid and has | |
| 1805 // detailed information. | |
| 1806 void LocalLookup(String* name, LookupResult* result); | |
| 1807 | |
| 1808 // The following lookup functions skip interceptors. | 1732 // The following lookup functions skip interceptors. |
| 1809 void LocalLookupRealNamedProperty(String* name, LookupResult* result); | 1733 void LocalLookupRealNamedProperty(String* name, LookupResult* result); |
| 1810 void LookupRealNamedProperty(String* name, LookupResult* result); | 1734 void LookupRealNamedProperty(String* name, LookupResult* result); |
| 1811 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); | 1735 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); |
| 1812 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); | 1736 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); |
| 1813 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( | 1737 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( |
| 1814 uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode); | 1738 uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode); |
| 1815 void LookupCallback(String* name, LookupResult* result); | 1739 void LookupCallback(String* name, LookupResult* result); |
| 1816 | 1740 |
| 1817 // Returns the number of properties on this object filtering out properties | 1741 // Returns the number of properties on this object filtering out properties |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty( | 1777 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty( |
| 1854 String* name, | 1778 String* name, |
| 1855 JSFunction* function, | 1779 JSFunction* function, |
| 1856 PropertyAttributes attributes); | 1780 PropertyAttributes attributes); |
| 1857 | 1781 |
| 1858 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( | 1782 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( |
| 1859 String* name, | 1783 String* name, |
| 1860 Object* value, | 1784 Object* value, |
| 1861 PropertyAttributes attributes); | 1785 PropertyAttributes attributes); |
| 1862 | 1786 |
| 1787 // Returns a new map with all transitions dropped from the object's current |
| 1788 // map and the ElementsKind set. |
| 1789 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( |
| 1790 ElementsKind elements_kind); |
| 1791 |
| 1863 // Converts a descriptor of any other type to a real field, | 1792 // Converts a descriptor of any other type to a real field, |
| 1864 // backed by the properties array. Descriptors of visible | 1793 // backed by the properties array. Descriptors of visible |
| 1865 // types, such as CONSTANT_FUNCTION, keep their enumeration order. | 1794 // types, such as CONSTANT_FUNCTION, keep their enumeration order. |
| 1866 // Converts the descriptor on the original object's map to a | 1795 // Converts the descriptor on the original object's map to a |
| 1867 // map transition, and the the new field is on the object's new map. | 1796 // map transition, and the the new field is on the object's new map. |
| 1868 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition( | 1797 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition( |
| 1869 String* name, | 1798 String* name, |
| 1870 Object* new_value, | 1799 Object* new_value, |
| 1871 PropertyAttributes attributes); | 1800 PropertyAttributes attributes); |
| 1872 | 1801 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 inline Object* FastPropertyAtPut(int index, Object* value); | 1847 inline Object* FastPropertyAtPut(int index, Object* value); |
| 1919 | 1848 |
| 1920 // Access to in object properties. | 1849 // Access to in object properties. |
| 1921 inline int GetInObjectPropertyOffset(int index); | 1850 inline int GetInObjectPropertyOffset(int index); |
| 1922 inline Object* InObjectPropertyAt(int index); | 1851 inline Object* InObjectPropertyAt(int index); |
| 1923 inline Object* InObjectPropertyAtPut(int index, | 1852 inline Object* InObjectPropertyAtPut(int index, |
| 1924 Object* value, | 1853 Object* value, |
| 1925 WriteBarrierMode mode | 1854 WriteBarrierMode mode |
| 1926 = UPDATE_WRITE_BARRIER); | 1855 = UPDATE_WRITE_BARRIER); |
| 1927 | 1856 |
| 1928 // initializes the body after properties slot, properties slot is | 1857 // Initializes the body after properties slot, properties slot is |
| 1929 // initialized by set_properties | 1858 // initialized by set_properties. Fill the pre-allocated fields with |
| 1930 // Note: this call does not update write barrier, it is caller's | 1859 // pre_allocated_value and the rest with filler_value. |
| 1931 // reponsibility to ensure that *v* can be collected without WB here. | 1860 // Note: this call does not update write barrier, the caller is responsible |
| 1932 inline void InitializeBody(int object_size, Object* value); | 1861 // to ensure that |filler_value| can be collected without WB here. |
| 1862 inline void InitializeBody(Map* map, |
| 1863 Object* pre_allocated_value, |
| 1864 Object* filler_value); |
| 1933 | 1865 |
| 1934 // Check whether this object references another object | 1866 // Check whether this object references another object |
| 1935 bool ReferencesObject(Object* obj); | 1867 bool ReferencesObject(Object* obj); |
| 1936 | 1868 |
| 1937 // Casting. | 1869 // Casting. |
| 1938 static inline JSObject* cast(Object* obj); | 1870 static inline JSObject* cast(Object* obj); |
| 1939 | 1871 |
| 1940 // Disalow further properties to be added to the object. | 1872 // Disalow further properties to be added to the object. |
| 1941 MUST_USE_RESULT MaybeObject* PreventExtensions(); | 1873 MUST_USE_RESULT MaybeObject* PreventExtensions(); |
| 1942 | 1874 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 uint32_t index, | 1979 uint32_t index, |
| 2048 Object* value, | 1980 Object* value, |
| 2049 StrictModeFlag strict_mode, | 1981 StrictModeFlag strict_mode, |
| 2050 bool check_prototype); | 1982 bool check_prototype); |
| 2051 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor( | 1983 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor( |
| 2052 uint32_t index, | 1984 uint32_t index, |
| 2053 Object* value, | 1985 Object* value, |
| 2054 StrictModeFlag strict_mode, | 1986 StrictModeFlag strict_mode, |
| 2055 bool check_prototype); | 1987 bool check_prototype); |
| 2056 | 1988 |
| 1989 // Searches the prototype chain for a callback setter and sets the property |
| 1990 // with the setter if it finds one. The '*found' flag indicates whether |
| 1991 // a setter was found or not. |
| 1992 // This function can cause GC and can return a failure result with |
| 1993 // '*found==true'. |
| 1994 MUST_USE_RESULT MaybeObject* SetPropertyWithCallbackSetterInPrototypes( |
| 1995 String* name, |
| 1996 Object* value, |
| 1997 PropertyAttributes attributes, |
| 1998 bool* found, |
| 1999 StrictModeFlag strict_mode); |
| 2000 |
| 2057 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, | 2001 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, |
| 2058 DeleteMode mode); | 2002 DeleteMode mode); |
| 2059 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); | 2003 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); |
| 2060 | 2004 |
| 2061 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); | 2005 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); |
| 2062 | 2006 |
| 2063 MUST_USE_RESULT MaybeObject* DeleteFastElement(uint32_t index); | 2007 MUST_USE_RESULT MaybeObject* DeleteFastElement(uint32_t index); |
| 2064 MUST_USE_RESULT MaybeObject* DeleteDictionaryElement(uint32_t index, | 2008 MUST_USE_RESULT MaybeObject* DeleteDictionaryElement(uint32_t index, |
| 2065 DeleteMode mode); | 2009 DeleteMode mode); |
| 2066 | 2010 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2085 MUST_USE_RESULT MaybeObject* SetPropertyCallback( | 2029 MUST_USE_RESULT MaybeObject* SetPropertyCallback( |
| 2086 String* name, | 2030 String* name, |
| 2087 Object* structure, | 2031 Object* structure, |
| 2088 PropertyAttributes attributes); | 2032 PropertyAttributes attributes); |
| 2089 MUST_USE_RESULT MaybeObject* DefineGetterSetter( | 2033 MUST_USE_RESULT MaybeObject* DefineGetterSetter( |
| 2090 String* name, | 2034 String* name, |
| 2091 PropertyAttributes attributes); | 2035 PropertyAttributes attributes); |
| 2092 | 2036 |
| 2093 void LookupInDescriptor(String* name, LookupResult* result); | 2037 void LookupInDescriptor(String* name, LookupResult* result); |
| 2094 | 2038 |
| 2039 // Returns the hidden properties backing store object, currently |
| 2040 // a StringDictionary, stored on this object. |
| 2041 // If no hidden properties object has been put on this object, |
| 2042 // return undefined, unless create_if_absent is true, in which case |
| 2043 // a new dictionary is created, added to this object, and returned. |
| 2044 MaybeObject* GetHiddenPropertiesDictionary(bool create_if_absent); |
| 2045 // Updates the existing hidden properties dictionary. |
| 2046 MaybeObject* SetHiddenPropertiesDictionary(StringDictionary* dictionary); |
| 2047 |
| 2095 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); | 2048 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); |
| 2096 }; | 2049 }; |
| 2097 | 2050 |
| 2098 | 2051 |
| 2099 // Common superclass for FixedArrays that allow implementations to share | 2052 // Common superclass for FixedArrays that allow implementations to share |
| 2100 // common accessors and some code paths. | 2053 // common accessors and some code paths. |
| 2101 class FixedArrayBase: public HeapObject { | 2054 class FixedArrayBase: public HeapObject { |
| 2102 public: | 2055 public: |
| 2103 // [length]: length of the array. | 2056 // [length]: length of the array. |
| 2104 inline int length(); | 2057 inline int length(); |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 } | 2863 } |
| 2911 | 2864 |
| 2912 // Copies enumerable keys to preallocated fixed array. | 2865 // Copies enumerable keys to preallocated fixed array. |
| 2913 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); | 2866 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); |
| 2914 | 2867 |
| 2915 // For transforming properties of a JSObject. | 2868 // For transforming properties of a JSObject. |
| 2916 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( | 2869 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( |
| 2917 JSObject* obj, | 2870 JSObject* obj, |
| 2918 int unused_property_fields); | 2871 int unused_property_fields); |
| 2919 | 2872 |
| 2920 // Find entry for key otherwise return kNotFound. Optimzed version of | 2873 // Find entry for key, otherwise return kNotFound. Optimized version of |
| 2921 // HashTable::FindEntry. | 2874 // HashTable::FindEntry. |
| 2922 int FindEntry(String* key); | 2875 int FindEntry(String* key); |
| 2923 }; | 2876 }; |
| 2924 | 2877 |
| 2925 | 2878 |
| 2926 class NumberDictionaryShape { | 2879 class NumberDictionaryShape { |
| 2927 public: | 2880 public: |
| 2928 static inline bool IsMatch(uint32_t key, Object* other); | 2881 static inline bool IsMatch(uint32_t key, Object* other); |
| 2929 static inline uint32_t Hash(uint32_t key); | 2882 static inline uint32_t Hash(uint32_t key); |
| 2930 static inline uint32_t HashForObject(uint32_t key, Object* object); | 2883 static inline uint32_t HashForObject(uint32_t key, Object* object); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2973 | 2926 |
| 2974 // Bit masks. | 2927 // Bit masks. |
| 2975 static const int kRequiresSlowElementsMask = 1; | 2928 static const int kRequiresSlowElementsMask = 1; |
| 2976 static const int kRequiresSlowElementsTagSize = 1; | 2929 static const int kRequiresSlowElementsTagSize = 1; |
| 2977 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; | 2930 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; |
| 2978 }; | 2931 }; |
| 2979 | 2932 |
| 2980 | 2933 |
| 2981 class ObjectHashTableShape { | 2934 class ObjectHashTableShape { |
| 2982 public: | 2935 public: |
| 2983 static inline bool IsMatch(JSObject* key, Object* other); | 2936 static inline bool IsMatch(JSReceiver* key, Object* other); |
| 2984 static inline uint32_t Hash(JSObject* key); | 2937 static inline uint32_t Hash(JSReceiver* key); |
| 2985 static inline uint32_t HashForObject(JSObject* key, Object* object); | 2938 static inline uint32_t HashForObject(JSReceiver* key, Object* object); |
| 2986 MUST_USE_RESULT static inline MaybeObject* AsObject(JSObject* key); | 2939 MUST_USE_RESULT static inline MaybeObject* AsObject(JSReceiver* key); |
| 2987 static const int kPrefixSize = 0; | 2940 static const int kPrefixSize = 0; |
| 2988 static const int kEntrySize = 2; | 2941 static const int kEntrySize = 2; |
| 2989 }; | 2942 }; |
| 2990 | 2943 |
| 2991 | 2944 |
| 2992 // ObjectHashTable maps keys that are JavaScript objects to object values by | 2945 // ObjectHashTable maps keys that are JavaScript objects to object values by |
| 2993 // using the identity hash of the key for hashing purposes. | 2946 // using the identity hash of the key for hashing purposes. |
| 2994 class ObjectHashTable: public HashTable<ObjectHashTableShape, JSObject*> { | 2947 class ObjectHashTable: public HashTable<ObjectHashTableShape, JSReceiver*> { |
| 2995 public: | 2948 public: |
| 2996 static inline ObjectHashTable* cast(Object* obj) { | 2949 static inline ObjectHashTable* cast(Object* obj) { |
| 2997 ASSERT(obj->IsHashTable()); | 2950 ASSERT(obj->IsHashTable()); |
| 2998 return reinterpret_cast<ObjectHashTable*>(obj); | 2951 return reinterpret_cast<ObjectHashTable*>(obj); |
| 2999 } | 2952 } |
| 3000 | 2953 |
| 3001 // Looks up the value associated with the given key. The undefined value is | 2954 // Looks up the value associated with the given key. The undefined value is |
| 3002 // returned in case the key is not present. | 2955 // returned in case the key is not present. |
| 3003 Object* Lookup(JSObject* key); | 2956 Object* Lookup(JSReceiver* key); |
| 3004 | 2957 |
| 3005 // Adds (or overwrites) the value associated with the given key. Mapping a | 2958 // Adds (or overwrites) the value associated with the given key. Mapping a |
| 3006 // key to the undefined value causes removal of the whole entry. | 2959 // key to the undefined value causes removal of the whole entry. |
| 3007 MUST_USE_RESULT MaybeObject* Put(JSObject* key, Object* value); | 2960 MUST_USE_RESULT MaybeObject* Put(JSReceiver* key, Object* value); |
| 3008 | 2961 |
| 3009 private: | 2962 private: |
| 3010 friend class MarkCompactCollector; | 2963 friend class MarkCompactCollector; |
| 3011 | 2964 |
| 3012 void AddEntry(int entry, JSObject* key, Object* value); | 2965 void AddEntry(int entry, JSReceiver* key, Object* value); |
| 3013 void RemoveEntry(int entry, Heap* heap); | 2966 void RemoveEntry(int entry, Heap* heap); |
| 3014 inline void RemoveEntry(int entry); | 2967 inline void RemoveEntry(int entry); |
| 3015 | 2968 |
| 3016 // Returns the index to the value of an entry. | 2969 // Returns the index to the value of an entry. |
| 3017 static inline int EntryToValueIndex(int entry) { | 2970 static inline int EntryToValueIndex(int entry) { |
| 3018 return EntryToIndex(entry) + 1; | 2971 return EntryToIndex(entry) + 1; |
| 3019 } | 2972 } |
| 3020 }; | 2973 }; |
| 3021 | 2974 |
| 3022 | 2975 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3072 | 3025 |
| 3073 // Casting | 3026 // Casting |
| 3074 static inline NormalizedMapCache* cast(Object* obj); | 3027 static inline NormalizedMapCache* cast(Object* obj); |
| 3075 | 3028 |
| 3076 #ifdef DEBUG | 3029 #ifdef DEBUG |
| 3077 void NormalizedMapCacheVerify(); | 3030 void NormalizedMapCacheVerify(); |
| 3078 #endif | 3031 #endif |
| 3079 }; | 3032 }; |
| 3080 | 3033 |
| 3081 | 3034 |
| 3082 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 3035 // ByteArray represents fixed sized byte arrays. Used for the relocation info |
| 3083 // such as PCRE, and also by the memory allocator and garbage collector to | 3036 // that is attached to code objects. |
| 3084 // fill in free blocks in the heap. | |
| 3085 class ByteArray: public FixedArrayBase { | 3037 class ByteArray: public FixedArrayBase { |
| 3086 public: | 3038 public: |
| 3039 inline int Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } |
| 3040 |
| 3087 // Setter and getter. | 3041 // Setter and getter. |
| 3088 inline byte get(int index); | 3042 inline byte get(int index); |
| 3089 inline void set(int index, byte value); | 3043 inline void set(int index, byte value); |
| 3090 | 3044 |
| 3091 // Treat contents as an int array. | 3045 // Treat contents as an int array. |
| 3092 inline int get_int(int index); | 3046 inline int get_int(int index); |
| 3093 | 3047 |
| 3094 static int SizeFor(int length) { | 3048 static int SizeFor(int length) { |
| 3095 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 3049 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
| 3096 } | 3050 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 // Maximal memory consumption for a single ByteArray. | 3087 // Maximal memory consumption for a single ByteArray. |
| 3134 static const int kMaxSize = 512 * MB; | 3088 static const int kMaxSize = 512 * MB; |
| 3135 // Maximal length of a single ByteArray. | 3089 // Maximal length of a single ByteArray. |
| 3136 static const int kMaxLength = kMaxSize - kHeaderSize; | 3090 static const int kMaxLength = kMaxSize - kHeaderSize; |
| 3137 | 3091 |
| 3138 private: | 3092 private: |
| 3139 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 3093 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
| 3140 }; | 3094 }; |
| 3141 | 3095 |
| 3142 | 3096 |
| 3097 // FreeSpace represents fixed sized areas of the heap that are not currently in |
| 3098 // use. Used by the heap and GC. |
| 3099 class FreeSpace: public HeapObject { |
| 3100 public: |
| 3101 // [size]: size of the free space including the header. |
| 3102 inline int size(); |
| 3103 inline void set_size(int value); |
| 3104 |
| 3105 inline int Size() { return size(); } |
| 3106 |
| 3107 // Casting. |
| 3108 static inline FreeSpace* cast(Object* obj); |
| 3109 |
| 3110 #ifdef OBJECT_PRINT |
| 3111 inline void FreeSpacePrint() { |
| 3112 FreeSpacePrint(stdout); |
| 3113 } |
| 3114 void FreeSpacePrint(FILE* out); |
| 3115 #endif |
| 3116 #ifdef DEBUG |
| 3117 void FreeSpaceVerify(); |
| 3118 #endif |
| 3119 |
| 3120 // Layout description. |
| 3121 // Size is smi tagged when it is stored. |
| 3122 static const int kSizeOffset = HeapObject::kHeaderSize; |
| 3123 static const int kHeaderSize = kSizeOffset + kPointerSize; |
| 3124 |
| 3125 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
| 3126 |
| 3127 // Maximal size of a single FreeSpace. |
| 3128 static const int kMaxSize = 512 * MB; |
| 3129 |
| 3130 private: |
| 3131 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeSpace); |
| 3132 }; |
| 3133 |
| 3134 |
| 3143 // An ExternalArray represents a fixed-size array of primitive values | 3135 // An ExternalArray represents a fixed-size array of primitive values |
| 3144 // which live outside the JavaScript heap. Its subclasses are used to | 3136 // which live outside the JavaScript heap. Its subclasses are used to |
| 3145 // implement the CanvasArray types being defined in the WebGL | 3137 // implement the CanvasArray types being defined in the WebGL |
| 3146 // specification. As of this writing the first public draft is not yet | 3138 // specification. As of this writing the first public draft is not yet |
| 3147 // available, but Khronos members can access the draft at: | 3139 // available, but Khronos members can access the draft at: |
| 3148 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 3140 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
| 3149 // | 3141 // |
| 3150 // The semantics of these arrays differ from CanvasPixelArray. | 3142 // The semantics of these arrays differ from CanvasPixelArray. |
| 3151 // Out-of-range values passed to the setter are converted via a C | 3143 // Out-of-range values passed to the setter are converted via a C |
| 3152 // cast, not clamping. Out-of-range indices cause exceptions to be | 3144 // cast, not clamping. Out-of-range indices cause exceptions to be |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3666 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } | 3658 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } |
| 3667 inline bool is_unary_op_stub() { return kind() == UNARY_OP_IC; } | 3659 inline bool is_unary_op_stub() { return kind() == UNARY_OP_IC; } |
| 3668 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } | 3660 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } |
| 3669 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } | 3661 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } |
| 3670 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } | 3662 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } |
| 3671 | 3663 |
| 3672 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. | 3664 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. |
| 3673 inline int major_key(); | 3665 inline int major_key(); |
| 3674 inline void set_major_key(int value); | 3666 inline void set_major_key(int value); |
| 3675 | 3667 |
| 3668 // For stubs, tells whether they should always exist, so that they can be |
| 3669 // called from other stubs. |
| 3670 inline bool is_pregenerated(); |
| 3671 inline void set_is_pregenerated(bool value); |
| 3672 |
| 3676 // [optimizable]: For FUNCTION kind, tells if it is optimizable. | 3673 // [optimizable]: For FUNCTION kind, tells if it is optimizable. |
| 3677 inline bool optimizable(); | 3674 inline bool optimizable(); |
| 3678 inline void set_optimizable(bool value); | 3675 inline void set_optimizable(bool value); |
| 3679 | 3676 |
| 3680 // [has_deoptimization_support]: For FUNCTION kind, tells if it has | 3677 // [has_deoptimization_support]: For FUNCTION kind, tells if it has |
| 3681 // deoptimization support. | 3678 // deoptimization support. |
| 3682 inline bool has_deoptimization_support(); | 3679 inline bool has_deoptimization_support(); |
| 3683 inline void set_has_deoptimization_support(bool value); | 3680 inline void set_has_deoptimization_support(bool value); |
| 3684 | 3681 |
| 3685 // [has_debug_break_slots]: For FUNCTION kind, tells if it has | 3682 // [has_debug_break_slots]: For FUNCTION kind, tells if it has |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3725 inline void set_binary_op_result_type(byte value); | 3722 inline void set_binary_op_result_type(byte value); |
| 3726 | 3723 |
| 3727 // [compare state]: For kind COMPARE_IC, tells what state the stub is in. | 3724 // [compare state]: For kind COMPARE_IC, tells what state the stub is in. |
| 3728 inline byte compare_state(); | 3725 inline byte compare_state(); |
| 3729 inline void set_compare_state(byte value); | 3726 inline void set_compare_state(byte value); |
| 3730 | 3727 |
| 3731 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. | 3728 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. |
| 3732 inline byte to_boolean_state(); | 3729 inline byte to_boolean_state(); |
| 3733 inline void set_to_boolean_state(byte value); | 3730 inline void set_to_boolean_state(byte value); |
| 3734 | 3731 |
| 3732 // For kind STUB, major_key == CallFunction, tells whether there is |
| 3733 // a function cache in the instruction stream. |
| 3734 inline bool has_function_cache(); |
| 3735 inline void set_has_function_cache(bool flag); |
| 3736 |
| 3735 // Get the safepoint entry for the given pc. | 3737 // Get the safepoint entry for the given pc. |
| 3736 SafepointEntry GetSafepointEntry(Address pc); | 3738 SafepointEntry GetSafepointEntry(Address pc); |
| 3737 | 3739 |
| 3738 // Mark this code object as not having a stack check table. Assumes kind | 3740 // Mark this code object as not having a stack check table. Assumes kind |
| 3739 // is FUNCTION. | 3741 // is FUNCTION. |
| 3740 void SetNoStackCheckTable(); | 3742 void SetNoStackCheckTable(); |
| 3741 | 3743 |
| 3742 // Find the first map in an IC stub. | 3744 // Find the first map in an IC stub. |
| 3743 Map* FindFirstMap(); | 3745 Map* FindFirstMap(); |
| 3744 | 3746 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3829 #ifdef OBJECT_PRINT | 3831 #ifdef OBJECT_PRINT |
| 3830 inline void CodePrint() { | 3832 inline void CodePrint() { |
| 3831 CodePrint(stdout); | 3833 CodePrint(stdout); |
| 3832 } | 3834 } |
| 3833 void CodePrint(FILE* out); | 3835 void CodePrint(FILE* out); |
| 3834 #endif | 3836 #endif |
| 3835 #ifdef DEBUG | 3837 #ifdef DEBUG |
| 3836 void CodeVerify(); | 3838 void CodeVerify(); |
| 3837 #endif | 3839 #endif |
| 3838 | 3840 |
| 3839 // Returns the isolate/heap this code object belongs to. | |
| 3840 inline Isolate* isolate(); | |
| 3841 inline Heap* heap(); | |
| 3842 | |
| 3843 // Max loop nesting marker used to postpose OSR. We don't take loop | 3841 // Max loop nesting marker used to postpose OSR. We don't take loop |
| 3844 // nesting that is deeper than 5 levels into account. | 3842 // nesting that is deeper than 5 levels into account. |
| 3845 static const int kMaxLoopNestingMarker = 6; | 3843 static const int kMaxLoopNestingMarker = 6; |
| 3846 | 3844 |
| 3847 // Layout description. | 3845 // Layout description. |
| 3848 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; | 3846 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
| 3849 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; | 3847 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; |
| 3850 static const int kDeoptimizationDataOffset = | 3848 static const int kDeoptimizationDataOffset = |
| 3851 kRelocationInfoOffset + kPointerSize; | 3849 kRelocationInfoOffset + kPointerSize; |
| 3852 static const int kNextCodeFlushingCandidateOffset = | 3850 static const int kNextCodeFlushingCandidateOffset = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3868 // Byte offsets within kKindSpecificFlagsOffset. | 3866 // Byte offsets within kKindSpecificFlagsOffset. |
| 3869 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset; | 3867 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset; |
| 3870 static const int kOptimizableOffset = kKindSpecificFlagsOffset; | 3868 static const int kOptimizableOffset = kKindSpecificFlagsOffset; |
| 3871 static const int kStackSlotsOffset = kKindSpecificFlagsOffset; | 3869 static const int kStackSlotsOffset = kKindSpecificFlagsOffset; |
| 3872 static const int kCheckTypeOffset = kKindSpecificFlagsOffset; | 3870 static const int kCheckTypeOffset = kKindSpecificFlagsOffset; |
| 3873 | 3871 |
| 3874 static const int kUnaryOpTypeOffset = kStubMajorKeyOffset + 1; | 3872 static const int kUnaryOpTypeOffset = kStubMajorKeyOffset + 1; |
| 3875 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; | 3873 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; |
| 3876 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; | 3874 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; |
| 3877 static const int kToBooleanTypeOffset = kStubMajorKeyOffset + 1; | 3875 static const int kToBooleanTypeOffset = kStubMajorKeyOffset + 1; |
| 3876 static const int kHasFunctionCacheOffset = kStubMajorKeyOffset + 1; |
| 3878 | 3877 |
| 3879 static const int kFullCodeFlags = kOptimizableOffset + 1; | 3878 static const int kFullCodeFlags = kOptimizableOffset + 1; |
| 3880 class FullCodeFlagsHasDeoptimizationSupportField: | 3879 class FullCodeFlagsHasDeoptimizationSupportField: |
| 3881 public BitField<bool, 0, 1> {}; // NOLINT | 3880 public BitField<bool, 0, 1> {}; // NOLINT |
| 3882 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {}; | 3881 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {}; |
| 3883 | 3882 |
| 3884 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; | 3883 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; |
| 3885 | 3884 |
| 3886 static const int kAllowOSRAtLoopNestingLevelOffset = kFullCodeFlags + 1; | 3885 static const int kAllowOSRAtLoopNestingLevelOffset = kFullCodeFlags + 1; |
| 3887 | 3886 |
| 3888 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; | 3887 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; |
| 3889 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize; | 3888 static const int kStackCheckTableOffsetOffset = kStackSlotsOffset + kIntSize; |
| 3890 | 3889 |
| 3891 // Flags layout. BitField<type, shift, size>. | 3890 // Flags layout. BitField<type, shift, size>. |
| 3892 class ICStateField: public BitField<InlineCacheState, 0, 3> {}; | 3891 class ICStateField: public BitField<InlineCacheState, 0, 3> {}; |
| 3893 class TypeField: public BitField<PropertyType, 3, 4> {}; | 3892 class TypeField: public BitField<PropertyType, 3, 4> {}; |
| 3894 class KindField: public BitField<Kind, 7, 4> {}; | 3893 class KindField: public BitField<Kind, 7, 4> {}; |
| 3895 class CacheHolderField: public BitField<InlineCacheHolderFlag, 11, 1> {}; | 3894 class CacheHolderField: public BitField<InlineCacheHolderFlag, 11, 1> {}; |
| 3896 class ExtraICStateField: public BitField<ExtraICState, 12, 2> {}; | 3895 class ExtraICStateField: public BitField<ExtraICState, 12, 2> {}; |
| 3896 class IsPregeneratedField: public BitField<bool, 14, 1> {}; |
| 3897 | 3897 |
| 3898 // Signed field cannot be encoded using the BitField class. | 3898 // Signed field cannot be encoded using the BitField class. |
| 3899 static const int kArgumentsCountShift = 14; | 3899 static const int kArgumentsCountShift = 15; |
| 3900 static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1); | 3900 static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1); |
| 3901 | 3901 |
| 3902 static const int kFlagsNotUsedInLookup = | 3902 static const int kFlagsNotUsedInLookup = |
| 3903 TypeField::kMask | CacheHolderField::kMask; | 3903 TypeField::kMask | CacheHolderField::kMask; |
| 3904 | 3904 |
| 3905 private: | 3905 private: |
| 3906 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 3906 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
| 3907 }; | 3907 }; |
| 3908 | 3908 |
| 3909 | 3909 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4025 set_bit_field2((bit_field2() & ~kElementsKindMask) | | 4025 set_bit_field2((bit_field2() & ~kElementsKindMask) | |
| 4026 (elements_kind << kElementsKindShift)); | 4026 (elements_kind << kElementsKindShift)); |
| 4027 ASSERT(this->elements_kind() == elements_kind); | 4027 ASSERT(this->elements_kind() == elements_kind); |
| 4028 } | 4028 } |
| 4029 | 4029 |
| 4030 inline ElementsKind elements_kind() { | 4030 inline ElementsKind elements_kind() { |
| 4031 return static_cast<ElementsKind>( | 4031 return static_cast<ElementsKind>( |
| 4032 (bit_field2() & kElementsKindMask) >> kElementsKindShift); | 4032 (bit_field2() & kElementsKindMask) >> kElementsKindShift); |
| 4033 } | 4033 } |
| 4034 | 4034 |
| 4035 // Tells whether the instance has fast elements that are only Smis. |
| 4036 inline bool has_fast_smi_only_elements() { |
| 4037 return elements_kind() == FAST_SMI_ONLY_ELEMENTS; |
| 4038 } |
| 4039 |
| 4035 // Tells whether the instance has fast elements. | 4040 // Tells whether the instance has fast elements. |
| 4036 // Equivalent to instance->GetElementsKind() == FAST_ELEMENTS. | |
| 4037 inline bool has_fast_elements() { | 4041 inline bool has_fast_elements() { |
| 4038 return elements_kind() == FAST_ELEMENTS; | 4042 return elements_kind() == FAST_ELEMENTS; |
| 4039 } | 4043 } |
| 4040 | 4044 |
| 4041 inline bool has_fast_double_elements() { | 4045 inline bool has_fast_double_elements() { |
| 4042 return elements_kind() == FAST_DOUBLE_ELEMENTS; | 4046 return elements_kind() == FAST_DOUBLE_ELEMENTS; |
| 4043 } | 4047 } |
| 4044 | 4048 |
| 4049 inline bool has_non_strict_arguments_elements() { |
| 4050 return elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS; |
| 4051 } |
| 4052 |
| 4045 inline bool has_external_array_elements() { | 4053 inline bool has_external_array_elements() { |
| 4046 ElementsKind kind(elements_kind()); | 4054 ElementsKind kind(elements_kind()); |
| 4047 return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && | 4055 return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && |
| 4048 kind <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; | 4056 kind <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; |
| 4049 } | 4057 } |
| 4050 | 4058 |
| 4051 inline bool has_dictionary_elements() { | 4059 inline bool has_dictionary_elements() { |
| 4052 return elements_kind() == DICTIONARY_ELEMENTS; | 4060 return elements_kind() == DICTIONARY_ELEMENTS; |
| 4053 } | 4061 } |
| 4054 | 4062 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 DECL_ACCESSORS(code_cache, Object) | 4101 DECL_ACCESSORS(code_cache, Object) |
| 4094 | 4102 |
| 4095 // [prototype transitions]: cache of prototype transitions. | 4103 // [prototype transitions]: cache of prototype transitions. |
| 4096 // Prototype transition is a transition that happens | 4104 // Prototype transition is a transition that happens |
| 4097 // when we change object's prototype to a new one. | 4105 // when we change object's prototype to a new one. |
| 4098 // Cache format: | 4106 // Cache format: |
| 4099 // 0: finger - index of the first free cell in the cache | 4107 // 0: finger - index of the first free cell in the cache |
| 4100 // 1 + 2 * i: prototype | 4108 // 1 + 2 * i: prototype |
| 4101 // 2 + 2 * i: target map | 4109 // 2 + 2 * i: target map |
| 4102 DECL_ACCESSORS(prototype_transitions, FixedArray) | 4110 DECL_ACCESSORS(prototype_transitions, FixedArray) |
| 4111 |
| 4103 inline FixedArray* unchecked_prototype_transitions(); | 4112 inline FixedArray* unchecked_prototype_transitions(); |
| 4104 | 4113 |
| 4105 static const int kProtoTransitionHeaderSize = 1; | 4114 static const int kProtoTransitionHeaderSize = 1; |
| 4106 static const int kProtoTransitionNumberOfEntriesOffset = 0; | 4115 static const int kProtoTransitionNumberOfEntriesOffset = 0; |
| 4107 static const int kProtoTransitionElementsPerEntry = 2; | 4116 static const int kProtoTransitionElementsPerEntry = 2; |
| 4108 static const int kProtoTransitionPrototypeOffset = 0; | 4117 static const int kProtoTransitionPrototypeOffset = 0; |
| 4109 static const int kProtoTransitionMapOffset = 1; | 4118 static const int kProtoTransitionMapOffset = 1; |
| 4110 | 4119 |
| 4111 inline int NumberOfProtoTransitions() { | 4120 inline int NumberOfProtoTransitions() { |
| 4112 FixedArray* cache = unchecked_prototype_transitions(); | 4121 FixedArray* cache = prototype_transitions(); |
| 4113 if (cache->length() == 0) return 0; | 4122 if (cache->length() == 0) return 0; |
| 4114 return | 4123 return |
| 4115 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value(); | 4124 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value(); |
| 4116 } | 4125 } |
| 4117 | 4126 |
| 4118 inline void SetNumberOfProtoTransitions(int value) { | 4127 inline void SetNumberOfProtoTransitions(int value) { |
| 4119 FixedArray* cache = unchecked_prototype_transitions(); | 4128 FixedArray* cache = prototype_transitions(); |
| 4120 ASSERT(cache->length() != 0); | 4129 ASSERT(cache->length() != 0); |
| 4121 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, | 4130 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, |
| 4122 Smi::FromInt(value)); | 4131 Smi::FromInt(value)); |
| 4123 } | 4132 } |
| 4124 | 4133 |
| 4125 // Lookup in the map's instance descriptors and fill out the result | 4134 // Lookup in the map's instance descriptors and fill out the result |
| 4126 // with the given holder if the name is found. The holder may be | 4135 // with the given holder if the name is found. The holder may be |
| 4127 // NULL when this function is used from the compiler. | 4136 // NULL when this function is used from the compiler. |
| 4128 void LookupInDescriptors(JSObject* holder, | 4137 void LookupInDescriptors(JSObject* holder, |
| 4129 String* name, | 4138 String* name, |
| 4130 LookupResult* result); | 4139 LookupResult* result); |
| 4131 | 4140 |
| 4132 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); | 4141 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); |
| 4133 | 4142 |
| 4134 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, | 4143 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, |
| 4135 NormalizedMapSharingMode sharing); | 4144 NormalizedMapSharingMode sharing); |
| 4136 | 4145 |
| 4137 // Returns a copy of the map, with all transitions dropped from the | 4146 // Returns a copy of the map, with all transitions dropped from the |
| 4138 // instance descriptors. | 4147 // instance descriptors. |
| 4139 MUST_USE_RESULT MaybeObject* CopyDropTransitions(); | 4148 MUST_USE_RESULT MaybeObject* CopyDropTransitions(); |
| 4140 | 4149 |
| 4141 // Returns this map if it already has elements that are fast, otherwise | |
| 4142 // returns a copy of the map, with all transitions dropped from the | |
| 4143 // descriptors and the ElementsKind set to FAST_ELEMENTS. | |
| 4144 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); | |
| 4145 | |
| 4146 // Returns this map if it already has fast elements that are doubles, | |
| 4147 // otherwise returns a copy of the map, with all transitions dropped from the | |
| 4148 // descriptors and the ElementsKind set to FAST_DOUBLE_ELEMENTS. | |
| 4149 MUST_USE_RESULT inline MaybeObject* GetFastDoubleElementsMap(); | |
| 4150 | |
| 4151 // Returns this map if already has dictionary elements, otherwise returns a | |
| 4152 // copy of the map, with all transitions dropped from the descriptors and the | |
| 4153 // ElementsKind set to DICTIONARY_ELEMENTS. | |
| 4154 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); | |
| 4155 | |
| 4156 // Returns a new map with all transitions dropped from the descriptors and the | |
| 4157 // ElementsKind set. | |
| 4158 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( | |
| 4159 ElementsKind elements_kind, | |
| 4160 bool safe_to_add_transition); | |
| 4161 | |
| 4162 // Returns the property index for name (only valid for FAST MODE). | 4150 // Returns the property index for name (only valid for FAST MODE). |
| 4163 int PropertyIndexFor(String* name); | 4151 int PropertyIndexFor(String* name); |
| 4164 | 4152 |
| 4165 // Returns the next free property index (only valid for FAST MODE). | 4153 // Returns the next free property index (only valid for FAST MODE). |
| 4166 int NextFreePropertyIndex(); | 4154 int NextFreePropertyIndex(); |
| 4167 | 4155 |
| 4168 // Returns the number of properties described in instance_descriptors. | 4156 // Returns the number of properties described in instance_descriptors. |
| 4169 int NumberOfDescribedProperties(); | 4157 int NumberOfDescribedProperties(); |
| 4170 | 4158 |
| 4171 // Casting. | 4159 // Casting. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4190 int IndexInCodeCache(Object* name, Code* code); | 4178 int IndexInCodeCache(Object* name, Code* code); |
| 4191 | 4179 |
| 4192 // Removes a code object from the code cache at the given index. | 4180 // Removes a code object from the code cache at the given index. |
| 4193 void RemoveFromCodeCache(String* name, Code* code, int index); | 4181 void RemoveFromCodeCache(String* name, Code* code, int index); |
| 4194 | 4182 |
| 4195 // For every transition in this map, makes the transition's | 4183 // For every transition in this map, makes the transition's |
| 4196 // target's prototype pointer point back to this map. | 4184 // target's prototype pointer point back to this map. |
| 4197 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). | 4185 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). |
| 4198 void CreateBackPointers(); | 4186 void CreateBackPointers(); |
| 4199 | 4187 |
| 4188 void CreateOneBackPointer(Map* transition_target); |
| 4189 |
| 4200 // Set all map transitions from this map to dead maps to null. | 4190 // Set all map transitions from this map to dead maps to null. |
| 4201 // Also, restore the original prototype on the targets of these | 4191 // Also, restore the original prototype on the targets of these |
| 4202 // transitions, so that we do not process this map again while | 4192 // transitions, so that we do not process this map again while |
| 4203 // following back pointers. | 4193 // following back pointers. |
| 4204 void ClearNonLiveTransitions(Heap* heap, Object* real_prototype); | 4194 void ClearNonLiveTransitions(Heap* heap, Object* real_prototype); |
| 4205 | 4195 |
| 4206 // Computes a hash value for this map, to be used in HashTables and such. | 4196 // Computes a hash value for this map, to be used in HashTables and such. |
| 4207 int Hash(); | 4197 int Hash(); |
| 4208 | 4198 |
| 4209 // Compares this map to another to see if they describe equivalent objects. | 4199 // Compares this map to another to see if they describe equivalent objects. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4226 void MapPrint(FILE* out); | 4216 void MapPrint(FILE* out); |
| 4227 #endif | 4217 #endif |
| 4228 #ifdef DEBUG | 4218 #ifdef DEBUG |
| 4229 void MapVerify(); | 4219 void MapVerify(); |
| 4230 void SharedMapVerify(); | 4220 void SharedMapVerify(); |
| 4231 #endif | 4221 #endif |
| 4232 | 4222 |
| 4233 inline int visitor_id(); | 4223 inline int visitor_id(); |
| 4234 inline void set_visitor_id(int visitor_id); | 4224 inline void set_visitor_id(int visitor_id); |
| 4235 | 4225 |
| 4236 // Returns the isolate/heap this map belongs to. | |
| 4237 inline Isolate* isolate(); | |
| 4238 inline Heap* heap(); | |
| 4239 | |
| 4240 typedef void (*TraverseCallback)(Map* map, void* data); | 4226 typedef void (*TraverseCallback)(Map* map, void* data); |
| 4241 | 4227 |
| 4242 void TraverseTransitionTree(TraverseCallback callback, void* data); | 4228 void TraverseTransitionTree(TraverseCallback callback, void* data); |
| 4243 | 4229 |
| 4244 static const int kMaxCachedPrototypeTransitions = 256; | 4230 static const int kMaxCachedPrototypeTransitions = 256; |
| 4245 | 4231 |
| 4246 Object* GetPrototypeTransition(Object* prototype); | 4232 Object* GetPrototypeTransition(Object* prototype); |
| 4247 | 4233 |
| 4248 MaybeObject* PutPrototypeTransition(Object* prototype, Map* map); | 4234 MaybeObject* PutPrototypeTransition(Object* prototype, Map* map); |
| 4249 | 4235 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4266 static const int kInstanceDescriptorsOrBitField3Offset = | 4252 static const int kInstanceDescriptorsOrBitField3Offset = |
| 4267 kConstructorOffset + kPointerSize; | 4253 kConstructorOffset + kPointerSize; |
| 4268 static const int kCodeCacheOffset = | 4254 static const int kCodeCacheOffset = |
| 4269 kInstanceDescriptorsOrBitField3Offset + kPointerSize; | 4255 kInstanceDescriptorsOrBitField3Offset + kPointerSize; |
| 4270 static const int kPrototypeTransitionsOffset = | 4256 static const int kPrototypeTransitionsOffset = |
| 4271 kCodeCacheOffset + kPointerSize; | 4257 kCodeCacheOffset + kPointerSize; |
| 4272 static const int kPadStart = kPrototypeTransitionsOffset + kPointerSize; | 4258 static const int kPadStart = kPrototypeTransitionsOffset + kPointerSize; |
| 4273 static const int kSize = MAP_POINTER_ALIGN(kPadStart); | 4259 static const int kSize = MAP_POINTER_ALIGN(kPadStart); |
| 4274 | 4260 |
| 4275 // Layout of pointer fields. Heap iteration code relies on them | 4261 // Layout of pointer fields. Heap iteration code relies on them |
| 4276 // being continiously allocated. | 4262 // being continuously allocated. |
| 4277 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 4263 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
| 4278 static const int kPointerFieldsEndOffset = | 4264 static const int kPointerFieldsEndOffset = |
| 4279 Map::kPrototypeTransitionsOffset + kPointerSize; | 4265 Map::kPrototypeTransitionsOffset + kPointerSize; |
| 4280 | 4266 |
| 4281 // Byte offsets within kInstanceSizesOffset. | 4267 // Byte offsets within kInstanceSizesOffset. |
| 4282 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 4268 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 4283 static const int kInObjectPropertiesByte = 1; | 4269 static const int kInObjectPropertiesByte = 1; |
| 4284 static const int kInObjectPropertiesOffset = | 4270 static const int kInObjectPropertiesOffset = |
| 4285 kInstanceSizesOffset + kInObjectPropertiesByte; | 4271 kInstanceSizesOffset + kInObjectPropertiesByte; |
| 4286 static const int kPreAllocatedPropertyFieldsByte = 2; | 4272 static const int kPreAllocatedPropertyFieldsByte = 2; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4306 static const int kIsUndetectable = 5; | 4292 static const int kIsUndetectable = 5; |
| 4307 static const int kHasInstanceCallHandler = 6; | 4293 static const int kHasInstanceCallHandler = 6; |
| 4308 static const int kIsAccessCheckNeeded = 7; | 4294 static const int kIsAccessCheckNeeded = 7; |
| 4309 | 4295 |
| 4310 // Bit positions for bit field 2 | 4296 // Bit positions for bit field 2 |
| 4311 static const int kIsExtensible = 0; | 4297 static const int kIsExtensible = 0; |
| 4312 static const int kFunctionWithPrototype = 1; | 4298 static const int kFunctionWithPrototype = 1; |
| 4313 static const int kStringWrapperSafeForDefaultValueOf = 2; | 4299 static const int kStringWrapperSafeForDefaultValueOf = 2; |
| 4314 static const int kAttachedToSharedFunctionInfo = 3; | 4300 static const int kAttachedToSharedFunctionInfo = 3; |
| 4315 // No bits can be used after kElementsKindFirstBit, they are all reserved for | 4301 // No bits can be used after kElementsKindFirstBit, they are all reserved for |
| 4316 // storing ElementKind. for anything other than storing the ElementKind. | 4302 // storing ElementKind. |
| 4317 static const int kElementsKindShift = 4; | 4303 static const int kElementsKindShift = 4; |
| 4318 static const int kElementsKindBitCount = 4; | 4304 static const int kElementsKindBitCount = 4; |
| 4319 | 4305 |
| 4320 // Derived values from bit field 2 | 4306 // Derived values from bit field 2 |
| 4321 static const int kElementsKindMask = (-1 << kElementsKindShift) & | 4307 static const int kElementsKindMask = (-1 << kElementsKindShift) & |
| 4322 ((1 << (kElementsKindShift + kElementsKindBitCount)) - 1); | 4308 ((1 << (kElementsKindShift + kElementsKindBitCount)) - 1); |
| 4323 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( | 4309 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( |
| 4324 (FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1; | 4310 (FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1; |
| 4311 static const int8_t kMaximumBitField2FastSmiOnlyElementValue = |
| 4312 static_cast<int8_t>((FAST_SMI_ONLY_ELEMENTS + 1) << |
| 4313 Map::kElementsKindShift) - 1; |
| 4325 | 4314 |
| 4326 // Bit positions for bit field 3 | 4315 // Bit positions for bit field 3 |
| 4327 static const int kIsShared = 0; | 4316 static const int kIsShared = 0; |
| 4328 | 4317 |
| 4329 // Layout of the default cache. It holds alternating name and code objects. | 4318 // Layout of the default cache. It holds alternating name and code objects. |
| 4330 static const int kCodeCacheEntrySize = 2; | 4319 static const int kCodeCacheEntrySize = 2; |
| 4331 static const int kCodeCacheEntryNameOffset = 0; | 4320 static const int kCodeCacheEntryNameOffset = 0; |
| 4332 static const int kCodeCacheEntryCodeOffset = 1; | 4321 static const int kCodeCacheEntryCodeOffset = 1; |
| 4333 | 4322 |
| 4334 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 4323 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
| (...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6219 DISALLOW_IMPLICIT_CONSTRUCTORS(String); | 6208 DISALLOW_IMPLICIT_CONSTRUCTORS(String); |
| 6220 }; | 6209 }; |
| 6221 | 6210 |
| 6222 | 6211 |
| 6223 // The SeqString abstract class captures sequential string values. | 6212 // The SeqString abstract class captures sequential string values. |
| 6224 class SeqString: public String { | 6213 class SeqString: public String { |
| 6225 public: | 6214 public: |
| 6226 // Casting. | 6215 // Casting. |
| 6227 static inline SeqString* cast(Object* obj); | 6216 static inline SeqString* cast(Object* obj); |
| 6228 | 6217 |
| 6218 // Layout description. |
| 6219 static const int kHeaderSize = String::kSize; |
| 6220 |
| 6229 private: | 6221 private: |
| 6230 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); | 6222 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); |
| 6231 }; | 6223 }; |
| 6232 | 6224 |
| 6233 | 6225 |
| 6234 // The AsciiString class captures sequential ascii string objects. | 6226 // The AsciiString class captures sequential ascii string objects. |
| 6235 // Each character in the AsciiString is an ascii character. | 6227 // Each character in the AsciiString is an ascii character. |
| 6236 class SeqAsciiString: public SeqString { | 6228 class SeqAsciiString: public SeqString { |
| 6237 public: | 6229 public: |
| 6238 static const bool kHasAsciiEncoding = true; | 6230 static const bool kHasAsciiEncoding = true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6252 // Garbage collection support. This method is called by the | 6244 // Garbage collection support. This method is called by the |
| 6253 // garbage collector to compute the actual size of an AsciiString | 6245 // garbage collector to compute the actual size of an AsciiString |
| 6254 // instance. | 6246 // instance. |
| 6255 inline int SeqAsciiStringSize(InstanceType instance_type); | 6247 inline int SeqAsciiStringSize(InstanceType instance_type); |
| 6256 | 6248 |
| 6257 // Computes the size for an AsciiString instance of a given length. | 6249 // Computes the size for an AsciiString instance of a given length. |
| 6258 static int SizeFor(int length) { | 6250 static int SizeFor(int length) { |
| 6259 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); | 6251 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); |
| 6260 } | 6252 } |
| 6261 | 6253 |
| 6262 // Layout description. | |
| 6263 static const int kHeaderSize = String::kSize; | |
| 6264 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | |
| 6265 | |
| 6266 // Maximal memory usage for a single sequential ASCII string. | 6254 // Maximal memory usage for a single sequential ASCII string. |
| 6267 static const int kMaxSize = 512 * MB; | 6255 static const int kMaxSize = 512 * MB - 1; |
| 6268 // Maximal length of a single sequential ASCII string. | 6256 // Maximal length of a single sequential ASCII string. |
| 6269 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 6257 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
| 6270 static const int kMaxLength = (kMaxSize - kHeaderSize); | 6258 static const int kMaxLength = (kMaxSize - kHeaderSize); |
| 6271 | 6259 |
| 6272 // Support for StringInputBuffer. | 6260 // Support for StringInputBuffer. |
| 6273 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 6261 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 6274 unsigned* offset, | 6262 unsigned* offset, |
| 6275 unsigned chars); | 6263 unsigned chars); |
| 6276 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, | 6264 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, |
| 6277 unsigned* offset, | 6265 unsigned* offset, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6306 // Garbage collection support. This method is called by the | 6294 // Garbage collection support. This method is called by the |
| 6307 // garbage collector to compute the actual size of a TwoByteString | 6295 // garbage collector to compute the actual size of a TwoByteString |
| 6308 // instance. | 6296 // instance. |
| 6309 inline int SeqTwoByteStringSize(InstanceType instance_type); | 6297 inline int SeqTwoByteStringSize(InstanceType instance_type); |
| 6310 | 6298 |
| 6311 // Computes the size for a TwoByteString instance of a given length. | 6299 // Computes the size for a TwoByteString instance of a given length. |
| 6312 static int SizeFor(int length) { | 6300 static int SizeFor(int length) { |
| 6313 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); | 6301 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); |
| 6314 } | 6302 } |
| 6315 | 6303 |
| 6316 // Layout description. | |
| 6317 static const int kHeaderSize = String::kSize; | |
| 6318 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | |
| 6319 | |
| 6320 // Maximal memory usage for a single sequential two-byte string. | 6304 // Maximal memory usage for a single sequential two-byte string. |
| 6321 static const int kMaxSize = 512 * MB; | 6305 static const int kMaxSize = 512 * MB - 1; |
| 6322 // Maximal length of a single sequential two-byte string. | 6306 // Maximal length of a single sequential two-byte string. |
| 6323 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 6307 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
| 6324 static const int kMaxLength = (kMaxSize - kHeaderSize) / sizeof(uint16_t); | 6308 static const int kMaxLength = (kMaxSize - kHeaderSize) / sizeof(uint16_t); |
| 6325 | 6309 |
| 6326 // Support for StringInputBuffer. | 6310 // Support for StringInputBuffer. |
| 6327 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 6311 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 6328 unsigned* offset_ptr, | 6312 unsigned* offset_ptr, |
| 6329 unsigned chars); | 6313 unsigned chars); |
| 6330 | 6314 |
| 6331 private: | 6315 private: |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6473 | 6457 |
| 6474 // The ExternalAsciiString class is an external string backed by an | 6458 // The ExternalAsciiString class is an external string backed by an |
| 6475 // ASCII string. | 6459 // ASCII string. |
| 6476 class ExternalAsciiString: public ExternalString { | 6460 class ExternalAsciiString: public ExternalString { |
| 6477 public: | 6461 public: |
| 6478 static const bool kHasAsciiEncoding = true; | 6462 static const bool kHasAsciiEncoding = true; |
| 6479 | 6463 |
| 6480 typedef v8::String::ExternalAsciiStringResource Resource; | 6464 typedef v8::String::ExternalAsciiStringResource Resource; |
| 6481 | 6465 |
| 6482 // The underlying resource. | 6466 // The underlying resource. |
| 6483 inline Resource* resource(); | 6467 inline const Resource* resource(); |
| 6484 inline void set_resource(Resource* buffer); | 6468 inline void set_resource(const Resource* buffer); |
| 6485 | 6469 |
| 6486 // Dispatched behavior. | 6470 // Dispatched behavior. |
| 6487 uint16_t ExternalAsciiStringGet(int index); | 6471 uint16_t ExternalAsciiStringGet(int index); |
| 6488 | 6472 |
| 6489 // Casting. | 6473 // Casting. |
| 6490 static inline ExternalAsciiString* cast(Object* obj); | 6474 static inline ExternalAsciiString* cast(Object* obj); |
| 6491 | 6475 |
| 6492 // Garbage collection support. | 6476 // Garbage collection support. |
| 6493 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v); | 6477 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v); |
| 6494 | 6478 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6510 | 6494 |
| 6511 // The ExternalTwoByteString class is an external string backed by a UTF-16 | 6495 // The ExternalTwoByteString class is an external string backed by a UTF-16 |
| 6512 // encoded string. | 6496 // encoded string. |
| 6513 class ExternalTwoByteString: public ExternalString { | 6497 class ExternalTwoByteString: public ExternalString { |
| 6514 public: | 6498 public: |
| 6515 static const bool kHasAsciiEncoding = false; | 6499 static const bool kHasAsciiEncoding = false; |
| 6516 | 6500 |
| 6517 typedef v8::String::ExternalStringResource Resource; | 6501 typedef v8::String::ExternalStringResource Resource; |
| 6518 | 6502 |
| 6519 // The underlying string resource. | 6503 // The underlying string resource. |
| 6520 inline Resource* resource(); | 6504 inline const Resource* resource(); |
| 6521 inline void set_resource(Resource* buffer); | 6505 inline void set_resource(const Resource* buffer); |
| 6522 | 6506 |
| 6523 // Dispatched behavior. | 6507 // Dispatched behavior. |
| 6524 uint16_t ExternalTwoByteStringGet(int index); | 6508 uint16_t ExternalTwoByteStringGet(int index); |
| 6525 | 6509 |
| 6526 // For regexp code. | 6510 // For regexp code. |
| 6527 const uint16_t* ExternalTwoByteStringGetData(unsigned start); | 6511 const uint16_t* ExternalTwoByteStringGetData(unsigned start); |
| 6528 | 6512 |
| 6529 // Casting. | 6513 // Casting. |
| 6530 static inline ExternalTwoByteString* cast(Object* obj); | 6514 static inline ExternalTwoByteString* cast(Object* obj); |
| 6531 | 6515 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6662 | 6646 |
| 6663 static const byte kFalse = 0; | 6647 static const byte kFalse = 0; |
| 6664 static const byte kTrue = 1; | 6648 static const byte kTrue = 1; |
| 6665 static const byte kNotBooleanMask = ~1; | 6649 static const byte kNotBooleanMask = ~1; |
| 6666 static const byte kTheHole = 2; | 6650 static const byte kTheHole = 2; |
| 6667 static const byte kNull = 3; | 6651 static const byte kNull = 3; |
| 6668 static const byte kArgumentMarker = 4; | 6652 static const byte kArgumentMarker = 4; |
| 6669 static const byte kUndefined = 5; | 6653 static const byte kUndefined = 5; |
| 6670 static const byte kOther = 6; | 6654 static const byte kOther = 6; |
| 6671 | 6655 |
| 6656 // The ToNumber value of a hidden oddball is a negative smi. |
| 6657 static const int kLeastHiddenOddballNumber = -5; |
| 6658 |
| 6672 typedef FixedBodyDescriptor<kToStringOffset, | 6659 typedef FixedBodyDescriptor<kToStringOffset, |
| 6673 kToNumberOffset + kPointerSize, | 6660 kToNumberOffset + kPointerSize, |
| 6674 kSize> BodyDescriptor; | 6661 kSize> BodyDescriptor; |
| 6675 | 6662 |
| 6676 private: | 6663 private: |
| 6677 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); | 6664 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); |
| 6678 }; | 6665 }; |
| 6679 | 6666 |
| 6680 | 6667 |
| 6681 class JSGlobalPropertyCell: public HeapObject { | 6668 class JSGlobalPropertyCell: public HeapObject { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6697 #endif | 6684 #endif |
| 6698 | 6685 |
| 6699 // Layout description. | 6686 // Layout description. |
| 6700 static const int kValueOffset = HeapObject::kHeaderSize; | 6687 static const int kValueOffset = HeapObject::kHeaderSize; |
| 6701 static const int kSize = kValueOffset + kPointerSize; | 6688 static const int kSize = kValueOffset + kPointerSize; |
| 6702 | 6689 |
| 6703 typedef FixedBodyDescriptor<kValueOffset, | 6690 typedef FixedBodyDescriptor<kValueOffset, |
| 6704 kValueOffset + kPointerSize, | 6691 kValueOffset + kPointerSize, |
| 6705 kSize> BodyDescriptor; | 6692 kSize> BodyDescriptor; |
| 6706 | 6693 |
| 6707 // Returns the isolate/heap this cell object belongs to. | |
| 6708 inline Isolate* isolate(); | |
| 6709 inline Heap* heap(); | |
| 6710 | |
| 6711 private: | 6694 private: |
| 6712 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); | 6695 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); |
| 6713 }; | 6696 }; |
| 6714 | 6697 |
| 6715 | 6698 |
| 6716 // The JSProxy describes EcmaScript Harmony proxies | 6699 // The JSProxy describes EcmaScript Harmony proxies |
| 6717 class JSProxy: public JSReceiver { | 6700 class JSProxy: public JSReceiver { |
| 6718 public: | 6701 public: |
| 6719 // [handler]: The handler property. | 6702 // [handler]: The handler property. |
| 6720 DECL_ACCESSORS(handler, Object) | 6703 DECL_ACCESSORS(handler, Object) |
| 6721 | 6704 |
| 6705 // [hash]: The hash code property (undefined if not initialized yet). |
| 6706 DECL_ACCESSORS(hash, Object) |
| 6707 |
| 6722 // Casting. | 6708 // Casting. |
| 6723 static inline JSProxy* cast(Object* obj); | 6709 static inline JSProxy* cast(Object* obj); |
| 6724 | 6710 |
| 6725 bool HasPropertyWithHandler(String* name); | 6711 bool HasPropertyWithHandler(String* name); |
| 6712 bool HasElementWithHandler(uint32_t index); |
| 6713 |
| 6714 MUST_USE_RESULT MaybeObject* GetPropertyWithHandler( |
| 6715 Object* receiver, |
| 6716 String* name); |
| 6717 MUST_USE_RESULT MaybeObject* GetElementWithHandler( |
| 6718 Object* receiver, |
| 6719 uint32_t index); |
| 6726 | 6720 |
| 6727 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( | 6721 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( |
| 6728 String* name, | 6722 String* name, |
| 6729 Object* value, | 6723 Object* value, |
| 6730 PropertyAttributes attributes, | 6724 PropertyAttributes attributes, |
| 6731 StrictModeFlag strict_mode); | 6725 StrictModeFlag strict_mode); |
| 6726 MUST_USE_RESULT MaybeObject* SetElementWithHandler( |
| 6727 uint32_t index, |
| 6728 Object* value, |
| 6729 StrictModeFlag strict_mode); |
| 6730 |
| 6731 // If the handler defines an accessor property, invoke its setter |
| 6732 // (or throw if only a getter exists) and set *found to true. Otherwise false. |
| 6733 MUST_USE_RESULT MaybeObject* SetPropertyWithHandlerIfDefiningSetter( |
| 6734 String* name, |
| 6735 Object* value, |
| 6736 PropertyAttributes attributes, |
| 6737 StrictModeFlag strict_mode, |
| 6738 bool* found); |
| 6732 | 6739 |
| 6733 MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler( | 6740 MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler( |
| 6734 String* name, | 6741 String* name, |
| 6735 DeleteMode mode); | 6742 DeleteMode mode); |
| 6743 MUST_USE_RESULT MaybeObject* DeleteElementWithHandler( |
| 6744 uint32_t index, |
| 6745 DeleteMode mode); |
| 6736 | 6746 |
| 6737 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler( | 6747 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler( |
| 6738 JSReceiver* receiver, | 6748 JSReceiver* receiver, |
| 6739 String* name, | 6749 String* name); |
| 6740 bool* has_exception); | 6750 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithHandler( |
| 6751 JSReceiver* receiver, |
| 6752 uint32_t index); |
| 6753 |
| 6754 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
| 6741 | 6755 |
| 6742 // Turn this into an (empty) JSObject. | 6756 // Turn this into an (empty) JSObject. |
| 6743 void Fix(); | 6757 void Fix(); |
| 6744 | 6758 |
| 6745 // Initializes the body after the handler slot. | 6759 // Initializes the body after the handler slot. |
| 6746 inline void InitializeBody(int object_size, Object* value); | 6760 inline void InitializeBody(int object_size, Object* value); |
| 6747 | 6761 |
| 6762 // Invoke a trap by name. If the trap does not exist on this's handler, |
| 6763 // but derived_trap is non-NULL, invoke that instead. May cause GC. |
| 6764 Handle<Object> CallTrap(const char* name, |
| 6765 Handle<Object> derived_trap, |
| 6766 int argc, |
| 6767 Handle<Object> args[]); |
| 6768 |
| 6748 // Dispatched behavior. | 6769 // Dispatched behavior. |
| 6749 #ifdef OBJECT_PRINT | 6770 #ifdef OBJECT_PRINT |
| 6750 inline void JSProxyPrint() { | 6771 inline void JSProxyPrint() { |
| 6751 JSProxyPrint(stdout); | 6772 JSProxyPrint(stdout); |
| 6752 } | 6773 } |
| 6753 void JSProxyPrint(FILE* out); | 6774 void JSProxyPrint(FILE* out); |
| 6754 #endif | 6775 #endif |
| 6755 #ifdef DEBUG | 6776 #ifdef DEBUG |
| 6756 void JSProxyVerify(); | 6777 void JSProxyVerify(); |
| 6757 #endif | 6778 #endif |
| 6758 | 6779 |
| 6759 // Layout description. We add padding so that a proxy has the same | 6780 // Layout description. We add padding so that a proxy has the same |
| 6760 // size as a virgin JSObject. This is essential for becoming a JSObject | 6781 // size as a virgin JSObject. This is essential for becoming a JSObject |
| 6761 // upon freeze. | 6782 // upon freeze. |
| 6762 static const int kHandlerOffset = HeapObject::kHeaderSize; | 6783 static const int kHandlerOffset = HeapObject::kHeaderSize; |
| 6763 static const int kPaddingOffset = kHandlerOffset + kPointerSize; | 6784 static const int kHashOffset = kHandlerOffset + kPointerSize; |
| 6785 static const int kPaddingOffset = kHashOffset + kPointerSize; |
| 6764 static const int kSize = JSObject::kHeaderSize; | 6786 static const int kSize = JSObject::kHeaderSize; |
| 6765 static const int kHeaderSize = kPaddingOffset; | 6787 static const int kHeaderSize = kPaddingOffset; |
| 6766 static const int kPaddingSize = kSize - kPaddingOffset; | 6788 static const int kPaddingSize = kSize - kPaddingOffset; |
| 6767 | 6789 |
| 6768 STATIC_CHECK(kPaddingSize >= 0); | 6790 STATIC_CHECK(kPaddingSize >= 0); |
| 6769 | 6791 |
| 6770 typedef FixedBodyDescriptor<kHandlerOffset, | 6792 typedef FixedBodyDescriptor<kHandlerOffset, |
| 6771 kHandlerOffset + kPointerSize, | 6793 kPaddingOffset, |
| 6772 kSize> BodyDescriptor; | 6794 kSize> BodyDescriptor; |
| 6773 | 6795 |
| 6774 private: | 6796 private: |
| 6775 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 6797 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
| 6776 }; | 6798 }; |
| 6777 | 6799 |
| 6778 | 6800 |
| 6779 class JSFunctionProxy: public JSProxy { | 6801 class JSFunctionProxy: public JSProxy { |
| 6780 public: | 6802 public: |
| 6781 // [call_trap]: The call trap. | 6803 // [call_trap]: The call trap. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6792 inline void JSFunctionProxyPrint() { | 6814 inline void JSFunctionProxyPrint() { |
| 6793 JSFunctionProxyPrint(stdout); | 6815 JSFunctionProxyPrint(stdout); |
| 6794 } | 6816 } |
| 6795 void JSFunctionProxyPrint(FILE* out); | 6817 void JSFunctionProxyPrint(FILE* out); |
| 6796 #endif | 6818 #endif |
| 6797 #ifdef DEBUG | 6819 #ifdef DEBUG |
| 6798 void JSFunctionProxyVerify(); | 6820 void JSFunctionProxyVerify(); |
| 6799 #endif | 6821 #endif |
| 6800 | 6822 |
| 6801 // Layout description. | 6823 // Layout description. |
| 6802 static const int kCallTrapOffset = kHandlerOffset + kPointerSize; | 6824 static const int kCallTrapOffset = JSProxy::kPaddingOffset; |
| 6803 static const int kConstructTrapOffset = kCallTrapOffset + kPointerSize; | 6825 static const int kConstructTrapOffset = kCallTrapOffset + kPointerSize; |
| 6804 static const int kPaddingOffset = kConstructTrapOffset + kPointerSize; | 6826 static const int kPaddingOffset = kConstructTrapOffset + kPointerSize; |
| 6805 static const int kSize = JSFunction::kSize; | 6827 static const int kSize = JSFunction::kSize; |
| 6806 static const int kPaddingSize = kSize - kPaddingOffset; | 6828 static const int kPaddingSize = kSize - kPaddingOffset; |
| 6807 | 6829 |
| 6808 STATIC_CHECK(kPaddingSize >= 0); | 6830 STATIC_CHECK(kPaddingSize >= 0); |
| 6809 | 6831 |
| 6810 typedef FixedBodyDescriptor<kHandlerOffset, | 6832 typedef FixedBodyDescriptor<kHandlerOffset, |
| 6811 kConstructTrapOffset + kPointerSize, | 6833 kConstructTrapOffset + kPointerSize, |
| 6812 kSize> BodyDescriptor; | 6834 kSize> BodyDescriptor; |
| 6813 | 6835 |
| 6814 private: | 6836 private: |
| 6815 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); | 6837 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); |
| 6816 }; | 6838 }; |
| 6817 | 6839 |
| 6818 | 6840 |
| 6819 // The JSWeakMap describes EcmaScript Harmony weak maps | 6841 // The JSWeakMap describes EcmaScript Harmony weak maps |
| 6820 class JSWeakMap: public JSObject { | 6842 class JSWeakMap: public JSObject { |
| 6821 public: | 6843 public: |
| 6822 // [table]: the backing hash table mapping keys to values. | 6844 // [table]: the backing hash table mapping keys to values. |
| 6823 DECL_ACCESSORS(table, ObjectHashTable) | 6845 DECL_ACCESSORS(table, Object) |
| 6824 | 6846 |
| 6825 // [next]: linked list of encountered weak maps during GC. | 6847 // [next]: linked list of encountered weak maps during GC. |
| 6826 DECL_ACCESSORS(next, Object) | 6848 DECL_ACCESSORS(next, Object) |
| 6827 | 6849 |
| 6828 // Unchecked accessors to be used during GC. | 6850 // Unchecked accessors to be used during GC. |
| 6829 inline ObjectHashTable* unchecked_table(); | 6851 inline ObjectHashTable* unchecked_table(); |
| 6830 | 6852 |
| 6831 // Casting. | 6853 // Casting. |
| 6832 static inline JSWeakMap* cast(Object* obj); | 6854 static inline JSWeakMap* cast(Object* obj); |
| 6833 | 6855 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6906 | 6928 |
| 6907 MUST_USE_RESULT MaybeObject* JSArrayUpdateLengthFromIndex(uint32_t index, | 6929 MUST_USE_RESULT MaybeObject* JSArrayUpdateLengthFromIndex(uint32_t index, |
| 6908 Object* value); | 6930 Object* value); |
| 6909 | 6931 |
| 6910 // Initialize the array with the given capacity. The function may | 6932 // Initialize the array with the given capacity. The function may |
| 6911 // fail due to out-of-memory situations, but only if the requested | 6933 // fail due to out-of-memory situations, but only if the requested |
| 6912 // capacity is non-zero. | 6934 // capacity is non-zero. |
| 6913 MUST_USE_RESULT MaybeObject* Initialize(int capacity); | 6935 MUST_USE_RESULT MaybeObject* Initialize(int capacity); |
| 6914 | 6936 |
| 6915 // Set the content of the array to the content of storage. | 6937 // Set the content of the array to the content of storage. |
| 6916 inline void SetContent(FixedArray* storage); | 6938 inline MaybeObject* SetContent(FixedArray* storage); |
| 6917 | 6939 |
| 6918 // Casting. | 6940 // Casting. |
| 6919 static inline JSArray* cast(Object* obj); | 6941 static inline JSArray* cast(Object* obj); |
| 6920 | 6942 |
| 6921 // Uses handles. Ensures that the fixed array backing the JSArray has at | 6943 // Uses handles. Ensures that the fixed array backing the JSArray has at |
| 6922 // least the stated size. | 6944 // least the stated size. |
| 6923 inline void EnsureSize(int minimum_size_of_backing_fixed_array); | 6945 inline void EnsureSize(int minimum_size_of_backing_fixed_array); |
| 6924 | 6946 |
| 6925 // Dispatched behavior. | 6947 // Dispatched behavior. |
| 6926 #ifdef OBJECT_PRINT | 6948 #ifdef OBJECT_PRINT |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7426 v8::String::ExternalAsciiStringResource** resource) {} | 7448 v8::String::ExternalAsciiStringResource** resource) {} |
| 7427 virtual void VisitExternalTwoByteString( | 7449 virtual void VisitExternalTwoByteString( |
| 7428 v8::String::ExternalStringResource** resource) {} | 7450 v8::String::ExternalStringResource** resource) {} |
| 7429 | 7451 |
| 7430 // Visits a debug call target in the instruction stream. | 7452 // Visits a debug call target in the instruction stream. |
| 7431 virtual void VisitDebugTarget(RelocInfo* rinfo); | 7453 virtual void VisitDebugTarget(RelocInfo* rinfo); |
| 7432 | 7454 |
| 7433 // Handy shorthand for visiting a single pointer. | 7455 // Handy shorthand for visiting a single pointer. |
| 7434 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 7456 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } |
| 7435 | 7457 |
| 7458 // Visit pointer embedded into a code object. |
| 7459 virtual void VisitEmbeddedPointer(Code* host, Object** p) { |
| 7460 // Default implementation for the convenience of users that do |
| 7461 // not care about the host object. |
| 7462 VisitPointer(p); |
| 7463 } |
| 7464 |
| 7436 // Visits a contiguous arrays of external references (references to the C++ | 7465 // Visits a contiguous arrays of external references (references to the C++ |
| 7437 // heap) in the half-open range [start, end). Any or all of the values | 7466 // heap) in the half-open range [start, end). Any or all of the values |
| 7438 // may be modified on return. | 7467 // may be modified on return. |
| 7439 virtual void VisitExternalReferences(Address* start, Address* end) {} | 7468 virtual void VisitExternalReferences(Address* start, Address* end) {} |
| 7440 | 7469 |
| 7441 inline void VisitExternalReference(Address* p) { | 7470 inline void VisitExternalReference(Address* p) { |
| 7442 VisitExternalReferences(p, p + 1); | 7471 VisitExternalReferences(p, p + 1); |
| 7443 } | 7472 } |
| 7444 | 7473 |
| 7445 // Visits a handle that has an embedder-assigned class ID. | 7474 // Visits a handle that has an embedder-assigned class ID. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7486 } else { | 7515 } else { |
| 7487 value &= ~(1 << bit_position); | 7516 value &= ~(1 << bit_position); |
| 7488 } | 7517 } |
| 7489 return value; | 7518 return value; |
| 7490 } | 7519 } |
| 7491 }; | 7520 }; |
| 7492 | 7521 |
| 7493 } } // namespace v8::internal | 7522 } } // namespace v8::internal |
| 7494 | 7523 |
| 7495 #endif // V8_OBJECTS_H_ | 7524 #endif // V8_OBJECTS_H_ |
| OLD | NEW |