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

Side by Side Diff: src/objects.h

Issue 159263: - A prototype which allows to expose CanvasPixelArray functionality... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/jsregexp.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // - JSArray 45 // - JSArray
46 // - JSRegExp 46 // - JSRegExp
47 // - JSFunction 47 // - JSFunction
48 // - GlobalObject 48 // - GlobalObject
49 // - JSGlobalObject 49 // - JSGlobalObject
50 // - JSBuiltinsObject 50 // - JSBuiltinsObject
51 // - JSGlobalProxy 51 // - JSGlobalProxy
52 // - JSValue 52 // - JSValue
53 // - Array 53 // - Array
54 // - ByteArray 54 // - ByteArray
55 // - PixelArray
55 // - FixedArray 56 // - FixedArray
56 // - DescriptorArray 57 // - DescriptorArray
57 // - HashTable 58 // - HashTable
58 // - Dictionary 59 // - Dictionary
59 // - SymbolTable 60 // - SymbolTable
60 // - CompilationCacheTable 61 // - CompilationCacheTable
61 // - MapCache 62 // - MapCache
62 // - Context 63 // - Context
63 // - GlobalContext 64 // - GlobalContext
64 // - String 65 // - String
(...skipping 23 matching lines...) Expand all
88 // - SignatureInfo 89 // - SignatureInfo
89 // - TypeSwitchInfo 90 // - TypeSwitchInfo
90 // - DebugInfo 91 // - DebugInfo
91 // - BreakPointInfo 92 // - BreakPointInfo
92 // 93 //
93 // Formats of Object*: 94 // Formats of Object*:
94 // Smi: [31 bit signed int] 0 95 // Smi: [31 bit signed int] 0
95 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 96 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
96 // Failure: [30 bit signed int] 11 97 // Failure: [30 bit signed int] 11
97 98
98
99 // Ecma-262 3rd 8.6.1 99 // Ecma-262 3rd 8.6.1
100 enum PropertyAttributes { 100 enum PropertyAttributes {
101 NONE = v8::None, 101 NONE = v8::None,
102 READ_ONLY = v8::ReadOnly, 102 READ_ONLY = v8::ReadOnly,
103 DONT_ENUM = v8::DontEnum, 103 DONT_ENUM = v8::DontEnum,
104 DONT_DELETE = v8::DontDelete, 104 DONT_DELETE = v8::DontDelete,
105 ABSENT = 16 // Used in runtime to indicate a property is absent. 105 ABSENT = 16 // Used in runtime to indicate a property is absent.
106 // ABSENT can never be stored in or returned from a descriptor's attributes 106 // ABSENT can never be stored in or returned from a descriptor's attributes
107 // bitfield. It is only used as a return value meaning the attributes of 107 // bitfield. It is only used as a return value meaning the attributes of
108 // a non-existent property. 108 // a non-existent property.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ 263 V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \
264 \ 264 \
265 V(MAP_TYPE) \ 265 V(MAP_TYPE) \
266 V(HEAP_NUMBER_TYPE) \ 266 V(HEAP_NUMBER_TYPE) \
267 V(FIXED_ARRAY_TYPE) \ 267 V(FIXED_ARRAY_TYPE) \
268 V(CODE_TYPE) \ 268 V(CODE_TYPE) \
269 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ 269 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \
270 V(ODDBALL_TYPE) \ 270 V(ODDBALL_TYPE) \
271 V(PROXY_TYPE) \ 271 V(PROXY_TYPE) \
272 V(BYTE_ARRAY_TYPE) \ 272 V(BYTE_ARRAY_TYPE) \
273 V(PIXEL_ARRAY_TYPE) \
273 V(FILLER_TYPE) \ 274 V(FILLER_TYPE) \
274 \ 275 \
275 V(ACCESSOR_INFO_TYPE) \ 276 V(ACCESSOR_INFO_TYPE) \
276 V(ACCESS_CHECK_INFO_TYPE) \ 277 V(ACCESS_CHECK_INFO_TYPE) \
277 V(INTERCEPTOR_INFO_TYPE) \ 278 V(INTERCEPTOR_INFO_TYPE) \
278 V(SHARED_FUNCTION_INFO_TYPE) \ 279 V(SHARED_FUNCTION_INFO_TYPE) \
279 V(CALL_HANDLER_INFO_TYPE) \ 280 V(CALL_HANDLER_INFO_TYPE) \
280 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 281 V(FUNCTION_TEMPLATE_INFO_TYPE) \
281 V(OBJECT_TEMPLATE_INFO_TYPE) \ 282 V(OBJECT_TEMPLATE_INFO_TYPE) \
282 V(SIGNATURE_INFO_TYPE) \ 283 V(SIGNATURE_INFO_TYPE) \
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE = LONG_EXTERNAL_ASCII_STRING_TYPE, 653 LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE = LONG_EXTERNAL_ASCII_STRING_TYPE,
653 654
654 MAP_TYPE = kNotStringTag, 655 MAP_TYPE = kNotStringTag,
655 HEAP_NUMBER_TYPE, 656 HEAP_NUMBER_TYPE,
656 FIXED_ARRAY_TYPE, 657 FIXED_ARRAY_TYPE,
657 CODE_TYPE, 658 CODE_TYPE,
658 ODDBALL_TYPE, 659 ODDBALL_TYPE,
659 JS_GLOBAL_PROPERTY_CELL_TYPE, 660 JS_GLOBAL_PROPERTY_CELL_TYPE,
660 PROXY_TYPE, 661 PROXY_TYPE,
661 BYTE_ARRAY_TYPE, 662 BYTE_ARRAY_TYPE,
663 PIXEL_ARRAY_TYPE,
662 FILLER_TYPE, 664 FILLER_TYPE,
663 SMI_TYPE, 665 SMI_TYPE,
664 666
665 ACCESSOR_INFO_TYPE, 667 ACCESSOR_INFO_TYPE,
666 ACCESS_CHECK_INFO_TYPE, 668 ACCESS_CHECK_INFO_TYPE,
667 INTERCEPTOR_INFO_TYPE, 669 INTERCEPTOR_INFO_TYPE,
668 SHARED_FUNCTION_INFO_TYPE, 670 SHARED_FUNCTION_INFO_TYPE,
669 CALL_HANDLER_INFO_TYPE, 671 CALL_HANDLER_INFO_TYPE,
670 FUNCTION_TEMPLATE_INFO_TYPE, 672 FUNCTION_TEMPLATE_INFO_TYPE,
671 OBJECT_TEMPLATE_INFO_TYPE, 673 OBJECT_TEMPLATE_INFO_TYPE,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 inline bool IsSlicedString(); 755 inline bool IsSlicedString();
754 inline bool IsExternalString(); 756 inline bool IsExternalString();
755 inline bool IsConsString(); 757 inline bool IsConsString();
756 inline bool IsExternalTwoByteString(); 758 inline bool IsExternalTwoByteString();
757 inline bool IsExternalAsciiString(); 759 inline bool IsExternalAsciiString();
758 inline bool IsSeqTwoByteString(); 760 inline bool IsSeqTwoByteString();
759 inline bool IsSeqAsciiString(); 761 inline bool IsSeqAsciiString();
760 762
761 inline bool IsNumber(); 763 inline bool IsNumber();
762 inline bool IsByteArray(); 764 inline bool IsByteArray();
765 inline bool IsPixelArray();
763 inline bool IsFailure(); 766 inline bool IsFailure();
764 inline bool IsRetryAfterGC(); 767 inline bool IsRetryAfterGC();
765 inline bool IsOutOfMemoryFailure(); 768 inline bool IsOutOfMemoryFailure();
766 inline bool IsException(); 769 inline bool IsException();
767 inline bool IsJSObject(); 770 inline bool IsJSObject();
768 inline bool IsJSContextExtensionObject(); 771 inline bool IsJSContextExtensionObject();
769 inline bool IsMap(); 772 inline bool IsMap();
770 inline bool IsFixedArray(); 773 inline bool IsFixedArray();
771 inline bool IsDescriptorArray(); 774 inline bool IsDescriptorArray();
772 inline bool IsContext(); 775 inline bool IsContext();
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 }; 1298 };
1296 1299
1297 1300
1298 // The JSObject describes real heap allocated JavaScript objects with 1301 // The JSObject describes real heap allocated JavaScript objects with
1299 // properties. 1302 // properties.
1300 // Note that the map of JSObject changes during execution to enable inline 1303 // Note that the map of JSObject changes during execution to enable inline
1301 // caching. 1304 // caching.
1302 class JSObject: public HeapObject { 1305 class JSObject: public HeapObject {
1303 public: 1306 public:
1304 enum DeleteMode { NORMAL_DELETION, FORCE_DELETION }; 1307 enum DeleteMode { NORMAL_DELETION, FORCE_DELETION };
1308 enum ElementsKind {
1309 FAST_ELEMENTS,
1310 DICTIONARY_ELEMENTS,
1311 PIXEL_ELEMENTS
1312 };
1305 1313
1306 // [properties]: Backing storage for properties. 1314 // [properties]: Backing storage for properties.
1307 // properties is a FixedArray in the fast case, and a Dictionary in the 1315 // properties is a FixedArray in the fast case, and a Dictionary in the
1308 // slow case. 1316 // slow case.
1309 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. 1317 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties.
1310 inline void initialize_properties(); 1318 inline void initialize_properties();
1311 inline bool HasFastProperties(); 1319 inline bool HasFastProperties();
1312 inline StringDictionary* property_dictionary(); // Gets slow properties. 1320 inline StringDictionary* property_dictionary(); // Gets slow properties.
1313 1321
1314 // [elements]: The elements (properties with names that are integers). 1322 // [elements]: The elements (properties with names that are integers).
1315 // elements is a FixedArray in the fast case, and a Dictionary in the slow 1323 // elements is a FixedArray in the fast case, and a Dictionary in the slow
1316 // case. 1324 // case or a PixelArray in a special case.
1317 DECL_ACCESSORS(elements, FixedArray) // Get and set fast elements. 1325 DECL_ACCESSORS(elements, Array) // Get and set fast elements.
1318 inline void initialize_elements(); 1326 inline void initialize_elements();
1327 inline ElementsKind GetElementsKind();
1319 inline bool HasFastElements(); 1328 inline bool HasFastElements();
1329 inline bool HasDictionaryElements();
1330 inline bool HasPixelElements();
1320 inline NumberDictionary* element_dictionary(); // Gets slow elements. 1331 inline NumberDictionary* element_dictionary(); // Gets slow elements.
1321 1332
1322 // Collects elements starting at index 0. 1333 // Collects elements starting at index 0.
1323 // Undefined values are placed after non-undefined values. 1334 // Undefined values are placed after non-undefined values.
1324 // Returns the number of non-undefined values. 1335 // Returns the number of non-undefined values.
1325 Object* PrepareElementsForSort(uint32_t limit); 1336 Object* PrepareElementsForSort(uint32_t limit);
1326 // As PrepareElementsForSort, but only on objects where elements is 1337 // As PrepareElementsForSort, but only on objects where elements is
1327 // a dictionary, and it will stay a dictionary. 1338 // a dictionary, and it will stay a dictionary.
1328 Object* PrepareSlowElementsForSort(uint32_t limit); 1339 Object* PrepareSlowElementsForSort(uint32_t limit);
1329 1340
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 2444
2434 // ByteArray headers are not quadword aligned. 2445 // ByteArray headers are not quadword aligned.
2435 static const int kHeaderSize = Array::kHeaderSize; 2446 static const int kHeaderSize = Array::kHeaderSize;
2436 static const int kAlignedSize = Array::kAlignedSize; 2447 static const int kAlignedSize = Array::kAlignedSize;
2437 2448
2438 private: 2449 private:
2439 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); 2450 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
2440 }; 2451 };
2441 2452
2442 2453
2454 // PixelArray represents a fixed size byte array with special sematics used for
2455 // implementing the CanvasPixelArray object. Please see the specification at:
2456 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-elemen t.html#canvaspixelarray
2457 // In particular write access clamps the values to 0 or 255 if the value
2458 // used is outside this range.
2459 class PixelArray: public Array {
2460 public:
2461 // [external_pointer]: The pointer to the external memory area backing this
2462 // pixel array.
2463 DECL_ACCESSORS(external_pointer, uint8_t) // Pointer to the data store.
2464
2465 // Setter and getter.
2466 inline uint8_t get(int index);
2467 inline void set(int index, uint8_t value);
2468
2469 // This accessor applies the correct conversion from Smi, HeapNumber and
2470 // undefined and clamps the converted value between 0 and 255.
2471 Object* SetValue(uint32_t index, Object* value);
2472
2473 // Casting.
2474 static inline PixelArray* cast(Object* obj);
2475
2476 #ifdef DEBUG
2477 void PixelArrayPrint();
2478 void PixelArrayVerify();
2479 #endif // DEBUG
2480
2481 // PixelArray headers are not quadword aligned.
2482 static const int kExternalPointerOffset = Array::kAlignedSize;
2483 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
2484 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize);
2485
2486 private:
2487 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray);
2488 };
2489
2490
2443 // Code describes objects with on-the-fly generated machine code. 2491 // Code describes objects with on-the-fly generated machine code.
2444 class Code: public HeapObject { 2492 class Code: public HeapObject {
2445 public: 2493 public:
2446 // Opaque data type for encapsulating code flags like kind, inline 2494 // Opaque data type for encapsulating code flags like kind, inline
2447 // cache state, and arguments count. 2495 // cache state, and arguments count.
2448 enum Flags { }; 2496 enum Flags { };
2449 2497
2450 enum Kind { 2498 enum Kind {
2451 FUNCTION, 2499 FUNCTION,
2452 STUB, 2500 STUB,
(...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after
4747 } else { 4795 } else {
4748 value &= ~(1 << bit_position); 4796 value &= ~(1 << bit_position);
4749 } 4797 }
4750 return value; 4798 return value;
4751 } 4799 }
4752 }; 4800 };
4753 4801
4754 } } // namespace v8::internal 4802 } } // namespace v8::internal
4755 4803
4756 #endif // V8_OBJECTS_H_ 4804 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698