| 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 #include "objects-visiting.h" | 52 #include "objects-visiting.h" |
| 52 | 53 |
| 53 namespace v8 { | 54 namespace v8 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 79 } | 80 } |
| 80 | 81 |
| 81 | 82 |
| 82 #define CAST_ACCESSOR(type) \ | 83 #define CAST_ACCESSOR(type) \ |
| 83 type* type::cast(Object* object) { \ | 84 type* type::cast(Object* object) { \ |
| 84 SLOW_ASSERT(object->Is##type()); \ | 85 SLOW_ASSERT(object->Is##type()); \ |
| 85 return reinterpret_cast<type*>(object); \ | 86 return reinterpret_cast<type*>(object); \ |
| 86 } | 87 } |
| 87 | 88 |
| 88 | 89 |
| 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 |
| 89 #define INT_ACCESSORS(holder, name, offset) \ | 97 #define INT_ACCESSORS(holder, name, offset) \ |
| 90 int holder::name() { return READ_INT_FIELD(this, offset); } \ | 98 int holder::name() { return READ_INT_FIELD(this, offset); } \ |
| 91 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 99 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
| 92 | 100 |
| 93 | 101 |
| 94 #define ACCESSORS(holder, name, type, offset) \ | 102 #define ACCESSORS(holder, name, type, offset) \ |
| 95 type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \ | 103 type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \ |
| 96 void holder::set_##name(type* value, WriteBarrierMode mode) { \ | 104 void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
| 97 WRITE_FIELD(this, offset, value); \ | 105 WRITE_FIELD(this, offset, value); \ |
| 98 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ | 106 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 127 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 135 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
| 128 bool holder::name() { \ | 136 bool holder::name() { \ |
| 129 return BooleanBit::get(field(), offset); \ | 137 return BooleanBit::get(field(), offset); \ |
| 130 } \ | 138 } \ |
| 131 void holder::set_##name(bool value) { \ | 139 void holder::set_##name(bool value) { \ |
| 132 set_##field(BooleanBit::set(field(), offset, value)); \ | 140 set_##field(BooleanBit::set(field(), offset, value)); \ |
| 133 } | 141 } |
| 134 | 142 |
| 135 | 143 |
| 136 bool Object::IsFixedArrayBase() { | 144 bool Object::IsFixedArrayBase() { |
| 137 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray(); | 145 return IsFixedArray() || IsFixedDoubleArray() || IsConstantPoolArray() || |
| 146 IsFixedTypedArrayBase() || IsExternalArray(); |
| 138 } | 147 } |
| 139 | 148 |
| 140 | 149 |
| 141 // External objects are not extensible, so the map check is enough. | 150 // External objects are not extensible, so the map check is enough. |
| 142 bool Object::IsExternal() { | 151 bool Object::IsExternal() { |
| 143 return Object::IsHeapObject() && | 152 return Object::IsHeapObject() && |
| 144 HeapObject::cast(this)->map() == | 153 HeapObject::cast(this)->map() == |
| 145 HeapObject::cast(this)->GetHeap()->external_map(); | 154 HeapObject::cast(this)->GetHeap()->external_map(); |
| 146 } | 155 } |
| 147 | 156 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 264 |
| 256 | 265 |
| 257 bool Object::IsExternalTwoByteString() { | 266 bool Object::IsExternalTwoByteString() { |
| 258 if (!IsString()) return false; | 267 if (!IsString()) return false; |
| 259 return StringShape(String::cast(this)).IsExternal() && | 268 return StringShape(String::cast(this)).IsExternal() && |
| 260 String::cast(this)->IsTwoByteRepresentation(); | 269 String::cast(this)->IsTwoByteRepresentation(); |
| 261 } | 270 } |
| 262 | 271 |
| 263 bool Object::HasValidElements() { | 272 bool Object::HasValidElements() { |
| 264 // Dictionary is covered under FixedArray. | 273 // Dictionary is covered under FixedArray. |
| 265 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); | 274 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() || |
| 275 IsFixedTypedArrayBase(); |
| 266 } | 276 } |
| 267 | 277 |
| 268 | 278 |
| 269 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, | 279 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, |
| 270 Representation representation) { | 280 Representation representation) { |
| 271 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { | 281 if (FLAG_track_fields && representation.IsSmi() && IsUninitialized()) { |
| 272 return Smi::FromInt(0); | 282 return Smi::FromInt(0); |
| 273 } | 283 } |
| 274 if (!FLAG_track_double_fields) return this; | 284 if (!FLAG_track_double_fields) return this; |
| 275 if (!representation.IsDouble()) return this; | 285 if (!representation.IsDouble()) return this; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) | 491 TYPE_CHECKER(ExternalByteArray, EXTERNAL_BYTE_ARRAY_TYPE) |
| 482 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) | 492 TYPE_CHECKER(ExternalUnsignedByteArray, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) |
| 483 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) | 493 TYPE_CHECKER(ExternalShortArray, EXTERNAL_SHORT_ARRAY_TYPE) |
| 484 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) | 494 TYPE_CHECKER(ExternalUnsignedShortArray, EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) |
| 485 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) | 495 TYPE_CHECKER(ExternalIntArray, EXTERNAL_INT_ARRAY_TYPE) |
| 486 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) | 496 TYPE_CHECKER(ExternalUnsignedIntArray, EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
| 487 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) | 497 TYPE_CHECKER(ExternalFloatArray, EXTERNAL_FLOAT_ARRAY_TYPE) |
| 488 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) | 498 TYPE_CHECKER(ExternalDoubleArray, EXTERNAL_DOUBLE_ARRAY_TYPE) |
| 489 | 499 |
| 490 | 500 |
| 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 |
| 491 bool MaybeObject::IsFailure() { | 522 bool MaybeObject::IsFailure() { |
| 492 return HAS_FAILURE_TAG(this); | 523 return HAS_FAILURE_TAG(this); |
| 493 } | 524 } |
| 494 | 525 |
| 495 | 526 |
| 496 bool MaybeObject::IsRetryAfterGC() { | 527 bool MaybeObject::IsRetryAfterGC() { |
| 497 return HAS_FAILURE_TAG(this) | 528 return HAS_FAILURE_TAG(this) |
| 498 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; | 529 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; |
| 499 } | 530 } |
| 500 | 531 |
| (...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1948 IsTrue() || | 1979 IsTrue() || |
| 1949 IsFalse() || | 1980 IsFalse() || |
| 1950 IsNull())) { | 1981 IsNull())) { |
| 1951 FATAL("API call returned invalid object"); | 1982 FATAL("API call returned invalid object"); |
| 1952 } | 1983 } |
| 1953 #endif // ENABLE_EXTRA_CHECKS | 1984 #endif // ENABLE_EXTRA_CHECKS |
| 1954 } | 1985 } |
| 1955 | 1986 |
| 1956 | 1987 |
| 1957 FixedArrayBase* FixedArrayBase::cast(Object* object) { | 1988 FixedArrayBase* FixedArrayBase::cast(Object* object) { |
| 1958 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray() || | 1989 ASSERT(object->IsFixedArrayBase()); |
| 1959 object->IsConstantPoolArray()); | |
| 1960 return reinterpret_cast<FixedArrayBase*>(object); | 1990 return reinterpret_cast<FixedArrayBase*>(object); |
| 1961 } | 1991 } |
| 1962 | 1992 |
| 1963 | 1993 |
| 1964 Object* FixedArray::get(int index) { | 1994 Object* FixedArray::get(int index) { |
| 1965 SLOW_ASSERT(index >= 0 && index < this->length()); | 1995 SLOW_ASSERT(index >= 0 && index < this->length()); |
| 1966 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 1996 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
| 1967 } | 1997 } |
| 1968 | 1998 |
| 1969 | 1999 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 2658 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 2629 } | 2659 } |
| 2630 | 2660 |
| 2631 | 2661 |
| 2632 // ------------------------------------ | 2662 // ------------------------------------ |
| 2633 // Cast operations | 2663 // Cast operations |
| 2634 | 2664 |
| 2635 | 2665 |
| 2636 CAST_ACCESSOR(FixedArray) | 2666 CAST_ACCESSOR(FixedArray) |
| 2637 CAST_ACCESSOR(FixedDoubleArray) | 2667 CAST_ACCESSOR(FixedDoubleArray) |
| 2668 CAST_ACCESSOR(FixedTypedArrayBase) |
| 2638 CAST_ACCESSOR(ConstantPoolArray) | 2669 CAST_ACCESSOR(ConstantPoolArray) |
| 2639 CAST_ACCESSOR(DescriptorArray) | 2670 CAST_ACCESSOR(DescriptorArray) |
| 2640 CAST_ACCESSOR(DeoptimizationInputData) | 2671 CAST_ACCESSOR(DeoptimizationInputData) |
| 2641 CAST_ACCESSOR(DeoptimizationOutputData) | 2672 CAST_ACCESSOR(DeoptimizationOutputData) |
| 2642 CAST_ACCESSOR(DependentCode) | 2673 CAST_ACCESSOR(DependentCode) |
| 2643 CAST_ACCESSOR(TypeFeedbackCells) | 2674 CAST_ACCESSOR(TypeFeedbackCells) |
| 2644 CAST_ACCESSOR(StringTable) | 2675 CAST_ACCESSOR(StringTable) |
| 2645 CAST_ACCESSOR(JSFunctionResultCache) | 2676 CAST_ACCESSOR(JSFunctionResultCache) |
| 2646 CAST_ACCESSOR(NormalizedMapCache) | 2677 CAST_ACCESSOR(NormalizedMapCache) |
| 2647 CAST_ACCESSOR(ScopeInfo) | 2678 CAST_ACCESSOR(ScopeInfo) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2697 CAST_ACCESSOR(ExternalShortArray) | 2728 CAST_ACCESSOR(ExternalShortArray) |
| 2698 CAST_ACCESSOR(ExternalUnsignedShortArray) | 2729 CAST_ACCESSOR(ExternalUnsignedShortArray) |
| 2699 CAST_ACCESSOR(ExternalIntArray) | 2730 CAST_ACCESSOR(ExternalIntArray) |
| 2700 CAST_ACCESSOR(ExternalUnsignedIntArray) | 2731 CAST_ACCESSOR(ExternalUnsignedIntArray) |
| 2701 CAST_ACCESSOR(ExternalFloatArray) | 2732 CAST_ACCESSOR(ExternalFloatArray) |
| 2702 CAST_ACCESSOR(ExternalDoubleArray) | 2733 CAST_ACCESSOR(ExternalDoubleArray) |
| 2703 CAST_ACCESSOR(ExternalPixelArray) | 2734 CAST_ACCESSOR(ExternalPixelArray) |
| 2704 CAST_ACCESSOR(Struct) | 2735 CAST_ACCESSOR(Struct) |
| 2705 CAST_ACCESSOR(AccessorInfo) | 2736 CAST_ACCESSOR(AccessorInfo) |
| 2706 | 2737 |
| 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 |
| 2707 | 2746 |
| 2708 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) | 2747 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) |
| 2709 STRUCT_LIST(MAKE_STRUCT_CAST) | 2748 STRUCT_LIST(MAKE_STRUCT_CAST) |
| 2710 #undef MAKE_STRUCT_CAST | 2749 #undef MAKE_STRUCT_CAST |
| 2711 | 2750 |
| 2712 | 2751 |
| 2713 template <typename Shape, typename Key> | 2752 template <typename Shape, typename Key> |
| 2714 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { | 2753 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { |
| 2715 ASSERT(obj->IsHashTable()); | 2754 ASSERT(obj->IsHashTable()); |
| 2716 return reinterpret_cast<HashTable*>(obj); | 2755 return reinterpret_cast<HashTable*>(obj); |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3472 } | 3511 } |
| 3473 | 3512 |
| 3474 | 3513 |
| 3475 void ExternalDoubleArray::set(int index, double value) { | 3514 void ExternalDoubleArray::set(int index, double value) { |
| 3476 ASSERT((index >= 0) && (index < this->length())); | 3515 ASSERT((index >= 0) && (index < this->length())); |
| 3477 double* ptr = static_cast<double*>(external_pointer()); | 3516 double* ptr = static_cast<double*>(external_pointer()); |
| 3478 ptr[index] = value; | 3517 ptr[index] = value; |
| 3479 } | 3518 } |
| 3480 | 3519 |
| 3481 | 3520 |
| 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 |
| 3482 int Map::visitor_id() { | 3648 int Map::visitor_id() { |
| 3483 return READ_BYTE_FIELD(this, kVisitorIdOffset); | 3649 return READ_BYTE_FIELD(this, kVisitorIdOffset); |
| 3484 } | 3650 } |
| 3485 | 3651 |
| 3486 | 3652 |
| 3487 void Map::set_visitor_id(int id) { | 3653 void Map::set_visitor_id(int id) { |
| 3488 ASSERT(0 <= id && id < 256); | 3654 ASSERT(0 <= id && id < 256); |
| 3489 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); | 3655 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); |
| 3490 } | 3656 } |
| 3491 | 3657 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 3698 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 3533 return FixedDoubleArray::SizeFor( | 3699 return FixedDoubleArray::SizeFor( |
| 3534 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 3700 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
| 3535 } | 3701 } |
| 3536 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 3702 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
| 3537 return ConstantPoolArray::SizeFor( | 3703 return ConstantPoolArray::SizeFor( |
| 3538 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), | 3704 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int64_entries(), |
| 3539 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), | 3705 reinterpret_cast<ConstantPoolArray*>(this)->count_of_ptr_entries(), |
| 3540 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); | 3706 reinterpret_cast<ConstantPoolArray*>(this)->count_of_int32_entries()); |
| 3541 } | 3707 } |
| 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 } |
| 3542 ASSERT(instance_type == CODE_TYPE); | 3712 ASSERT(instance_type == CODE_TYPE); |
| 3543 return reinterpret_cast<Code*>(this)->CodeSize(); | 3713 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 3544 } | 3714 } |
| 3545 | 3715 |
| 3546 | 3716 |
| 3547 void Map::set_instance_size(int value) { | 3717 void Map::set_instance_size(int value) { |
| 3548 ASSERT_EQ(0, value & (kPointerSize - 1)); | 3718 ASSERT_EQ(0, value & (kPointerSize - 1)); |
| 3549 value >>= kPointerSizeLog2; | 3719 value >>= kPointerSizeLog2; |
| 3550 ASSERT(0 <= value && value < 256); | 3720 ASSERT(0 <= value && value < 256); |
| 3551 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); | 3721 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); |
| (...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5700 EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) | 5870 EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE) |
| 5701 EXTERNAL_ELEMENTS_CHECK(UnsignedInt, | 5871 EXTERNAL_ELEMENTS_CHECK(UnsignedInt, |
| 5702 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) | 5872 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) |
| 5703 EXTERNAL_ELEMENTS_CHECK(Float, | 5873 EXTERNAL_ELEMENTS_CHECK(Float, |
| 5704 EXTERNAL_FLOAT_ARRAY_TYPE) | 5874 EXTERNAL_FLOAT_ARRAY_TYPE) |
| 5705 EXTERNAL_ELEMENTS_CHECK(Double, | 5875 EXTERNAL_ELEMENTS_CHECK(Double, |
| 5706 EXTERNAL_DOUBLE_ARRAY_TYPE) | 5876 EXTERNAL_DOUBLE_ARRAY_TYPE) |
| 5707 EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) | 5877 EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE) |
| 5708 | 5878 |
| 5709 | 5879 |
| 5880 bool JSObject::HasFixedTypedArrayElements() { |
| 5881 HeapObject* array = elements(); |
| 5882 ASSERT(array != NULL); |
| 5883 return array->IsFixedTypedArrayBase(); |
| 5884 } |
| 5885 |
| 5886 |
| 5710 bool JSObject::HasNamedInterceptor() { | 5887 bool JSObject::HasNamedInterceptor() { |
| 5711 return map()->has_named_interceptor(); | 5888 return map()->has_named_interceptor(); |
| 5712 } | 5889 } |
| 5713 | 5890 |
| 5714 | 5891 |
| 5715 bool JSObject::HasIndexedInterceptor() { | 5892 bool JSObject::HasIndexedInterceptor() { |
| 5716 return map()->has_indexed_interceptor(); | 5893 return map()->has_indexed_interceptor(); |
| 5717 } | 5894 } |
| 5718 | 5895 |
| 5719 | 5896 |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6491 #undef WRITE_UINT32_FIELD | 6668 #undef WRITE_UINT32_FIELD |
| 6492 #undef READ_SHORT_FIELD | 6669 #undef READ_SHORT_FIELD |
| 6493 #undef WRITE_SHORT_FIELD | 6670 #undef WRITE_SHORT_FIELD |
| 6494 #undef READ_BYTE_FIELD | 6671 #undef READ_BYTE_FIELD |
| 6495 #undef WRITE_BYTE_FIELD | 6672 #undef WRITE_BYTE_FIELD |
| 6496 | 6673 |
| 6497 | 6674 |
| 6498 } } // namespace v8::internal | 6675 } } // namespace v8::internal |
| 6499 | 6676 |
| 6500 #endif // V8_OBJECTS_INL_H_ | 6677 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |