OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 #ifndef V8_OBJECTS_INL_H_ | 35 #ifndef V8_OBJECTS_INL_H_ |
36 #define V8_OBJECTS_INL_H_ | 36 #define V8_OBJECTS_INL_H_ |
37 | 37 |
38 #include "elements.h" | 38 #include "elements.h" |
39 #include "objects.h" | 39 #include "objects.h" |
40 #include "contexts.h" | 40 #include "contexts.h" |
41 #include "conversions-inl.h" | 41 #include "conversions-inl.h" |
42 #include "heap.h" | 42 #include "heap.h" |
43 #include "isolate.h" | 43 #include "isolate.h" |
44 #include "heap-inl.h" | |
44 #include "property.h" | 45 #include "property.h" |
45 #include "spaces.h" | 46 #include "spaces.h" |
46 #include "store-buffer.h" | 47 #include "store-buffer.h" |
47 #include "v8memory.h" | 48 #include "v8memory.h" |
48 #include "factory.h" | 49 #include "factory.h" |
49 #include "incremental-marking.h" | 50 #include "incremental-marking.h" |
50 #include "transitions-inl.h" | 51 #include "transitions-inl.h" |
51 | 52 |
52 namespace v8 { | 53 namespace v8 { |
53 namespace internal { | 54 namespace internal { |
(...skipping 24 matching lines...) Expand all Loading... | |
78 } | 79 } |
79 | 80 |
80 | 81 |
81 #define CAST_ACCESSOR(type) \ | 82 #define CAST_ACCESSOR(type) \ |
82 type* type::cast(Object* object) { \ | 83 type* type::cast(Object* object) { \ |
83 SLOW_ASSERT(object->Is##type()); \ | 84 SLOW_ASSERT(object->Is##type()); \ |
84 return reinterpret_cast<type*>(object); \ | 85 return reinterpret_cast<type*>(object); \ |
85 } | 86 } |
86 | 87 |
87 | 88 |
89 #define FIXED_TYPED_ARRAY_CAST_ACCESSOR(type) \ | |
90 template<> \ | |
91 type* type::cast(Object* object) { \ | |
92 SLOW_ASSERT(object->Is##type()); \ | |
93 return reinterpret_cast<type*>(object); \ | |
94 } | |
95 | |
88 #define INT_ACCESSORS(holder, name, offset) \ | 96 #define INT_ACCESSORS(holder, name, offset) \ |
89 int holder::name() { return READ_INT_FIELD(this, offset); } \ | 97 int holder::name() { return READ_INT_FIELD(this, offset); } \ |
90 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 98 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
91 | 99 |
92 | 100 |
93 #define ACCESSORS(holder, name, type, offset) \ | 101 #define ACCESSORS(holder, name, type, offset) \ |
94 type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \ | 102 type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \ |
95 void holder::set_##name(type* value, WriteBarrierMode mode) { \ | 103 void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
96 WRITE_FIELD(this, offset, value); \ | 104 WRITE_FIELD(this, offset, value); \ |
97 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ | 105 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
(...skipping 28 matching lines...) Expand all Loading... | |
126 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 134 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
127 bool holder::name() { \ | 135 bool holder::name() { \ |
128 return BooleanBit::get(field(), offset); \ | 136 return BooleanBit::get(field(), offset); \ |
129 } \ | 137 } \ |
130 void holder::set_##name(bool value) { \ | 138 void holder::set_##name(bool value) { \ |
131 set_##field(BooleanBit::set(field(), offset, value)); \ | 139 set_##field(BooleanBit::set(field(), offset, value)); \ |
132 } | 140 } |
133 | 141 |
134 | 142 |
135 bool Object::IsFixedArrayBase() { | 143 bool Object::IsFixedArrayBase() { |
136 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray(); | 144 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray() |
145 || IsFixedTypedArrayBase() || IsExternalArray(); | |
Toon Verwaest
2013/12/23 10:40:32
|| on previous line.
Dmitry Lomov (no reviews)
2014/01/07 15:48:43
Done.
| |
137 } | 146 } |
138 | 147 |
139 | 148 |
140 // External objects are not extensible, so the map check is enough. | 149 // External objects are not extensible, so the map check is enough. |
141 bool Object::IsExternal() { | 150 bool Object::IsExternal() { |
142 return Object::IsHeapObject() && | 151 return Object::IsHeapObject() && |
143 HeapObject::cast(this)->map() == | 152 HeapObject::cast(this)->map() == |
144 HeapObject::cast(this)->GetHeap()->external_map(); | 153 HeapObject::cast(this)->GetHeap()->external_map(); |
145 } | 154 } |
146 | 155 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 | 263 |
255 | 264 |
256 bool Object::IsExternalTwoByteString() { | 265 bool Object::IsExternalTwoByteString() { |
257 if (!IsString()) return false; | 266 if (!IsString()) return false; |
258 return StringShape(String::cast(this)).IsExternal() && | 267 return StringShape(String::cast(this)).IsExternal() && |
259 String::cast(this)->IsTwoByteRepresentation(); | 268 String::cast(this)->IsTwoByteRepresentation(); |
260 } | 269 } |
261 | 270 |
262 bool Object::HasValidElements() { | 271 bool Object::HasValidElements() { |
263 // Dictionary is covered under FixedArray. | 272 // Dictionary is covered under FixedArray. |
264 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); | 273 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() |
274 || IsFixedTypedArrayBase(); | |
Toon Verwaest
2013/12/23 10:40:32
|| on previous line.
Dmitry Lomov (no reviews)
2014/01/07 15:48:43
Done.
| |
265 } | 275 } |
266 | 276 |
267 | 277 |
268 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, | 278 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, |
269 Representation representation) { | 279 Representation representation) { |
270 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { | 280 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { |
271 return Smi::FromInt(0); | 281 return Smi::FromInt(0); |
272 } | 282 } |
273 if (!FLAG_track_double_fields) return this; | 283 if (!FLAG_track_double_fields) return this; |
274 if (!representation.IsDouble()) return this; | 284 if (!representation.IsDouble()) return this; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) | 490 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) |
481 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) | 491 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) |
482 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) | 492 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) |
483 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) | 493 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) |
484 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) | 494 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) |
485 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) | 495 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
486 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) | 496 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) |
487 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) | 497 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) |
488 | 498 |
489 | 499 |
500 bool Object::IsFixedTypedArrayBase() { | |
501 if (!Object::IsHeapObject()) | |
502 return false; | |
503 InstanceType instance_type = | |
504 HeapObject::cast(this)->map()->instance_type(); | |
505 return (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | |
506 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE); | |
507 } | |
508 | |
509 | |
510 TYPE_CHECKER(FixedUint8Array, FIXED_UINT8_ARRAY_TYPE) | |
511 TYPE_CHECKER(FixedInt8Array, FIXED_INT8_ARRAY_TYPE) | |
512 TYPE_CHECKER(FixedUint16Array, FIXED_UINT16_ARRAY_TYPE) | |
513 TYPE_CHECKER(FixedInt16Array, FIXED_INT16_ARRAY_TYPE) | |
514 TYPE_CHECKER(FixedUint32Array, FIXED_UINT32_ARRAY_TYPE) | |
515 TYPE_CHECKER(FixedInt32Array, FIXED_INT32_ARRAY_TYPE) | |
516 TYPE_CHECKER(FixedFloat32Array, FIXED_FLOAT32_ARRAY_TYPE) | |
517 TYPE_CHECKER(FixedFloat64Array, FIXED_FLOAT64_ARRAY_TYPE) | |
518 TYPE_CHECKER(FixedUint8ClampedArray, FIXED_UINT8_CLAMPED_ARRAY_TYPE) | |
519 | |
520 | |
490 bool MaybeObject::IsFailure() { | 521 bool MaybeObject::IsFailure() { |
491 return HAS_FAILURE_TAG(this); | 522 return HAS_FAILURE_TAG(this); |
492 } | 523 } |
493 | 524 |
494 | 525 |
495 bool MaybeObject::IsRetryAfterGC() { | 526 bool MaybeObject::IsRetryAfterGC() { |
496 return HAS_FAILURE_TAG(this) | 527 return HAS_FAILURE_TAG(this) |
497 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; | 528 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; |
498 } | 529 } |
499 | 530 |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1934 IsTrue() || | 1965 IsTrue() || |
1935 IsFalse() || | 1966 IsFalse() || |
1936 IsNull())) { | 1967 IsNull())) { |
1937 FATAL("API call returned invalid object"); | 1968 FATAL("API call returned invalid object"); |
1938 } | 1969 } |
1939 #endif // ENABLE_EXTRA_CHECKS | 1970 #endif // ENABLE_EXTRA_CHECKS |
1940 } | 1971 } |
1941 | 1972 |
1942 | 1973 |
1943 FixedArrayBase* FixedArrayBase::cast(Object* object) { | 1974 FixedArrayBase* FixedArrayBase::cast(Object* object) { |
1944 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() || | 1975 ASSERT(object->IsFixedArrayBase()); |
1945 object->IsConstantPoolArray()); | |
1946 return reinterpret_cast<FixedArrayBase*>(object); | 1976 return reinterpret_cast<FixedArrayBase*>(object); |
1947 } | 1977 } |
1948 | 1978 |
1949 | 1979 |
1950 Object* FixedArray::get(int index) { | 1980 Object* FixedArray::get(int index) { |
1951 SLOW_ASSERT(index >= 0 && index < this->length()); | 1981 SLOW_ASSERT(index >= 0 && index < this->length()); |
1952 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 1982 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
1953 } | 1983 } |
1954 | 1984 |
1955 | 1985 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2618 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 2648 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
2619 } | 2649 } |
2620 | 2650 |
2621 | 2651 |
2622 // ------------------------------------ | 2652 // ------------------------------------ |
2623 // Cast operations | 2653 // Cast operations |
2624 | 2654 |
2625 | 2655 |
2626 CAST_ACCESSOR(FixedArray) | 2656 CAST_ACCESSOR(FixedArray) |
2627 CAST_ACCESSOR(FixedDoubleArray) | 2657 CAST_ACCESSOR(FixedDoubleArray) |
2658 CAST_ACCESSOR(FixedTypedArrayBase) | |
2628 CAST_ACCESSOR(ConstantPoolArray) | 2659 CAST_ACCESSOR(ConstantPoolArray) |
2629 CAST_ACCESSOR(DescriptorArray) | 2660 CAST_ACCESSOR(DescriptorArray) |
2630 CAST_ACCESSOR(DeoptimizationInputData) | 2661 CAST_ACCESSOR(DeoptimizationInputData) |
2631 CAST_ACCESSOR(DeoptimizationOutputData) | 2662 CAST_ACCESSOR(DeoptimizationOutputData) |
2632 CAST_ACCESSOR(DependentCode) | 2663 CAST_ACCESSOR(DependentCode) |
2633 CAST_ACCESSOR(TypeFeedbackCells) | 2664 CAST_ACCESSOR(TypeFeedbackCells) |
2634 CAST_ACCESSOR(StringTable) | 2665 CAST_ACCESSOR(StringTable) |
2635 CAST_ACCESSOR(JSFunctionResultCache) | 2666 CAST_ACCESSOR(JSFunctionResultCache) |
2636 CAST_ACCESSOR(NormalizedMapCache) | 2667 CAST_ACCESSOR(NormalizedMapCache) |
2637 CAST_ACCESSOR(ScopeInfo) | 2668 CAST_ACCESSOR(ScopeInfo) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2687 CAST_ACCESSOR(ExternalShortArray) | 2718 CAST_ACCESSOR(ExternalShortArray) |
2688 CAST_ACCESSOR(ExternalUnsignedShortArray) | 2719 CAST_ACCESSOR(ExternalUnsignedShortArray) |
2689 CAST_ACCESSOR(ExternalIntArray) | 2720 CAST_ACCESSOR(ExternalIntArray) |
2690 CAST_ACCESSOR(ExternalUnsignedIntArray) | 2721 CAST_ACCESSOR(ExternalUnsignedIntArray) |
2691 CAST_ACCESSOR(ExternalFloatArray) | 2722 CAST_ACCESSOR(ExternalFloatArray) |
2692 CAST_ACCESSOR(ExternalDoubleArray) | 2723 CAST_ACCESSOR(ExternalDoubleArray) |
2693 CAST_ACCESSOR(ExternalPixelArray) | 2724 CAST_ACCESSOR(ExternalPixelArray) |
2694 CAST_ACCESSOR(Struct) | 2725 CAST_ACCESSOR(Struct) |
2695 CAST_ACCESSOR(AccessorInfo) | 2726 CAST_ACCESSOR(AccessorInfo) |
2696 | 2727 |
2728 template <class Traits> | |
2729 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { | |
2730 SLOW_ASSERT(object->IsHeapObject() && | |
2731 HeapObject::cast(object)->map()->instance_type() | |
2732 == Traits::kInstanceType); | |
2733 return reinterpret_cast<FixedTypedArray<Traits>*>(object); | |
2734 } | |
2735 | |
2697 | 2736 |
2698 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) | 2737 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) |
2699 STRUCT_LIST(MAKE_STRUCT_CAST) | 2738 STRUCT_LIST(MAKE_STRUCT_CAST) |
2700 #undef MAKE_STRUCT_CAST | 2739 #undef MAKE_STRUCT_CAST |
2701 | 2740 |
2702 | 2741 |
2703 template <typename Shape, typename Key> | 2742 template <typename Shape, typename Key> |
2704 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { | 2743 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { |
2705 ASSERT(obj->IsHashTable()); | 2744 ASSERT(obj->IsHashTable()); |
2706 return reinterpret_cast<HashTable*>(obj); | 2745 return reinterpret_cast<HashTable*>(obj); |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3462 } | 3501 } |
3463 | 3502 |
3464 | 3503 |
3465 void ExternalDoubleArray::set(int index, double value) { | 3504 void ExternalDoubleArray::set(int index, double value) { |
3466 ASSERT((index >= 0) && (index < this->length())); | 3505 ASSERT((index >= 0) && (index < this->length())); |
3467 double* ptr = static_cast<double*>(external_pointer()); | 3506 double* ptr = static_cast<double*>(external_pointer()); |
3468 ptr[index] = value; | 3507 ptr[index] = value; |
3469 } | 3508 } |
3470 | 3509 |
3471 | 3510 |
3511 int FixedTypedArrayBase::size() { | |
3512 InstanceType instance_type = map()->instance_type(); | |
3513 int element_size; | |
3514 switch (instance_type) { | |
3515 case FIXED_UINT8_ARRAY_TYPE: | |
3516 case FIXED_INT8_ARRAY_TYPE: | |
3517 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: | |
3518 element_size = 1; | |
3519 break; | |
3520 case FIXED_UINT16_ARRAY_TYPE: | |
3521 case FIXED_INT16_ARRAY_TYPE: | |
3522 element_size = 2; | |
3523 break; | |
3524 case FIXED_UINT32_ARRAY_TYPE: | |
3525 case FIXED_INT32_ARRAY_TYPE: | |
3526 case FIXED_FLOAT32_ARRAY_TYPE: | |
3527 element_size = 4; | |
3528 break; | |
3529 case FIXED_FLOAT64_ARRAY_TYPE: | |
3530 element_size = 8; | |
3531 break; | |
3532 default: | |
3533 UNREACHABLE(); | |
3534 return 0; | |
3535 } | |
3536 return kDataOffset + length() * element_size; | |
3537 } | |
3538 | |
3539 | |
3540 template <class Traits> | |
3541 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { | |
3542 ASSERT((index >= 0) && (index < this->length())); | |
3543 ElementType* ptr = reinterpret_cast<ElementType*>( | |
3544 FIELD_ADDR(this, kDataOffset)); | |
3545 return ptr[index]; | |
3546 } | |
3547 | |
3548 template <class Traits> | |
3549 void FixedTypedArray<Traits>::set(int index, ElementType value) { | |
3550 ASSERT((index >= 0) && (index < this->length())); | |
3551 ElementType* ptr = reinterpret_cast<ElementType*>( | |
3552 FIELD_ADDR(this, kDataOffset)); | |
3553 ptr[index] = value; | |
3554 } | |
3555 | |
3556 | |
3557 template <class Traits> | |
3558 MaybeObject* FixedTypedArray<Traits>::get(int index) { | |
3559 return Traits::ToObject(GetHeap(), get_scalar(index)); | |
3560 } | |
3561 | |
3562 template <class Traits> | |
3563 MaybeObject* FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) { | |
3564 ElementType cast_value = Traits::defaultValue(); | |
3565 if (index < static_cast<uint32_t>(length())) { | |
3566 if (value->IsSmi()) { | |
3567 int int_value = Smi::cast(value)->value(); | |
3568 cast_value = static_cast<ElementType>(int_value); | |
3569 } else if (value->IsHeapNumber()) { | |
3570 double double_value = HeapNumber::cast(value)->value(); | |
3571 cast_value = static_cast<ElementType>(DoubleToInt32(double_value)); | |
3572 } else { | |
3573 // Clamp undefined to zero (default). All other types have been | |
Toon Verwaest
2013/12/23 10:40:32
I'd just write "Clamp undefined to the default val
Dmitry Lomov (no reviews)
2014/01/07 15:48:43
Done.
| |
3574 // converted to a number type further up in the call chain. | |
3575 ASSERT(value->IsUndefined()); | |
3576 } | |
3577 set(index, cast_value); | |
3578 } | |
3579 return Traits::ToObject(GetHeap(), cast_value); | |
3580 } | |
3581 | |
3582 template <class Traits> | |
3583 Handle<Object> FixedTypedArray<Traits>::SetValue( | |
3584 Handle<FixedTypedArray<Traits> > array, | |
3585 uint32_t index, | |
3586 Handle<Object> value) { | |
3587 CALL_HEAP_FUNCTION(array->GetIsolate(), | |
3588 array->SetValue(index, *value), | |
3589 Object); | |
3590 } | |
3591 | |
3592 | |
3593 MaybeObject* Uint8ArrayTraits::ToObject(Heap*, uint8_t scalar) { | |
3594 return Smi::FromInt(scalar); | |
3595 } | |
3596 | |
3597 | |
3598 MaybeObject* Uint8ClampedArrayTraits::ToObject(Heap*, uint8_t scalar) { | |
3599 return Smi::FromInt(scalar); | |
3600 } | |
3601 | |
3602 | |
3603 MaybeObject* Int8ArrayTraits::ToObject(Heap*, int8_t scalar) { | |
3604 return Smi::FromInt(scalar); | |
3605 } | |
3606 | |
3607 | |
3608 MaybeObject* Uint16ArrayTraits::ToObject(Heap*, uint16_t scalar) { | |
3609 return Smi::FromInt(scalar); | |
3610 } | |
3611 | |
3612 | |
3613 MaybeObject* Int16ArrayTraits::ToObject(Heap*, int16_t scalar) { | |
3614 return Smi::FromInt(scalar); | |
3615 } | |
3616 | |
3617 | |
3618 MaybeObject* Uint32ArrayTraits::ToObject(Heap* heap, uint32_t scalar) { | |
3619 return heap->NumberFromUint32(scalar); | |
3620 } | |
3621 | |
3622 | |
3623 MaybeObject* Int32ArrayTraits::ToObject(Heap* heap, int32_t scalar) { | |
3624 return heap->NumberFromInt32(scalar); | |
3625 } | |
3626 | |
3627 | |
3628 MaybeObject* Float32ArrayTraits::ToObject(Heap* heap, float scalar) { | |
3629 return heap->NumberFromDouble(scalar); | |
3630 } | |
3631 | |
3632 | |
3633 MaybeObject* Float64ArrayTraits::ToObject(Heap* heap, double scalar) { | |
3634 return heap->NumberFromDouble(scalar); | |
3635 } | |
3636 | |
3637 | |
3472 int Map::visitor_id() { | 3638 int Map::visitor_id() { |
3473 return READ_BYTE_FIELD(this, kVisitorIdOffset); | 3639 return READ_BYTE_FIELD(this, kVisitorIdOffset); |
3474 } | 3640 } |
3475 | 3641 |
3476 | 3642 |
3477 void Map::set_visitor_id(int id) { | 3643 void Map::set_visitor_id(int id) { |
3478 ASSERT(0 <= id && id < 256); | 3644 ASSERT(0 <= id && id < 256); |
3479 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); | 3645 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); |
3480 } | 3646 } |
3481 | 3647 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3522 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 3688 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
3523 return FixedDoubleArray::SizeFor( | 3689 return FixedDoubleArray::SizeFor( |
3524 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 3690 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
3525 } | 3691 } |
3526 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 3692 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
3527 return ConstantPoolArray::SizeFor( | 3693 return ConstantPoolArray::SizeFor( |
3528 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), | 3694 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), |
3529 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), | 3695 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), |
3530 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); | 3696 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); |
3531 } | 3697 } |
3698 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | |
3699 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | |
3700 return reinterpret_cast<FixedTypedArrayBase*>(this)->size(); | |
3701 } | |
3532 ASSERT(instance_type == CODE_TYPE); | 3702 ASSERT(instance_type == CODE_TYPE); |
3533 return reinterpret_cast<Code*>(this)->CodeSize(); | 3703 return reinterpret_cast<Code*>(this)->CodeSize(); |
3534 } | 3704 } |
3535 | 3705 |
3536 | 3706 |
3537 void Map::set_instance_size(int value) { | 3707 void Map::set_instance_size(int value) { |
3538 ASSERT_EQ(0, value & (kPointerSize - 1)); | 3708 ASSERT_EQ(0, value & (kPointerSize - 1)); |
3539 value >>= kPointerSizeLog2; | 3709 value >>= kPointerSizeLog2; |
3540 ASSERT(0 <= value && value < 256); | 3710 ASSERT(0 <= value && value < 256); |
3541 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); | 3711 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); |
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5673 EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) | 5843 EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) |
5674 EXTERNAL_ELEMENTS_CHECK(UnsignedInt, | 5844 EXTERNAL_ELEMENTS_CHECK(UnsignedInt, |
5675 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) | 5845 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
5676 EXTERNAL_ELEMENTS_CHECK(Float, | 5846 EXTERNAL_ELEMENTS_CHECK(Float, |
5677 EXTERNAL_FLOAT_ARRAY_TYPE) | 5847 EXTERNAL_FLOAT_ARRAY_TYPE) |
5678 EXTERNAL_ELEMENTS_CHECK(Double, | 5848 EXTERNAL_ELEMENTS_CHECK(Double, |
5679 EXTERNAL_DOUBLE_ARRAY_TYPE) | 5849 EXTERNAL_DOUBLE_ARRAY_TYPE) |
5680 EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) | 5850 EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) |
5681 | 5851 |
5682 | 5852 |
5853 bool JSObject::HasFixedTypedArrayElements() { | |
5854 HeapObject* array = elements(); | |
5855 ASSERT(array != NULL); | |
5856 return array->IsFixedTypedArrayBase(); | |
5857 } | |
5858 | |
5859 | |
5683 bool JSObject::HasNamedInterceptor() { | 5860 bool JSObject::HasNamedInterceptor() { |
5684 return map()->has_named_interceptor(); | 5861 return map()->has_named_interceptor(); |
5685 } | 5862 } |
5686 | 5863 |
5687 | 5864 |
5688 bool JSObject::HasIndexedInterceptor() { | 5865 bool JSObject::HasIndexedInterceptor() { |
5689 return map()->has_indexed_interceptor(); | 5866 return map()->has_indexed_interceptor(); |
5690 } | 5867 } |
5691 | 5868 |
5692 | 5869 |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6464 #undef WRITE_UINT32_FIELD | 6641 #undef WRITE_UINT32_FIELD |
6465 #undef READ_SHORT_FIELD | 6642 #undef READ_SHORT_FIELD |
6466 #undef WRITE_SHORT_FIELD | 6643 #undef WRITE_SHORT_FIELD |
6467 #undef READ_BYTE_FIELD | 6644 #undef READ_BYTE_FIELD |
6468 #undef WRITE_BYTE_FIELD | 6645 #undef WRITE_BYTE_FIELD |
6469 | 6646 |
6470 | 6647 |
6471 } } // namespace v8::internal | 6648 } } // namespace v8::internal |
6472 | 6649 |
6473 #endif // V8_OBJECTS_INL_H_ | 6650 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |