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

Side by Side Diff: src/objects-inl.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/objects-debug.cc ('k') | src/runtime.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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return IsSmi() || IsHeapNumber(); 314 return IsSmi() || IsHeapNumber();
315 } 315 }
316 316
317 317
318 bool Object::IsByteArray() { 318 bool Object::IsByteArray() {
319 return Object::IsHeapObject() 319 return Object::IsHeapObject()
320 && HeapObject::cast(this)->map()->instance_type() == BYTE_ARRAY_TYPE; 320 && HeapObject::cast(this)->map()->instance_type() == BYTE_ARRAY_TYPE;
321 } 321 }
322 322
323 323
324 bool Object::IsPixelArray() {
325 return Object::IsHeapObject() &&
326 HeapObject::cast(this)->map()->instance_type() == PIXEL_ARRAY_TYPE;
327 }
328
329
324 bool Object::IsFailure() { 330 bool Object::IsFailure() {
325 return HAS_FAILURE_TAG(this); 331 return HAS_FAILURE_TAG(this);
326 } 332 }
327 333
328 334
329 bool Object::IsRetryAfterGC() { 335 bool Object::IsRetryAfterGC() {
330 return HAS_FAILURE_TAG(this) 336 return HAS_FAILURE_TAG(this)
331 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; 337 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC;
332 } 338 }
333 339
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 return READ_DOUBLE_FIELD(this, kValueOffset); 1042 return READ_DOUBLE_FIELD(this, kValueOffset);
1037 } 1043 }
1038 1044
1039 1045
1040 void HeapNumber::set_value(double value) { 1046 void HeapNumber::set_value(double value) {
1041 WRITE_DOUBLE_FIELD(this, kValueOffset, value); 1047 WRITE_DOUBLE_FIELD(this, kValueOffset, value);
1042 } 1048 }
1043 1049
1044 1050
1045 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) 1051 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
1046 ACCESSORS(JSObject, elements, FixedArray, kElementsOffset) 1052
1053
1054 Array* JSObject::elements() {
1055 Object* array = READ_FIELD(this, kElementsOffset);
1056 // In the assert below Dictionary is covered under FixedArray.
1057 ASSERT(array->IsFixedArray() || array->IsPixelArray());
1058 return reinterpret_cast<Array*>(array);
1059 }
1060
1061
1062 void JSObject::set_elements(Array* value, WriteBarrierMode mode) {
1063 // In the assert below Dictionary is covered under FixedArray.
1064 ASSERT(value->IsFixedArray() || value->IsPixelArray());
1065 WRITE_FIELD(this, kElementsOffset, value);
1066 CONDITIONAL_WRITE_BARRIER(this, kElementsOffset, mode);
1067 }
1047 1068
1048 1069
1049 void JSObject::initialize_properties() { 1070 void JSObject::initialize_properties() {
1050 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); 1071 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
1051 WRITE_FIELD(this, kPropertiesOffset, Heap::empty_fixed_array()); 1072 WRITE_FIELD(this, kPropertiesOffset, Heap::empty_fixed_array());
1052 } 1073 }
1053 1074
1054 1075
1055 void JSObject::initialize_elements() { 1076 void JSObject::initialize_elements() {
1056 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); 1077 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 CAST_ACCESSOR(JSFunction) 1516 CAST_ACCESSOR(JSFunction)
1496 CAST_ACCESSOR(GlobalObject) 1517 CAST_ACCESSOR(GlobalObject)
1497 CAST_ACCESSOR(JSGlobalProxy) 1518 CAST_ACCESSOR(JSGlobalProxy)
1498 CAST_ACCESSOR(JSGlobalObject) 1519 CAST_ACCESSOR(JSGlobalObject)
1499 CAST_ACCESSOR(JSBuiltinsObject) 1520 CAST_ACCESSOR(JSBuiltinsObject)
1500 CAST_ACCESSOR(Code) 1521 CAST_ACCESSOR(Code)
1501 CAST_ACCESSOR(JSArray) 1522 CAST_ACCESSOR(JSArray)
1502 CAST_ACCESSOR(JSRegExp) 1523 CAST_ACCESSOR(JSRegExp)
1503 CAST_ACCESSOR(Proxy) 1524 CAST_ACCESSOR(Proxy)
1504 CAST_ACCESSOR(ByteArray) 1525 CAST_ACCESSOR(ByteArray)
1526 CAST_ACCESSOR(PixelArray)
1505 CAST_ACCESSOR(Struct) 1527 CAST_ACCESSOR(Struct)
1506 1528
1507 1529
1508 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) 1530 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name)
1509 STRUCT_LIST(MAKE_STRUCT_CAST) 1531 STRUCT_LIST(MAKE_STRUCT_CAST)
1510 #undef MAKE_STRUCT_CAST 1532 #undef MAKE_STRUCT_CAST
1511 1533
1512 1534
1513 template <typename Shape, typename Key> 1535 template <typename Shape, typename Key>
1514 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { 1536 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 ASSERT_TAG_ALIGNED(address); 1875 ASSERT_TAG_ALIGNED(address);
1854 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); 1876 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag);
1855 } 1877 }
1856 1878
1857 1879
1858 Address ByteArray::GetDataStartAddress() { 1880 Address ByteArray::GetDataStartAddress() {
1859 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; 1881 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
1860 } 1882 }
1861 1883
1862 1884
1885 uint8_t* PixelArray::external_pointer() {
1886 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
1887 return reinterpret_cast<uint8_t*>(ptr);
1888 }
1889
1890
1891 void PixelArray::set_external_pointer(uint8_t* value, WriteBarrierMode mode) {
1892 intptr_t ptr = reinterpret_cast<intptr_t>(value);
1893 WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr);
1894 }
1895
1896
1897 uint8_t PixelArray::get(int index) {
1898 ASSERT((index >= 0) && (index < this->length()));
1899 uint8_t* ptr = external_pointer();
1900 return ptr[index];
1901 }
1902
1903
1904 void PixelArray::set(int index, uint8_t value) {
1905 ASSERT((index >= 0) && (index < this->length()));
1906 uint8_t* ptr = external_pointer();
1907 ptr[index] = value;
1908 }
1909
1910
1863 int Map::instance_size() { 1911 int Map::instance_size() {
1864 return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2; 1912 return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2;
1865 } 1913 }
1866 1914
1867 1915
1868 int Map::inobject_properties() { 1916 int Map::inobject_properties() {
1869 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); 1917 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset);
1870 } 1918 }
1871 1919
1872 1920
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 } 2564 }
2517 2565
2518 2566
2519 void JSRegExp::SetDataAt(int index, Object* value) { 2567 void JSRegExp::SetDataAt(int index, Object* value) {
2520 ASSERT(TypeTag() != NOT_COMPILED); 2568 ASSERT(TypeTag() != NOT_COMPILED);
2521 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. 2569 ASSERT(index >= kDataIndex); // Only implementation data can be set this way.
2522 FixedArray::cast(data())->set(index, value); 2570 FixedArray::cast(data())->set(index, value);
2523 } 2571 }
2524 2572
2525 2573
2574 JSObject::ElementsKind JSObject::GetElementsKind() {
2575 Array* array = elements();
2576 if (array->IsFixedArray()) {
2577 // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a FixedArray.
2578 if (array->map() == Heap::fixed_array_map()) {
2579 return FAST_ELEMENTS;
2580 }
2581 ASSERT(array->IsDictionary());
2582 return DICTIONARY_ELEMENTS;
2583 }
2584 ASSERT(array->IsPixelArray());
2585 return PIXEL_ELEMENTS;
2586 }
2587
2588
2526 bool JSObject::HasFastElements() { 2589 bool JSObject::HasFastElements() {
2527 return !elements()->IsDictionary(); 2590 return GetElementsKind() == FAST_ELEMENTS;
2591 }
2592
2593
2594 bool JSObject::HasDictionaryElements() {
2595 return GetElementsKind() == DICTIONARY_ELEMENTS;
2596 }
2597
2598
2599 bool JSObject::HasPixelElements() {
2600 return GetElementsKind() == PIXEL_ELEMENTS;
2528 } 2601 }
2529 2602
2530 2603
2531 bool JSObject::HasNamedInterceptor() { 2604 bool JSObject::HasNamedInterceptor() {
2532 return map()->has_named_interceptor(); 2605 return map()->has_named_interceptor();
2533 } 2606 }
2534 2607
2535 2608
2536 bool JSObject::HasIndexedInterceptor() { 2609 bool JSObject::HasIndexedInterceptor() {
2537 return map()->has_indexed_interceptor(); 2610 return map()->has_indexed_interceptor();
2538 } 2611 }
2539 2612
2540 2613
2541 StringDictionary* JSObject::property_dictionary() { 2614 StringDictionary* JSObject::property_dictionary() {
2542 ASSERT(!HasFastProperties()); 2615 ASSERT(!HasFastProperties());
2543 return StringDictionary::cast(properties()); 2616 return StringDictionary::cast(properties());
2544 } 2617 }
2545 2618
2546 2619
2547 NumberDictionary* JSObject::element_dictionary() { 2620 NumberDictionary* JSObject::element_dictionary() {
2548 ASSERT(!HasFastElements()); 2621 ASSERT(HasDictionaryElements());
2549 return NumberDictionary::cast(elements()); 2622 return NumberDictionary::cast(elements());
2550 } 2623 }
2551 2624
2552 2625
2553 bool String::HasHashCode() { 2626 bool String::HasHashCode() {
2554 return (length_field() & kHashComputedMask) != 0; 2627 return (length_field() & kHashComputedMask) != 0;
2555 } 2628 }
2556 2629
2557 2630
2558 uint32_t String::Hash() { 2631 uint32_t String::Hash() {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 #undef WRITE_INT_FIELD 2842 #undef WRITE_INT_FIELD
2770 #undef READ_SHORT_FIELD 2843 #undef READ_SHORT_FIELD
2771 #undef WRITE_SHORT_FIELD 2844 #undef WRITE_SHORT_FIELD
2772 #undef READ_BYTE_FIELD 2845 #undef READ_BYTE_FIELD
2773 #undef WRITE_BYTE_FIELD 2846 #undef WRITE_BYTE_FIELD
2774 2847
2775 2848
2776 } } // namespace v8::internal 2849 } } // namespace v8::internal
2777 2850
2778 #endif // V8_OBJECTS_INL_H_ 2851 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698