| 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" | |
| 45 #include "property.h" | 44 #include "property.h" |
| 46 #include "spaces.h" | 45 #include "spaces.h" |
| 47 #include "store-buffer.h" | 46 #include "store-buffer.h" |
| 48 #include "v8memory.h" | 47 #include "v8memory.h" |
| 49 #include "factory.h" | 48 #include "factory.h" |
| 50 #include "incremental-marking.h" | 49 #include "incremental-marking.h" |
| 51 #include "transitions-inl.h" | 50 #include "transitions-inl.h" |
| 52 #include "objects-visiting.h" | 51 #include "objects-visiting.h" |
| 53 | 52 |
| 54 namespace v8 { | 53 namespace v8 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 80 } | 79 } |
| 81 | 80 |
| 82 | 81 |
| 83 #define CAST_ACCESSOR(type) \ | 82 #define CAST_ACCESSOR(type) \ |
| 84 type* type::cast(Object* object) { \ | 83 type* type::cast(Object* object) { \ |
| 85 SLOW_ASSERT(object->Is##type()); \ | 84 SLOW_ASSERT(object->Is##type()); \ |
| 86 return reinterpret_cast<type*>(object); \ | 85 return reinterpret_cast<type*>(object); \ |
| 87 } | 86 } |
| 88 | 87 |
| 89 | 88 |
| 90 #define FIXED_TYPED_ARRAY_CAST_ACCESSOR(type) \ | |
| 91 template<> \ | |
| 92 type* type::cast(Object* object) { \ | |
| 93 SLOW_ASSERT(object->Is##type()); \ | |
| 94 return reinterpret_cast<type*>(object); \ | |
| 95 } | |
| 96 | |
| 97 #define INT_ACCESSORS(holder, name, offset) \ | 89 #define INT_ACCESSORS(holder, name, offset) \ |
| 98 int holder::name() { return READ_INT_FIELD(this, offset); } \ | 90 int holder::name() { return READ_INT_FIELD(this, offset); } \ |
| 99 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 91 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
| 100 | 92 |
| 101 | 93 |
| 102 #define ACCESSORS(holder, name, type, offset) \ | 94 #define ACCESSORS(holder, name, type, offset) \ |
| 103 type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \ | 95 type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \ |
| 104 void holder::set_##name(type* value, WriteBarrierMode mode) { \ | 96 void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
| 105 WRITE_FIELD(this, offset, value); \ | 97 WRITE_FIELD(this, offset, value); \ |
| 106 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ | 98 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 135 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 127 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
| 136 bool holder::name() { \ | 128 bool holder::name() { \ |
| 137 return BooleanBit::get(field(), offset); \ | 129 return BooleanBit::get(field(), offset); \ |
| 138 } \ | 130 } \ |
| 139 void holder::set_##name(bool value) { \ | 131 void holder::set_##name(bool value) { \ |
| 140 set_##field(BooleanBit::set(field(), offset, value)); \ | 132 set_##field(BooleanBit::set(field(), offset, value)); \ |
| 141 } | 133 } |
| 142 | 134 |
| 143 | 135 |
| 144 bool Object::IsFixedArrayBase() { | 136 bool Object::IsFixedArrayBase() { |
| 145 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray() || | 137 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray(); |
| 146 IsFixedTypedArrayBase() || IsExternalArray(); | |
| 147 } | 138 } |
| 148 | 139 |
| 149 | 140 |
| 150 // External objects are not extensible, so the map check is enough. | 141 // External objects are not extensible, so the map check is enough. |
| 151 bool Object::IsExternal() { | 142 bool Object::IsExternal() { |
| 152 return Object::IsHeapObject() && | 143 return Object::IsHeapObject() && |
| 153 HeapObject::cast(this)->map() == | 144 HeapObject::cast(this)->map() == |
| 154 HeapObject::cast(this)->GetHeap()->external_map(); | 145 HeapObject::cast(this)->GetHeap()->external_map(); |
| 155 } | 146 } |
| 156 | 147 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 255 |
| 265 | 256 |
| 266 bool Object::IsExternalTwoByteString() { | 257 bool Object::IsExternalTwoByteString() { |
| 267 if (!IsString()) return false; | 258 if (!IsString()) return false; |
| 268 return StringShape(String::cast(this)).IsExternal() && | 259 return StringShape(String::cast(this)).IsExternal() && |
| 269 String::cast(this)->IsTwoByteRepresentation(); | 260 String::cast(this)->IsTwoByteRepresentation(); |
| 270 } | 261 } |
| 271 | 262 |
| 272 bool Object::HasValidElements() { | 263 bool Object::HasValidElements() { |
| 273 // Dictionary is covered under FixedArray. | 264 // Dictionary is covered under FixedArray. |
| 274 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() || | 265 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); |
| 275 IsFixedTypedArrayBase(); | |
| 276 } | 266 } |
| 277 | 267 |
| 278 | 268 |
| 279 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, | 269 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, |
| 280 Representation representation) { | 270 Representation representation) { |
| 281 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { | 271 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { |
| 282 return Smi::FromInt(0); | 272 return Smi::FromInt(0); |
| 283 } | 273 } |
| 284 if (!FLAG_track_double_fields) return this; | 274 if (!FLAG_track_double_fields) return this; |
| 285 if (!representation.IsDouble()) return this; | 275 if (!representation.IsDouble()) return this; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) | 481 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) |
| 492 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) | 482 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) |
| 493 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) | 483 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) |
| 494 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) | 484 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) |
| 495 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) | 485 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) |
| 496 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) | 486 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
| 497 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) | 487 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) |
| 498 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) | 488 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) |
| 499 | 489 |
| 500 | 490 |
| 501 bool Object::IsFixedTypedArrayBase() { | |
| 502 if (!Object::IsHeapObject()) return false; | |
| 503 | |
| 504 InstanceType instance_type = | |
| 505 HeapObject::cast(this)->map()->instance_type(); | |
| 506 return (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | |
| 507 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE); | |
| 508 } | |
| 509 | |
| 510 | |
| 511 TYPE_CHECKER(FixedUint8Array, FIXED_UINT8_ARRAY_TYPE) | |
| 512 TYPE_CHECKER(FixedInt8Array, FIXED_INT8_ARRAY_TYPE) | |
| 513 TYPE_CHECKER(FixedUint16Array, FIXED_UINT16_ARRAY_TYPE) | |
| 514 TYPE_CHECKER(FixedInt16Array, FIXED_INT16_ARRAY_TYPE) | |
| 515 TYPE_CHECKER(FixedUint32Array, FIXED_UINT32_ARRAY_TYPE) | |
| 516 TYPE_CHECKER(FixedInt32Array, FIXED_INT32_ARRAY_TYPE) | |
| 517 TYPE_CHECKER(FixedFloat32Array, FIXED_FLOAT32_ARRAY_TYPE) | |
| 518 TYPE_CHECKER(FixedFloat64Array, FIXED_FLOAT64_ARRAY_TYPE) | |
| 519 TYPE_CHECKER(FixedUint8ClampedArray, FIXED_UINT8_CLAMPED_ARRAY_TYPE) | |
| 520 | |
| 521 | |
| 522 bool MaybeObject::IsFailure() { | 491 bool MaybeObject::IsFailure() { |
| 523 return HAS_FAILURE_TAG(this); | 492 return HAS_FAILURE_TAG(this); |
| 524 } | 493 } |
| 525 | 494 |
| 526 | 495 |
| 527 bool MaybeObject::IsRetryAfterGC() { | 496 bool MaybeObject::IsRetryAfterGC() { |
| 528 return HAS_FAILURE_TAG(this) | 497 return HAS_FAILURE_TAG(this) |
| 529 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; | 498 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; |
| 530 } | 499 } |
| 531 | 500 |
| (...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 IsTrue() || | 1948 IsTrue() || |
| 1980 IsFalse() || | 1949 IsFalse() || |
| 1981 IsNull())) { | 1950 IsNull())) { |
| 1982 FATAL("API call returned invalid object"); | 1951 FATAL("API call returned invalid object"); |
| 1983 } | 1952 } |
| 1984 #endif // ENABLE_EXTRA_CHECKS | 1953 #endif // ENABLE_EXTRA_CHECKS |
| 1985 } | 1954 } |
| 1986 | 1955 |
| 1987 | 1956 |
| 1988 FixedArrayBase* FixedArrayBase::cast(Object* object) { | 1957 FixedArrayBase* FixedArrayBase::cast(Object* object) { |
| 1989 ASSERT(object->IsFixedArrayBase()); | 1958 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() || |
| 1959 object->IsConstantPoolArray()); |
| 1990 return reinterpret_cast<FixedArrayBase*>(object); | 1960 return reinterpret_cast<FixedArrayBase*>(object); |
| 1991 } | 1961 } |
| 1992 | 1962 |
| 1993 | 1963 |
| 1994 Object* FixedArray::get(int index) { | 1964 Object* FixedArray::get(int index) { |
| 1995 SLOW_ASSERT(index >= 0 && index < this->length()); | 1965 SLOW_ASSERT(index >= 0 && index < this->length()); |
| 1996 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 1966 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
| 1997 } | 1967 } |
| 1998 | 1968 |
| 1999 | 1969 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2658 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 2628 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 2659 } | 2629 } |
| 2660 | 2630 |
| 2661 | 2631 |
| 2662 // ------------------------------------ | 2632 // ------------------------------------ |
| 2663 // Cast operations | 2633 // Cast operations |
| 2664 | 2634 |
| 2665 | 2635 |
| 2666 CAST_ACCESSOR(FixedArray) | 2636 CAST_ACCESSOR(FixedArray) |
| 2667 CAST_ACCESSOR(FixedDoubleArray) | 2637 CAST_ACCESSOR(FixedDoubleArray) |
| 2668 CAST_ACCESSOR(FixedTypedArrayBase) | |
| 2669 CAST_ACCESSOR(ConstantPoolArray) | 2638 CAST_ACCESSOR(ConstantPoolArray) |
| 2670 CAST_ACCESSOR(DescriptorArray) | 2639 CAST_ACCESSOR(DescriptorArray) |
| 2671 CAST_ACCESSOR(DeoptimizationInputData) | 2640 CAST_ACCESSOR(DeoptimizationInputData) |
| 2672 CAST_ACCESSOR(DeoptimizationOutputData) | 2641 CAST_ACCESSOR(DeoptimizationOutputData) |
| 2673 CAST_ACCESSOR(DependentCode) | 2642 CAST_ACCESSOR(DependentCode) |
| 2674 CAST_ACCESSOR(TypeFeedbackCells) | 2643 CAST_ACCESSOR(TypeFeedbackCells) |
| 2675 CAST_ACCESSOR(StringTable) | 2644 CAST_ACCESSOR(StringTable) |
| 2676 CAST_ACCESSOR(JSFunctionResultCache) | 2645 CAST_ACCESSOR(JSFunctionResultCache) |
| 2677 CAST_ACCESSOR(NormalizedMapCache) | 2646 CAST_ACCESSOR(NormalizedMapCache) |
| 2678 CAST_ACCESSOR(ScopeInfo) | 2647 CAST_ACCESSOR(ScopeInfo) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 CAST_ACCESSOR(ExternalShortArray) | 2697 CAST_ACCESSOR(ExternalShortArray) |
| 2729 CAST_ACCESSOR(ExternalUnsignedShortArray) | 2698 CAST_ACCESSOR(ExternalUnsignedShortArray) |
| 2730 CAST_ACCESSOR(ExternalIntArray) | 2699 CAST_ACCESSOR(ExternalIntArray) |
| 2731 CAST_ACCESSOR(ExternalUnsignedIntArray) | 2700 CAST_ACCESSOR(ExternalUnsignedIntArray) |
| 2732 CAST_ACCESSOR(ExternalFloatArray) | 2701 CAST_ACCESSOR(ExternalFloatArray) |
| 2733 CAST_ACCESSOR(ExternalDoubleArray) | 2702 CAST_ACCESSOR(ExternalDoubleArray) |
| 2734 CAST_ACCESSOR(ExternalPixelArray) | 2703 CAST_ACCESSOR(ExternalPixelArray) |
| 2735 CAST_ACCESSOR(Struct) | 2704 CAST_ACCESSOR(Struct) |
| 2736 CAST_ACCESSOR(AccessorInfo) | 2705 CAST_ACCESSOR(AccessorInfo) |
| 2737 | 2706 |
| 2738 template <class Traits> | |
| 2739 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { | |
| 2740 SLOW_ASSERT(object->IsHeapObject() && | |
| 2741 HeapObject::cast(object)->map()->instance_type() == | |
| 2742 Traits::kInstanceType); | |
| 2743 return reinterpret_cast<FixedTypedArray<Traits>*>(object); | |
| 2744 } | |
| 2745 | |
| 2746 | 2707 |
| 2747 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) | 2708 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) |
| 2748 STRUCT_LIST(MAKE_STRUCT_CAST) | 2709 STRUCT_LIST(MAKE_STRUCT_CAST) |
| 2749 #undef MAKE_STRUCT_CAST | 2710 #undef MAKE_STRUCT_CAST |
| 2750 | 2711 |
| 2751 | 2712 |
| 2752 template <typename Shape, typename Key> | 2713 template <typename Shape, typename Key> |
| 2753 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { | 2714 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { |
| 2754 ASSERT(obj->IsHashTable()); | 2715 ASSERT(obj->IsHashTable()); |
| 2755 return reinterpret_cast<HashTable*>(obj); | 2716 return reinterpret_cast<HashTable*>(obj); |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 } | 3472 } |
| 3512 | 3473 |
| 3513 | 3474 |
| 3514 void ExternalDoubleArray::set(int index, double value) { | 3475 void ExternalDoubleArray::set(int index, double value) { |
| 3515 ASSERT((index >= 0) && (index < this->length())); | 3476 ASSERT((index >= 0) && (index < this->length())); |
| 3516 double* ptr = static_cast<double*>(external_pointer()); | 3477 double* ptr = static_cast<double*>(external_pointer()); |
| 3517 ptr[index] = value; | 3478 ptr[index] = value; |
| 3518 } | 3479 } |
| 3519 | 3480 |
| 3520 | 3481 |
| 3521 int FixedTypedArrayBase::size() { | |
| 3522 InstanceType instance_type = map()->instance_type(); | |
| 3523 int element_size; | |
| 3524 switch (instance_type) { | |
| 3525 case FIXED_UINT8_ARRAY_TYPE: | |
| 3526 case FIXED_INT8_ARRAY_TYPE: | |
| 3527 case FIXED_UINT8_CLAMPED_ARRAY_TYPE: | |
| 3528 element_size = 1; | |
| 3529 break; | |
| 3530 case FIXED_UINT16_ARRAY_TYPE: | |
| 3531 case FIXED_INT16_ARRAY_TYPE: | |
| 3532 element_size = 2; | |
| 3533 break; | |
| 3534 case FIXED_UINT32_ARRAY_TYPE: | |
| 3535 case FIXED_INT32_ARRAY_TYPE: | |
| 3536 case FIXED_FLOAT32_ARRAY_TYPE: | |
| 3537 element_size = 4; | |
| 3538 break; | |
| 3539 case FIXED_FLOAT64_ARRAY_TYPE: | |
| 3540 element_size = 8; | |
| 3541 break; | |
| 3542 default: | |
| 3543 UNREACHABLE(); | |
| 3544 return 0; | |
| 3545 } | |
| 3546 return OBJECT_POINTER_ALIGN(kDataOffset + length() * element_size); | |
| 3547 } | |
| 3548 | |
| 3549 | |
| 3550 template <class Traits> | |
| 3551 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { | |
| 3552 ASSERT((index >= 0) && (index < this->length())); | |
| 3553 ElementType* ptr = reinterpret_cast<ElementType*>( | |
| 3554 FIELD_ADDR(this, kDataOffset)); | |
| 3555 return ptr[index]; | |
| 3556 } | |
| 3557 | |
| 3558 template <class Traits> | |
| 3559 void FixedTypedArray<Traits>::set(int index, ElementType value) { | |
| 3560 ASSERT((index >= 0) && (index < this->length())); | |
| 3561 ElementType* ptr = reinterpret_cast<ElementType*>( | |
| 3562 FIELD_ADDR(this, kDataOffset)); | |
| 3563 ptr[index] = value; | |
| 3564 } | |
| 3565 | |
| 3566 | |
| 3567 template <class Traits> | |
| 3568 MaybeObject* FixedTypedArray<Traits>::get(int index) { | |
| 3569 return Traits::ToObject(GetHeap(), get_scalar(index)); | |
| 3570 } | |
| 3571 | |
| 3572 template <class Traits> | |
| 3573 MaybeObject* FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) { | |
| 3574 ElementType cast_value = Traits::defaultValue(); | |
| 3575 if (index < static_cast<uint32_t>(length())) { | |
| 3576 if (value->IsSmi()) { | |
| 3577 int int_value = Smi::cast(value)->value(); | |
| 3578 cast_value = static_cast<ElementType>(int_value); | |
| 3579 } else if (value->IsHeapNumber()) { | |
| 3580 double double_value = HeapNumber::cast(value)->value(); | |
| 3581 cast_value = static_cast<ElementType>(DoubleToInt32(double_value)); | |
| 3582 } else { | |
| 3583 // Clamp undefined to the default value. All other types have been | |
| 3584 // converted to a number type further up in the call chain. | |
| 3585 ASSERT(value->IsUndefined()); | |
| 3586 } | |
| 3587 set(index, cast_value); | |
| 3588 } | |
| 3589 return Traits::ToObject(GetHeap(), cast_value); | |
| 3590 } | |
| 3591 | |
| 3592 template <class Traits> | |
| 3593 Handle<Object> FixedTypedArray<Traits>::SetValue( | |
| 3594 Handle<FixedTypedArray<Traits> > array, | |
| 3595 uint32_t index, | |
| 3596 Handle<Object> value) { | |
| 3597 CALL_HEAP_FUNCTION(array->GetIsolate(), | |
| 3598 array->SetValue(index, *value), | |
| 3599 Object); | |
| 3600 } | |
| 3601 | |
| 3602 | |
| 3603 MaybeObject* Uint8ArrayTraits::ToObject(Heap*, uint8_t scalar) { | |
| 3604 return Smi::FromInt(scalar); | |
| 3605 } | |
| 3606 | |
| 3607 | |
| 3608 MaybeObject* Uint8ClampedArrayTraits::ToObject(Heap*, uint8_t scalar) { | |
| 3609 return Smi::FromInt(scalar); | |
| 3610 } | |
| 3611 | |
| 3612 | |
| 3613 MaybeObject* Int8ArrayTraits::ToObject(Heap*, int8_t scalar) { | |
| 3614 return Smi::FromInt(scalar); | |
| 3615 } | |
| 3616 | |
| 3617 | |
| 3618 MaybeObject* Uint16ArrayTraits::ToObject(Heap*, uint16_t scalar) { | |
| 3619 return Smi::FromInt(scalar); | |
| 3620 } | |
| 3621 | |
| 3622 | |
| 3623 MaybeObject* Int16ArrayTraits::ToObject(Heap*, int16_t scalar) { | |
| 3624 return Smi::FromInt(scalar); | |
| 3625 } | |
| 3626 | |
| 3627 | |
| 3628 MaybeObject* Uint32ArrayTraits::ToObject(Heap* heap, uint32_t scalar) { | |
| 3629 return heap->NumberFromUint32(scalar); | |
| 3630 } | |
| 3631 | |
| 3632 | |
| 3633 MaybeObject* Int32ArrayTraits::ToObject(Heap* heap, int32_t scalar) { | |
| 3634 return heap->NumberFromInt32(scalar); | |
| 3635 } | |
| 3636 | |
| 3637 | |
| 3638 MaybeObject* Float32ArrayTraits::ToObject(Heap* heap, float scalar) { | |
| 3639 return heap->NumberFromDouble(scalar); | |
| 3640 } | |
| 3641 | |
| 3642 | |
| 3643 MaybeObject* Float64ArrayTraits::ToObject(Heap* heap, double scalar) { | |
| 3644 return heap->NumberFromDouble(scalar); | |
| 3645 } | |
| 3646 | |
| 3647 | |
| 3648 int Map::visitor_id() { | 3482 int Map::visitor_id() { |
| 3649 return READ_BYTE_FIELD(this, kVisitorIdOffset); | 3483 return READ_BYTE_FIELD(this, kVisitorIdOffset); |
| 3650 } | 3484 } |
| 3651 | 3485 |
| 3652 | 3486 |
| 3653 void Map::set_visitor_id(int id) { | 3487 void Map::set_visitor_id(int id) { |
| 3654 ASSERT(0 <= id && id < 256); | 3488 ASSERT(0 <= id && id < 256); |
| 3655 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); | 3489 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); |
| 3656 } | 3490 } |
| 3657 | 3491 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3698 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 3532 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 3699 return FixedDoubleArray::SizeFor( | 3533 return FixedDoubleArray::SizeFor( |
| 3700 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 3534 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
| 3701 } | 3535 } |
| 3702 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 3536 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
| 3703 return ConstantPoolArray::SizeFor( | 3537 return ConstantPoolArray::SizeFor( |
| 3704 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), | 3538 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), |
| 3705 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), | 3539 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), |
| 3706 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); | 3540 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); |
| 3707 } | 3541 } |
| 3708 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | |
| 3709 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | |
| 3710 return reinterpret_cast<FixedTypedArrayBase*>(this)->size(); | |
| 3711 } | |
| 3712 ASSERT(instance_type == CODE_TYPE); | 3542 ASSERT(instance_type == CODE_TYPE); |
| 3713 return reinterpret_cast<Code*>(this)->CodeSize(); | 3543 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 3714 } | 3544 } |
| 3715 | 3545 |
| 3716 | 3546 |
| 3717 void Map::set_instance_size(int value) { | 3547 void Map::set_instance_size(int value) { |
| 3718 ASSERT_EQ(0, value & (kPointerSize - 1)); | 3548 ASSERT_EQ(0, value & (kPointerSize - 1)); |
| 3719 value >>= kPointerSizeLog2; | 3549 value >>= kPointerSizeLog2; |
| 3720 ASSERT(0 <= value && value < 256); | 3550 ASSERT(0 <= value && value < 256); |
| 3721 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); | 3551 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); |
| (...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5870 EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) | 5700 EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) |
| 5871 EXTERNAL_ELEMENTS_CHECK(UnsignedInt, | 5701 EXTERNAL_ELEMENTS_CHECK(UnsignedInt, |
| 5872 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) | 5702 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
| 5873 EXTERNAL_ELEMENTS_CHECK(Float, | 5703 EXTERNAL_ELEMENTS_CHECK(Float, |
| 5874 EXTERNAL_FLOAT_ARRAY_TYPE) | 5704 EXTERNAL_FLOAT_ARRAY_TYPE) |
| 5875 EXTERNAL_ELEMENTS_CHECK(Double, | 5705 EXTERNAL_ELEMENTS_CHECK(Double, |
| 5876 EXTERNAL_DOUBLE_ARRAY_TYPE) | 5706 EXTERNAL_DOUBLE_ARRAY_TYPE) |
| 5877 EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) | 5707 EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) |
| 5878 | 5708 |
| 5879 | 5709 |
| 5880 bool JSObject::HasFixedTypedArrayElements() { | |
| 5881 HeapObject* array = elements(); | |
| 5882 ASSERT(array != NULL); | |
| 5883 return array->IsFixedTypedArrayBase(); | |
| 5884 } | |
| 5885 | |
| 5886 | |
| 5887 bool JSObject::HasNamedInterceptor() { | 5710 bool JSObject::HasNamedInterceptor() { |
| 5888 return map()->has_named_interceptor(); | 5711 return map()->has_named_interceptor(); |
| 5889 } | 5712 } |
| 5890 | 5713 |
| 5891 | 5714 |
| 5892 bool JSObject::HasIndexedInterceptor() { | 5715 bool JSObject::HasIndexedInterceptor() { |
| 5893 return map()->has_indexed_interceptor(); | 5716 return map()->has_indexed_interceptor(); |
| 5894 } | 5717 } |
| 5895 | 5718 |
| 5896 | 5719 |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6668 #undef WRITE_UINT32_FIELD | 6491 #undef WRITE_UINT32_FIELD |
| 6669 #undef READ_SHORT_FIELD | 6492 #undef READ_SHORT_FIELD |
| 6670 #undef WRITE_SHORT_FIELD | 6493 #undef WRITE_SHORT_FIELD |
| 6671 #undef READ_BYTE_FIELD | 6494 #undef READ_BYTE_FIELD |
| 6672 #undef WRITE_BYTE_FIELD | 6495 #undef WRITE_BYTE_FIELD |
| 6673 | 6496 |
| 6674 | 6497 |
| 6675 } } // namespace v8::internal | 6498 } } // namespace v8::internal |
| 6676 | 6499 |
| 6677 #endif // V8_OBJECTS_INL_H_ | 6500 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |