| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // - JSArray | 50 // - JSArray |
| 51 // - JSRegExp | 51 // - JSRegExp |
| 52 // - JSFunction | 52 // - JSFunction |
| 53 // - GlobalObject | 53 // - GlobalObject |
| 54 // - JSGlobalObject | 54 // - JSGlobalObject |
| 55 // - JSBuiltinsObject | 55 // - JSBuiltinsObject |
| 56 // - JSGlobalProxy | 56 // - JSGlobalProxy |
| 57 // - JSValue | 57 // - JSValue |
| 58 // - JSMessageObject | 58 // - JSMessageObject |
| 59 // - ByteArray | 59 // - ByteArray |
| 60 // - PixelArray | |
| 61 // - ExternalArray | 60 // - ExternalArray |
| 61 // - ExternalPixelArray |
| 62 // - ExternalByteArray | 62 // - ExternalByteArray |
| 63 // - ExternalUnsignedByteArray | 63 // - ExternalUnsignedByteArray |
| 64 // - ExternalShortArray | 64 // - ExternalShortArray |
| 65 // - ExternalUnsignedShortArray | 65 // - ExternalUnsignedShortArray |
| 66 // - ExternalIntArray | 66 // - ExternalIntArray |
| 67 // - ExternalUnsignedIntArray | 67 // - ExternalUnsignedIntArray |
| 68 // - ExternalFloatArray | 68 // - ExternalFloatArray |
| 69 // - FixedArray | 69 // - FixedArray |
| 70 // - DescriptorArray | 70 // - DescriptorArray |
| 71 // - HashTable | 71 // - HashTable |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 255 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
| 256 \ | 256 \ |
| 257 V(MAP_TYPE) \ | 257 V(MAP_TYPE) \ |
| 258 V(CODE_TYPE) \ | 258 V(CODE_TYPE) \ |
| 259 V(ODDBALL_TYPE) \ | 259 V(ODDBALL_TYPE) \ |
| 260 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 260 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
| 261 \ | 261 \ |
| 262 V(HEAP_NUMBER_TYPE) \ | 262 V(HEAP_NUMBER_TYPE) \ |
| 263 V(PROXY_TYPE) \ | 263 V(PROXY_TYPE) \ |
| 264 V(BYTE_ARRAY_TYPE) \ | 264 V(BYTE_ARRAY_TYPE) \ |
| 265 V(PIXEL_ARRAY_TYPE) \ | |
| 266 /* Note: the order of these external array */ \ | 265 /* Note: the order of these external array */ \ |
| 267 /* types is relied upon in */ \ | 266 /* types is relied upon in */ \ |
| 268 /* Object::IsExternalArray(). */ \ | 267 /* Object::IsExternalArray(). */ \ |
| 269 V(EXTERNAL_BYTE_ARRAY_TYPE) \ | 268 V(EXTERNAL_BYTE_ARRAY_TYPE) \ |
| 270 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ | 269 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ |
| 271 V(EXTERNAL_SHORT_ARRAY_TYPE) \ | 270 V(EXTERNAL_SHORT_ARRAY_TYPE) \ |
| 272 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ | 271 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ |
| 273 V(EXTERNAL_INT_ARRAY_TYPE) \ | 272 V(EXTERNAL_INT_ARRAY_TYPE) \ |
| 274 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ | 273 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ |
| 275 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ | 274 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ |
| 275 V(EXTERNAL_PIXEL_ARRAY_TYPE) \ |
| 276 V(FILLER_TYPE) \ | 276 V(FILLER_TYPE) \ |
| 277 \ | 277 \ |
| 278 V(ACCESSOR_INFO_TYPE) \ | 278 V(ACCESSOR_INFO_TYPE) \ |
| 279 V(ACCESS_CHECK_INFO_TYPE) \ | 279 V(ACCESS_CHECK_INFO_TYPE) \ |
| 280 V(INTERCEPTOR_INFO_TYPE) \ | 280 V(INTERCEPTOR_INFO_TYPE) \ |
| 281 V(CALL_HANDLER_INFO_TYPE) \ | 281 V(CALL_HANDLER_INFO_TYPE) \ |
| 282 V(FUNCTION_TEMPLATE_INFO_TYPE) \ | 282 V(FUNCTION_TEMPLATE_INFO_TYPE) \ |
| 283 V(OBJECT_TEMPLATE_INFO_TYPE) \ | 283 V(OBJECT_TEMPLATE_INFO_TYPE) \ |
| 284 V(SIGNATURE_INFO_TYPE) \ | 284 V(SIGNATURE_INFO_TYPE) \ |
| 285 V(TYPE_SWITCH_INFO_TYPE) \ | 285 V(TYPE_SWITCH_INFO_TYPE) \ |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 483 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
| 484 CODE_TYPE, | 484 CODE_TYPE, |
| 485 ODDBALL_TYPE, | 485 ODDBALL_TYPE, |
| 486 JS_GLOBAL_PROPERTY_CELL_TYPE, | 486 JS_GLOBAL_PROPERTY_CELL_TYPE, |
| 487 | 487 |
| 488 // "Data", objects that cannot contain non-map-word pointers to heap | 488 // "Data", objects that cannot contain non-map-word pointers to heap |
| 489 // objects. | 489 // objects. |
| 490 HEAP_NUMBER_TYPE, | 490 HEAP_NUMBER_TYPE, |
| 491 PROXY_TYPE, | 491 PROXY_TYPE, |
| 492 BYTE_ARRAY_TYPE, | 492 BYTE_ARRAY_TYPE, |
| 493 PIXEL_ARRAY_TYPE, | |
| 494 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 493 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
| 495 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | 494 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
| 496 EXTERNAL_SHORT_ARRAY_TYPE, | 495 EXTERNAL_SHORT_ARRAY_TYPE, |
| 497 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | 496 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
| 498 EXTERNAL_INT_ARRAY_TYPE, | 497 EXTERNAL_INT_ARRAY_TYPE, |
| 499 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | 498 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
| 500 EXTERNAL_FLOAT_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 499 EXTERNAL_FLOAT_ARRAY_TYPE, |
| 500 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
| 501 FILLER_TYPE, // LAST_DATA_TYPE | 501 FILLER_TYPE, // LAST_DATA_TYPE |
| 502 | 502 |
| 503 // Structs. | 503 // Structs. |
| 504 ACCESSOR_INFO_TYPE, | 504 ACCESSOR_INFO_TYPE, |
| 505 ACCESS_CHECK_INFO_TYPE, | 505 ACCESS_CHECK_INFO_TYPE, |
| 506 INTERCEPTOR_INFO_TYPE, | 506 INTERCEPTOR_INFO_TYPE, |
| 507 CALL_HANDLER_INFO_TYPE, | 507 CALL_HANDLER_INFO_TYPE, |
| 508 FUNCTION_TEMPLATE_INFO_TYPE, | 508 FUNCTION_TEMPLATE_INFO_TYPE, |
| 509 OBJECT_TEMPLATE_INFO_TYPE, | 509 OBJECT_TEMPLATE_INFO_TYPE, |
| 510 SIGNATURE_INFO_TYPE, | 510 SIGNATURE_INFO_TYPE, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 537 | 537 |
| 538 // Pseudo-types | 538 // Pseudo-types |
| 539 FIRST_TYPE = 0x0, | 539 FIRST_TYPE = 0x0, |
| 540 LAST_TYPE = JS_FUNCTION_TYPE, | 540 LAST_TYPE = JS_FUNCTION_TYPE, |
| 541 INVALID_TYPE = FIRST_TYPE - 1, | 541 INVALID_TYPE = FIRST_TYPE - 1, |
| 542 FIRST_NONSTRING_TYPE = MAP_TYPE, | 542 FIRST_NONSTRING_TYPE = MAP_TYPE, |
| 543 FIRST_STRING_TYPE = FIRST_TYPE, | 543 FIRST_STRING_TYPE = FIRST_TYPE, |
| 544 LAST_STRING_TYPE = FIRST_NONSTRING_TYPE - 1, | 544 LAST_STRING_TYPE = FIRST_NONSTRING_TYPE - 1, |
| 545 // Boundaries for testing for an external array. | 545 // Boundaries for testing for an external array. |
| 546 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, | 546 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, |
| 547 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_FLOAT_ARRAY_TYPE, | 547 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, |
| 548 // Boundary for promotion to old data space/old pointer space. | 548 // Boundary for promotion to old data space/old pointer space. |
| 549 LAST_DATA_TYPE = FILLER_TYPE, | 549 LAST_DATA_TYPE = FILLER_TYPE, |
| 550 // Boundaries for testing the type is a JavaScript "object". Note that | 550 // Boundaries for testing the type is a JavaScript "object". Note that |
| 551 // function objects are not counted as objects, even though they are | 551 // function objects are not counted as objects, even though they are |
| 552 // implemented as such; only values whose typeof is "object" are included. | 552 // implemented as such; only values whose typeof is "object" are included. |
| 553 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, | 553 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, |
| 554 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE, | 554 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE, |
| 555 // RegExp objects have [[Class]] "function" because they are callable. | 555 // RegExp objects have [[Class]] "function" because they are callable. |
| 556 // All types from this type and above are objects with [[Class]] "function". | 556 // All types from this type and above are objects with [[Class]] "function". |
| 557 FIRST_FUNCTION_CLASS_TYPE = JS_REGEXP_TYPE | 557 FIRST_FUNCTION_CLASS_TYPE = JS_REGEXP_TYPE |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 V(String) \ | 648 V(String) \ |
| 649 V(Symbol) \ | 649 V(Symbol) \ |
| 650 V(SeqString) \ | 650 V(SeqString) \ |
| 651 V(ExternalString) \ | 651 V(ExternalString) \ |
| 652 V(ConsString) \ | 652 V(ConsString) \ |
| 653 V(ExternalTwoByteString) \ | 653 V(ExternalTwoByteString) \ |
| 654 V(ExternalAsciiString) \ | 654 V(ExternalAsciiString) \ |
| 655 V(SeqTwoByteString) \ | 655 V(SeqTwoByteString) \ |
| 656 V(SeqAsciiString) \ | 656 V(SeqAsciiString) \ |
| 657 \ | 657 \ |
| 658 V(PixelArray) \ | |
| 659 V(ExternalArray) \ | 658 V(ExternalArray) \ |
| 660 V(ExternalByteArray) \ | 659 V(ExternalByteArray) \ |
| 661 V(ExternalUnsignedByteArray) \ | 660 V(ExternalUnsignedByteArray) \ |
| 662 V(ExternalShortArray) \ | 661 V(ExternalShortArray) \ |
| 663 V(ExternalUnsignedShortArray) \ | 662 V(ExternalUnsignedShortArray) \ |
| 664 V(ExternalIntArray) \ | 663 V(ExternalIntArray) \ |
| 665 V(ExternalUnsignedIntArray) \ | 664 V(ExternalUnsignedIntArray) \ |
| 666 V(ExternalFloatArray) \ | 665 V(ExternalFloatArray) \ |
| 666 V(ExternalPixelArray) \ |
| 667 V(ByteArray) \ | 667 V(ByteArray) \ |
| 668 V(JSObject) \ | 668 V(JSObject) \ |
| 669 V(JSContextExtensionObject) \ | 669 V(JSContextExtensionObject) \ |
| 670 V(Map) \ | 670 V(Map) \ |
| 671 V(DescriptorArray) \ | 671 V(DescriptorArray) \ |
| 672 V(DeoptimizationInputData) \ | 672 V(DeoptimizationInputData) \ |
| 673 V(DeoptimizationOutputData) \ | 673 V(DeoptimizationOutputData) \ |
| 674 V(FixedArray) \ | 674 V(FixedArray) \ |
| 675 V(Context) \ | 675 V(Context) \ |
| 676 V(CatchContext) \ | 676 V(CatchContext) \ |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 NORMAL_DELETION, | 1299 NORMAL_DELETION, |
| 1300 STRICT_DELETION, | 1300 STRICT_DELETION, |
| 1301 FORCE_DELETION | 1301 FORCE_DELETION |
| 1302 }; | 1302 }; |
| 1303 | 1303 |
| 1304 enum ElementsKind { | 1304 enum ElementsKind { |
| 1305 // The only "fast" kind. | 1305 // The only "fast" kind. |
| 1306 FAST_ELEMENTS, | 1306 FAST_ELEMENTS, |
| 1307 // All the kinds below are "slow". | 1307 // All the kinds below are "slow". |
| 1308 DICTIONARY_ELEMENTS, | 1308 DICTIONARY_ELEMENTS, |
| 1309 PIXEL_ELEMENTS, | |
| 1310 EXTERNAL_BYTE_ELEMENTS, | 1309 EXTERNAL_BYTE_ELEMENTS, |
| 1311 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1310 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
| 1312 EXTERNAL_SHORT_ELEMENTS, | 1311 EXTERNAL_SHORT_ELEMENTS, |
| 1313 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1312 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
| 1314 EXTERNAL_INT_ELEMENTS, | 1313 EXTERNAL_INT_ELEMENTS, |
| 1315 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1314 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
| 1316 EXTERNAL_FLOAT_ELEMENTS | 1315 EXTERNAL_FLOAT_ELEMENTS, |
| 1316 EXTERNAL_PIXEL_ELEMENTS |
| 1317 }; | 1317 }; |
| 1318 | 1318 |
| 1319 // [properties]: Backing storage for properties. | 1319 // [properties]: Backing storage for properties. |
| 1320 // properties is a FixedArray in the fast case and a Dictionary in the | 1320 // properties is a FixedArray in the fast case and a Dictionary in the |
| 1321 // slow case. | 1321 // slow case. |
| 1322 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1322 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
| 1323 inline void initialize_properties(); | 1323 inline void initialize_properties(); |
| 1324 inline bool HasFastProperties(); | 1324 inline bool HasFastProperties(); |
| 1325 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1325 inline StringDictionary* property_dictionary(); // Gets slow properties. |
| 1326 | 1326 |
| 1327 // [elements]: The elements (properties with names that are integers). | 1327 // [elements]: The elements (properties with names that are integers). |
| 1328 // | 1328 // |
| 1329 // Elements can be in two general modes: fast and slow. Each mode | 1329 // Elements can be in two general modes: fast and slow. Each mode |
| 1330 // corrensponds to a set of object representations of elements that | 1330 // corrensponds to a set of object representations of elements that |
| 1331 // have something in common. | 1331 // have something in common. |
| 1332 // | 1332 // |
| 1333 // In the fast mode elements is a FixedArray and so each element can | 1333 // In the fast mode elements is a FixedArray and so each element can |
| 1334 // be quickly accessed. This fact is used in the generated code. The | 1334 // be quickly accessed. This fact is used in the generated code. The |
| 1335 // elements array can have one of the two maps in this mode: | 1335 // elements array can have one of the two maps in this mode: |
| 1336 // fixed_array_map or fixed_cow_array_map (for copy-on-write | 1336 // fixed_array_map or fixed_cow_array_map (for copy-on-write |
| 1337 // arrays). In the latter case the elements array may be shared by a | 1337 // arrays). In the latter case the elements array may be shared by a |
| 1338 // few objects and so before writing to any element the array must | 1338 // few objects and so before writing to any element the array must |
| 1339 // be copied. Use EnsureWritableFastElements in this case. | 1339 // be copied. Use EnsureWritableFastElements in this case. |
| 1340 // | 1340 // |
| 1341 // In the slow mode elements is either a NumberDictionary or a | 1341 // In the slow mode elements is either a NumberDictionary or an ExternalArray. |
| 1342 // PixelArray or an ExternalArray. | |
| 1343 DECL_ACCESSORS(elements, HeapObject) | 1342 DECL_ACCESSORS(elements, HeapObject) |
| 1344 inline void initialize_elements(); | 1343 inline void initialize_elements(); |
| 1345 MUST_USE_RESULT inline MaybeObject* ResetElements(); | 1344 MUST_USE_RESULT inline MaybeObject* ResetElements(); |
| 1346 inline ElementsKind GetElementsKind(); | 1345 inline ElementsKind GetElementsKind(); |
| 1347 inline bool HasFastElements(); | 1346 inline bool HasFastElements(); |
| 1348 inline bool HasDictionaryElements(); | 1347 inline bool HasDictionaryElements(); |
| 1349 inline bool HasPixelElements(); | 1348 inline bool HasExternalPixelElements(); |
| 1350 inline bool HasExternalArrayElements(); | 1349 inline bool HasExternalArrayElements(); |
| 1351 inline bool HasExternalByteElements(); | 1350 inline bool HasExternalByteElements(); |
| 1352 inline bool HasExternalUnsignedByteElements(); | 1351 inline bool HasExternalUnsignedByteElements(); |
| 1353 inline bool HasExternalShortElements(); | 1352 inline bool HasExternalShortElements(); |
| 1354 inline bool HasExternalUnsignedShortElements(); | 1353 inline bool HasExternalUnsignedShortElements(); |
| 1355 inline bool HasExternalIntElements(); | 1354 inline bool HasExternalIntElements(); |
| 1356 inline bool HasExternalUnsignedIntElements(); | 1355 inline bool HasExternalUnsignedIntElements(); |
| 1357 inline bool HasExternalFloatElements(); | 1356 inline bool HasExternalFloatElements(); |
| 1358 inline bool AllowsSetElementsLength(); | 1357 inline bool AllowsSetElementsLength(); |
| 1359 inline NumberDictionary* element_dictionary(); // Gets slow elements. | 1358 inline NumberDictionary* element_dictionary(); // Gets slow elements. |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2785 // Maximal memory consumption for a single ByteArray. | 2784 // Maximal memory consumption for a single ByteArray. |
| 2786 static const int kMaxSize = 512 * MB; | 2785 static const int kMaxSize = 512 * MB; |
| 2787 // Maximal length of a single ByteArray. | 2786 // Maximal length of a single ByteArray. |
| 2788 static const int kMaxLength = kMaxSize - kHeaderSize; | 2787 static const int kMaxLength = kMaxSize - kHeaderSize; |
| 2789 | 2788 |
| 2790 private: | 2789 private: |
| 2791 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2790 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
| 2792 }; | 2791 }; |
| 2793 | 2792 |
| 2794 | 2793 |
| 2795 // A PixelArray represents a fixed-size byte array with special semantics | |
| 2796 // used for implementing the CanvasPixelArray object. Please see the | |
| 2797 // specification at: | |
| 2798 // http://www.whatwg.org/specs/web-apps/current-work/ | |
| 2799 // multipage/the-canvas-element.html#canvaspixelarray | |
| 2800 // In particular, write access clamps the value written to 0 or 255 if the | |
| 2801 // value written is outside this range. | |
| 2802 class PixelArray: public HeapObject { | |
| 2803 public: | |
| 2804 // [length]: length of the array. | |
| 2805 inline int length(); | |
| 2806 inline void set_length(int value); | |
| 2807 | |
| 2808 // [external_pointer]: The pointer to the external memory area backing this | |
| 2809 // pixel array. | |
| 2810 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store. | |
| 2811 | |
| 2812 // Setter and getter. | |
| 2813 inline uint8_t get(int index); | |
| 2814 inline void set(int index, uint8_t value); | |
| 2815 | |
| 2816 // This accessor applies the correct conversion from Smi, HeapNumber and | |
| 2817 // undefined and clamps the converted value between 0 and 255. | |
| 2818 Object* SetValue(uint32_t index, Object* value); | |
| 2819 | |
| 2820 // Casting. | |
| 2821 static inline PixelArray* cast(Object* obj); | |
| 2822 | |
| 2823 #ifdef OBJECT_PRINT | |
| 2824 inline void PixelArrayPrint() { | |
| 2825 PixelArrayPrint(stdout); | |
| 2826 } | |
| 2827 void PixelArrayPrint(FILE* out); | |
| 2828 #endif | |
| 2829 #ifdef DEBUG | |
| 2830 void PixelArrayVerify(); | |
| 2831 #endif // DEBUG | |
| 2832 | |
| 2833 // Maximal acceptable length for a pixel array. | |
| 2834 static const int kMaxLength = 0x3fffffff; | |
| 2835 | |
| 2836 // PixelArray headers are not quadword aligned. | |
| 2837 static const int kLengthOffset = HeapObject::kHeaderSize; | |
| 2838 static const int kExternalPointerOffset = | |
| 2839 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | |
| 2840 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | |
| 2841 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | |
| 2842 | |
| 2843 private: | |
| 2844 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); | |
| 2845 }; | |
| 2846 | |
| 2847 | |
| 2848 // An ExternalArray represents a fixed-size array of primitive values | 2794 // An ExternalArray represents a fixed-size array of primitive values |
| 2849 // which live outside the JavaScript heap. Its subclasses are used to | 2795 // which live outside the JavaScript heap. Its subclasses are used to |
| 2850 // implement the CanvasArray types being defined in the WebGL | 2796 // implement the CanvasArray types being defined in the WebGL |
| 2851 // specification. As of this writing the first public draft is not yet | 2797 // specification. As of this writing the first public draft is not yet |
| 2852 // available, but Khronos members can access the draft at: | 2798 // available, but Khronos members can access the draft at: |
| 2853 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2799 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
| 2854 // | 2800 // |
| 2855 // The semantics of these arrays differ from CanvasPixelArray. | 2801 // The semantics of these arrays differ from CanvasPixelArray. |
| 2856 // Out-of-range values passed to the setter are converted via a C | 2802 // Out-of-range values passed to the setter are converted via a C |
| 2857 // cast, not clamping. Out-of-range indices cause exceptions to be | 2803 // cast, not clamping. Out-of-range indices cause exceptions to be |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2877 static const int kExternalPointerOffset = | 2823 static const int kExternalPointerOffset = |
| 2878 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); | 2824 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); |
| 2879 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; | 2825 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; |
| 2880 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 2826 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
| 2881 | 2827 |
| 2882 private: | 2828 private: |
| 2883 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); | 2829 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); |
| 2884 }; | 2830 }; |
| 2885 | 2831 |
| 2886 | 2832 |
| 2833 // A ExternalPixelArray represents a fixed-size byte array with special |
| 2834 // semantics used for implementing the CanvasPixelArray object. Please see the |
| 2835 // specification at: |
| 2836 |
| 2837 // http://www.whatwg.org/specs/web-apps/current-work/ |
| 2838 // multipage/the-canvas-element.html#canvaspixelarray |
| 2839 // In particular, write access clamps the value written to 0 or 255 if the |
| 2840 // value written is outside this range. |
| 2841 class ExternalPixelArray: public ExternalArray { |
| 2842 public: |
| 2843 inline uint8_t* external_pixel_pointer(); |
| 2844 |
| 2845 // Setter and getter. |
| 2846 inline uint8_t get(int index); |
| 2847 inline void set(int index, uint8_t value); |
| 2848 |
| 2849 // This accessor applies the correct conversion from Smi, HeapNumber and |
| 2850 // undefined and clamps the converted value between 0 and 255. |
| 2851 Object* SetValue(uint32_t index, Object* value); |
| 2852 |
| 2853 // Casting. |
| 2854 static inline ExternalPixelArray* cast(Object* obj); |
| 2855 |
| 2856 #ifdef OBJECT_PRINT |
| 2857 inline void ExternalPixelArrayPrint() { |
| 2858 ExternalPixelArrayPrint(stdout); |
| 2859 } |
| 2860 void ExternalPixelArrayPrint(FILE* out); |
| 2861 #endif |
| 2862 #ifdef DEBUG |
| 2863 void ExternalPixelArrayVerify(); |
| 2864 #endif // DEBUG |
| 2865 |
| 2866 private: |
| 2867 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalPixelArray); |
| 2868 }; |
| 2869 |
| 2870 |
| 2887 class ExternalByteArray: public ExternalArray { | 2871 class ExternalByteArray: public ExternalArray { |
| 2888 public: | 2872 public: |
| 2889 // Setter and getter. | 2873 // Setter and getter. |
| 2890 inline int8_t get(int index); | 2874 inline int8_t get(int index); |
| 2891 inline void set(int index, int8_t value); | 2875 inline void set(int index, int8_t value); |
| 2892 | 2876 |
| 2893 // This accessor applies the correct conversion from Smi, HeapNumber | 2877 // This accessor applies the correct conversion from Smi, HeapNumber |
| 2894 // and undefined. | 2878 // and undefined. |
| 2895 MaybeObject* SetValue(uint32_t index, Object* value); | 2879 MaybeObject* SetValue(uint32_t index, Object* value); |
| 2896 | 2880 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3211 FLAGS_MAX_VALUE = kMaxInt | 3195 FLAGS_MAX_VALUE = kMaxInt |
| 3212 }; | 3196 }; |
| 3213 | 3197 |
| 3214 enum Kind { | 3198 enum Kind { |
| 3215 FUNCTION, | 3199 FUNCTION, |
| 3216 OPTIMIZED_FUNCTION, | 3200 OPTIMIZED_FUNCTION, |
| 3217 STUB, | 3201 STUB, |
| 3218 BUILTIN, | 3202 BUILTIN, |
| 3219 LOAD_IC, | 3203 LOAD_IC, |
| 3220 KEYED_LOAD_IC, | 3204 KEYED_LOAD_IC, |
| 3205 KEYED_EXTERNAL_ARRAY_LOAD_IC, |
| 3221 CALL_IC, | 3206 CALL_IC, |
| 3222 KEYED_CALL_IC, | 3207 KEYED_CALL_IC, |
| 3223 STORE_IC, | 3208 STORE_IC, |
| 3224 KEYED_STORE_IC, | 3209 KEYED_STORE_IC, |
| 3210 KEYED_EXTERNAL_ARRAY_STORE_IC, |
| 3225 BINARY_OP_IC, | 3211 BINARY_OP_IC, |
| 3226 TYPE_RECORDING_BINARY_OP_IC, | 3212 TYPE_RECORDING_BINARY_OP_IC, |
| 3227 COMPARE_IC, | 3213 COMPARE_IC, |
| 3228 // No more than 16 kinds. The value currently encoded in four bits in | 3214 // No more than 16 kinds. The value currently encoded in four bits in |
| 3229 // Flags. | 3215 // Flags. |
| 3230 | 3216 |
| 3231 // Pseudo-kinds. | 3217 // Pseudo-kinds. |
| 3232 REGEXP = BUILTIN, | 3218 REGEXP = BUILTIN, |
| 3233 FIRST_IC_KIND = LOAD_IC, | 3219 FIRST_IC_KIND = LOAD_IC, |
| 3234 LAST_IC_KIND = COMPARE_IC | 3220 LAST_IC_KIND = COMPARE_IC |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3289 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } | 3275 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } |
| 3290 inline bool is_store_stub() { return kind() == STORE_IC; } | 3276 inline bool is_store_stub() { return kind() == STORE_IC; } |
| 3291 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } | 3277 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } |
| 3292 inline bool is_call_stub() { return kind() == CALL_IC; } | 3278 inline bool is_call_stub() { return kind() == CALL_IC; } |
| 3293 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } | 3279 inline bool is_keyed_call_stub() { return kind() == KEYED_CALL_IC; } |
| 3294 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } | 3280 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } |
| 3295 inline bool is_type_recording_binary_op_stub() { | 3281 inline bool is_type_recording_binary_op_stub() { |
| 3296 return kind() == TYPE_RECORDING_BINARY_OP_IC; | 3282 return kind() == TYPE_RECORDING_BINARY_OP_IC; |
| 3297 } | 3283 } |
| 3298 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } | 3284 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } |
| 3285 inline bool is_external_array_load_stub() { |
| 3286 return kind() == KEYED_EXTERNAL_ARRAY_LOAD_IC; |
| 3287 } |
| 3288 inline bool is_external_array_store_stub() { |
| 3289 return kind() == KEYED_EXTERNAL_ARRAY_STORE_IC; |
| 3290 } |
| 3299 | 3291 |
| 3300 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. | 3292 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. |
| 3301 inline int major_key(); | 3293 inline int major_key(); |
| 3302 inline void set_major_key(int value); | 3294 inline void set_major_key(int value); |
| 3303 | 3295 |
| 3304 // [optimizable]: For FUNCTION kind, tells if it is optimizable. | 3296 // [optimizable]: For FUNCTION kind, tells if it is optimizable. |
| 3305 inline bool optimizable(); | 3297 inline bool optimizable(); |
| 3306 inline void set_optimizable(bool value); | 3298 inline void set_optimizable(bool value); |
| 3307 | 3299 |
| 3308 // [has_deoptimization_support]: For FUNCTION kind, tells if it has | 3300 // [has_deoptimization_support]: For FUNCTION kind, tells if it has |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3330 // [stack_check_table_start]: For kind FUNCTION, the offset in the | 3322 // [stack_check_table_start]: For kind FUNCTION, the offset in the |
| 3331 // instruction stream where the stack check table starts. | 3323 // instruction stream where the stack check table starts. |
| 3332 inline unsigned stack_check_table_offset(); | 3324 inline unsigned stack_check_table_offset(); |
| 3333 inline void set_stack_check_table_offset(unsigned offset); | 3325 inline void set_stack_check_table_offset(unsigned offset); |
| 3334 | 3326 |
| 3335 // [check type]: For kind CALL_IC, tells how to check if the | 3327 // [check type]: For kind CALL_IC, tells how to check if the |
| 3336 // receiver is valid for the given call. | 3328 // receiver is valid for the given call. |
| 3337 inline CheckType check_type(); | 3329 inline CheckType check_type(); |
| 3338 inline void set_check_type(CheckType value); | 3330 inline void set_check_type(CheckType value); |
| 3339 | 3331 |
| 3332 // [external array type]: For kind KEYED_EXTERNAL_ARRAY_LOAD_IC and |
| 3333 // KEYED_EXTERNAL_ARRAY_STORE_IC, identifies the type of external |
| 3334 // array that the code stub is specialized for. |
| 3335 inline ExternalArrayType external_array_type(); |
| 3336 inline void set_external_array_type(ExternalArrayType value); |
| 3337 |
| 3340 // [binary op type]: For all BINARY_OP_IC. | 3338 // [binary op type]: For all BINARY_OP_IC. |
| 3341 inline byte binary_op_type(); | 3339 inline byte binary_op_type(); |
| 3342 inline void set_binary_op_type(byte value); | 3340 inline void set_binary_op_type(byte value); |
| 3343 | 3341 |
| 3344 // [type-recording binary op type]: For all TYPE_RECORDING_BINARY_OP_IC. | 3342 // [type-recording binary op type]: For all TYPE_RECORDING_BINARY_OP_IC. |
| 3345 inline byte type_recording_binary_op_type(); | 3343 inline byte type_recording_binary_op_type(); |
| 3346 inline void set_type_recording_binary_op_type(byte value); | 3344 inline void set_type_recording_binary_op_type(byte value); |
| 3347 inline byte type_recording_binary_op_result_type(); | 3345 inline byte type_recording_binary_op_result_type(); |
| 3348 inline void set_type_recording_binary_op_result_type(byte value); | 3346 inline void set_type_recording_binary_op_result_type(byte value); |
| 3349 | 3347 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3478 // Add padding to align the instruction start following right after | 3476 // Add padding to align the instruction start following right after |
| 3479 // the Code object header. | 3477 // the Code object header. |
| 3480 static const int kHeaderSize = | 3478 static const int kHeaderSize = |
| 3481 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; | 3479 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; |
| 3482 | 3480 |
| 3483 // Byte offsets within kKindSpecificFlagsOffset. | 3481 // Byte offsets within kKindSpecificFlagsOffset. |
| 3484 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset; | 3482 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset; |
| 3485 static const int kOptimizableOffset = kKindSpecificFlagsOffset; | 3483 static const int kOptimizableOffset = kKindSpecificFlagsOffset; |
| 3486 static const int kStackSlotsOffset = kKindSpecificFlagsOffset; | 3484 static const int kStackSlotsOffset = kKindSpecificFlagsOffset; |
| 3487 static const int kCheckTypeOffset = kKindSpecificFlagsOffset; | 3485 static const int kCheckTypeOffset = kKindSpecificFlagsOffset; |
| 3486 static const int kExternalArrayTypeOffset = kKindSpecificFlagsOffset; |
| 3488 | 3487 |
| 3489 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; | 3488 static const int kCompareStateOffset = kStubMajorKeyOffset + 1; |
| 3490 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; | 3489 static const int kBinaryOpTypeOffset = kStubMajorKeyOffset + 1; |
| 3491 static const int kHasDeoptimizationSupportOffset = kOptimizableOffset + 1; | 3490 static const int kHasDeoptimizationSupportOffset = kOptimizableOffset + 1; |
| 3492 | 3491 |
| 3493 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; | 3492 static const int kBinaryOpReturnTypeOffset = kBinaryOpTypeOffset + 1; |
| 3494 static const int kAllowOSRAtLoopNestingLevelOffset = | 3493 static const int kAllowOSRAtLoopNestingLevelOffset = |
| 3495 kHasDeoptimizationSupportOffset + 1; | 3494 kHasDeoptimizationSupportOffset + 1; |
| 3496 | 3495 |
| 3497 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; | 3496 static const int kSafepointTableOffsetOffset = kStackSlotsOffset + kIntSize; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3635 } else { | 3634 } else { |
| 3636 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); | 3635 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); |
| 3637 } | 3636 } |
| 3638 } | 3637 } |
| 3639 | 3638 |
| 3640 inline bool has_fast_elements() { | 3639 inline bool has_fast_elements() { |
| 3641 return ((1 << kHasFastElements) & bit_field2()) != 0; | 3640 return ((1 << kHasFastElements) & bit_field2()) != 0; |
| 3642 } | 3641 } |
| 3643 | 3642 |
| 3644 // Tells whether an instance has pixel array elements. | 3643 // Tells whether an instance has pixel array elements. |
| 3645 inline void set_has_pixel_array_elements(bool value) { | 3644 inline void set_has_external_array_elements(bool value) { |
| 3646 if (value) { | 3645 if (value) { |
| 3647 set_bit_field2(bit_field2() | (1 << kHasPixelArrayElements)); | 3646 set_bit_field2(bit_field2() | (1 << kHasExternalArrayElements)); |
| 3648 } else { | 3647 } else { |
| 3649 set_bit_field2(bit_field2() & ~(1 << kHasPixelArrayElements)); | 3648 set_bit_field2(bit_field2() & ~(1 << kHasExternalArrayElements)); |
| 3650 } | 3649 } |
| 3651 } | 3650 } |
| 3652 | 3651 |
| 3653 inline bool has_pixel_array_elements() { | 3652 inline bool has_external_array_elements() { |
| 3654 return ((1 << kHasPixelArrayElements) & bit_field2()) != 0; | 3653 return ((1 << kHasExternalArrayElements) & bit_field2()) != 0; |
| 3655 } | 3654 } |
| 3656 | 3655 |
| 3657 // Tells whether the map is attached to SharedFunctionInfo | 3656 // Tells whether the map is attached to SharedFunctionInfo |
| 3658 // (for inobject slack tracking). | 3657 // (for inobject slack tracking). |
| 3659 inline void set_attached_to_shared_function_info(bool value); | 3658 inline void set_attached_to_shared_function_info(bool value); |
| 3660 | 3659 |
| 3661 inline bool attached_to_shared_function_info(); | 3660 inline bool attached_to_shared_function_info(); |
| 3662 | 3661 |
| 3663 // Tells whether the map is shared between objects that may have different | 3662 // Tells whether the map is shared between objects that may have different |
| 3664 // behavior. If true, the map should never be modified, instead a clone | 3663 // behavior. If true, the map should never be modified, instead a clone |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3705 // Returns this map if it has the fast elements bit set, otherwise | 3704 // Returns this map if it has the fast elements bit set, otherwise |
| 3706 // returns a copy of the map, with all transitions dropped from the | 3705 // returns a copy of the map, with all transitions dropped from the |
| 3707 // descriptors and the fast elements bit set. | 3706 // descriptors and the fast elements bit set. |
| 3708 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); | 3707 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); |
| 3709 | 3708 |
| 3710 // Returns this map if it has the fast elements bit cleared, | 3709 // Returns this map if it has the fast elements bit cleared, |
| 3711 // otherwise returns a copy of the map, with all transitions dropped | 3710 // otherwise returns a copy of the map, with all transitions dropped |
| 3712 // from the descriptors and the fast elements bit cleared. | 3711 // from the descriptors and the fast elements bit cleared. |
| 3713 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); | 3712 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); |
| 3714 | 3713 |
| 3715 // Returns this map if it has the pixel array elements bit is set, otherwise | 3714 // Returns a new map with all transitions dropped from the descriptors and the |
| 3716 // returns a copy of the map, with all transitions dropped from the | 3715 // external array elements bit set. |
| 3717 // descriptors and the pixel array elements bit set. | 3716 MUST_USE_RESULT inline MaybeObject* NewExternalArrayElementsMap(); |
| 3718 MUST_USE_RESULT inline MaybeObject* GetPixelArrayElementsMap(); | |
| 3719 | 3717 |
| 3720 // Returns the property index for name (only valid for FAST MODE). | 3718 // Returns the property index for name (only valid for FAST MODE). |
| 3721 int PropertyIndexFor(String* name); | 3719 int PropertyIndexFor(String* name); |
| 3722 | 3720 |
| 3723 // Returns the next free property index (only valid for FAST MODE). | 3721 // Returns the next free property index (only valid for FAST MODE). |
| 3724 int NextFreePropertyIndex(); | 3722 int NextFreePropertyIndex(); |
| 3725 | 3723 |
| 3726 // Returns the number of properties described in instance_descriptors. | 3724 // Returns the number of properties described in instance_descriptors. |
| 3727 int NumberOfDescribedProperties(); | 3725 int NumberOfDescribedProperties(); |
| 3728 | 3726 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3831 static const int kHasInstanceCallHandler = 6; | 3829 static const int kHasInstanceCallHandler = 6; |
| 3832 static const int kIsAccessCheckNeeded = 7; | 3830 static const int kIsAccessCheckNeeded = 7; |
| 3833 | 3831 |
| 3834 // Bit positions for bit field 2 | 3832 // Bit positions for bit field 2 |
| 3835 static const int kIsExtensible = 0; | 3833 static const int kIsExtensible = 0; |
| 3836 static const int kFunctionWithPrototype = 1; | 3834 static const int kFunctionWithPrototype = 1; |
| 3837 static const int kHasFastElements = 2; | 3835 static const int kHasFastElements = 2; |
| 3838 static const int kStringWrapperSafeForDefaultValueOf = 3; | 3836 static const int kStringWrapperSafeForDefaultValueOf = 3; |
| 3839 static const int kAttachedToSharedFunctionInfo = 4; | 3837 static const int kAttachedToSharedFunctionInfo = 4; |
| 3840 static const int kIsShared = 5; | 3838 static const int kIsShared = 5; |
| 3841 static const int kHasPixelArrayElements = 6; | 3839 static const int kHasExternalArrayElements = 6; |
| 3842 | 3840 |
| 3843 // Layout of the default cache. It holds alternating name and code objects. | 3841 // Layout of the default cache. It holds alternating name and code objects. |
| 3844 static const int kCodeCacheEntrySize = 2; | 3842 static const int kCodeCacheEntrySize = 2; |
| 3845 static const int kCodeCacheEntryNameOffset = 0; | 3843 static const int kCodeCacheEntryNameOffset = 0; |
| 3846 static const int kCodeCacheEntryCodeOffset = 1; | 3844 static const int kCodeCacheEntryCodeOffset = 1; |
| 3847 | 3845 |
| 3848 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 3846 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
| 3849 kPointerFieldsEndOffset, | 3847 kPointerFieldsEndOffset, |
| 3850 kSize> BodyDescriptor; | 3848 kSize> BodyDescriptor; |
| 3851 | 3849 |
| (...skipping 2757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6609 } else { | 6607 } else { |
| 6610 value &= ~(1 << bit_position); | 6608 value &= ~(1 << bit_position); |
| 6611 } | 6609 } |
| 6612 return value; | 6610 return value; |
| 6613 } | 6611 } |
| 6614 }; | 6612 }; |
| 6615 | 6613 |
| 6616 } } // namespace v8::internal | 6614 } } // namespace v8::internal |
| 6617 | 6615 |
| 6618 #endif // V8_OBJECTS_H_ | 6616 #endif // V8_OBJECTS_H_ |
| OLD | NEW |