| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 #define TYPE_CHECKER(type, instancetype) \ | 57 #define TYPE_CHECKER(type, instancetype) \ |
| 58 bool Object::Is##type() const { \ | 58 bool Object::Is##type() const { \ |
| 59 return Object::IsHeapObject() && \ | 59 return Object::IsHeapObject() && \ |
| 60 HeapObject::cast(this)->map()->instance_type() == instancetype; \ | 60 HeapObject::cast(this)->map()->instance_type() == instancetype; \ |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 #define CAST_ACCESSOR(type) \ | 64 #define CAST_ACCESSOR(type) \ |
| 65 type* type::cast(Object* object) { \ | 65 type* type::cast(Object* object) { \ |
| 66 SLOW_ASSERT(object->Is##type()); \ | 66 SLOW_DCHECK(object->Is##type()); \ |
| 67 return reinterpret_cast<type*>(object); \ | 67 return reinterpret_cast<type*>(object); \ |
| 68 } \ | 68 } \ |
| 69 const type* type::cast(const Object* object) { \ | 69 const type* type::cast(const Object* object) { \ |
| 70 SLOW_ASSERT(object->Is##type()); \ | 70 SLOW_DCHECK(object->Is##type()); \ |
| 71 return reinterpret_cast<const type*>(object); \ | 71 return reinterpret_cast<const type*>(object); \ |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 #define INT_ACCESSORS(holder, name, offset) \ | 75 #define INT_ACCESSORS(holder, name, offset) \ |
| 76 int holder::name() const { return READ_INT_FIELD(this, offset); } \ | 76 int holder::name() const { return READ_INT_FIELD(this, offset); } \ |
| 77 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 77 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
| 78 | 78 |
| 79 | 79 |
| 80 #define ACCESSORS(holder, name, type, offset) \ | 80 #define ACCESSORS(holder, name, type, offset) \ |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } else { | 287 } else { |
| 288 value = object->Number(); | 288 value = object->Number(); |
| 289 } | 289 } |
| 290 return isolate->factory()->NewHeapNumber(value, MUTABLE); | 290 return isolate->factory()->NewHeapNumber(value, MUTABLE); |
| 291 } | 291 } |
| 292 | 292 |
| 293 | 293 |
| 294 Handle<Object> Object::WrapForRead(Isolate* isolate, | 294 Handle<Object> Object::WrapForRead(Isolate* isolate, |
| 295 Handle<Object> object, | 295 Handle<Object> object, |
| 296 Representation representation) { | 296 Representation representation) { |
| 297 ASSERT(!object->IsUninitialized()); | 297 DCHECK(!object->IsUninitialized()); |
| 298 if (!representation.IsDouble()) { | 298 if (!representation.IsDouble()) { |
| 299 ASSERT(object->FitsRepresentation(representation)); | 299 DCHECK(object->FitsRepresentation(representation)); |
| 300 return object; | 300 return object; |
| 301 } | 301 } |
| 302 return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value()); | 302 return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value()); |
| 303 } | 303 } |
| 304 | 304 |
| 305 | 305 |
| 306 StringShape::StringShape(const String* str) | 306 StringShape::StringShape(const String* str) |
| 307 : type_(str->map()->instance_type()) { | 307 : type_(str->map()->instance_type()) { |
| 308 set_valid(); | 308 set_valid(); |
| 309 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 309 DCHECK((type_ & kIsNotStringMask) == kStringTag); |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 StringShape::StringShape(Map* map) | 313 StringShape::StringShape(Map* map) |
| 314 : type_(map->instance_type()) { | 314 : type_(map->instance_type()) { |
| 315 set_valid(); | 315 set_valid(); |
| 316 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 316 DCHECK((type_ & kIsNotStringMask) == kStringTag); |
| 317 } | 317 } |
| 318 | 318 |
| 319 | 319 |
| 320 StringShape::StringShape(InstanceType t) | 320 StringShape::StringShape(InstanceType t) |
| 321 : type_(static_cast<uint32_t>(t)) { | 321 : type_(static_cast<uint32_t>(t)) { |
| 322 set_valid(); | 322 set_valid(); |
| 323 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 323 DCHECK((type_ & kIsNotStringMask) == kStringTag); |
| 324 } | 324 } |
| 325 | 325 |
| 326 | 326 |
| 327 bool StringShape::IsInternalized() { | 327 bool StringShape::IsInternalized() { |
| 328 ASSERT(valid()); | 328 DCHECK(valid()); |
| 329 STATIC_ASSERT(kNotInternalizedTag != 0); | 329 STATIC_ASSERT(kNotInternalizedTag != 0); |
| 330 return (type_ & (kIsNotStringMask | kIsNotInternalizedMask)) == | 330 return (type_ & (kIsNotStringMask | kIsNotInternalizedMask)) == |
| 331 (kStringTag | kInternalizedTag); | 331 (kStringTag | kInternalizedTag); |
| 332 } | 332 } |
| 333 | 333 |
| 334 | 334 |
| 335 bool String::IsOneByteRepresentation() const { | 335 bool String::IsOneByteRepresentation() const { |
| 336 uint32_t type = map()->instance_type(); | 336 uint32_t type = map()->instance_type(); |
| 337 return (type & kStringEncodingMask) == kOneByteStringTag; | 337 return (type & kStringEncodingMask) == kOneByteStringTag; |
| 338 } | 338 } |
| 339 | 339 |
| 340 | 340 |
| 341 bool String::IsTwoByteRepresentation() const { | 341 bool String::IsTwoByteRepresentation() const { |
| 342 uint32_t type = map()->instance_type(); | 342 uint32_t type = map()->instance_type(); |
| 343 return (type & kStringEncodingMask) == kTwoByteStringTag; | 343 return (type & kStringEncodingMask) == kTwoByteStringTag; |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 bool String::IsOneByteRepresentationUnderneath() { | 347 bool String::IsOneByteRepresentationUnderneath() { |
| 348 uint32_t type = map()->instance_type(); | 348 uint32_t type = map()->instance_type(); |
| 349 STATIC_ASSERT(kIsIndirectStringTag != 0); | 349 STATIC_ASSERT(kIsIndirectStringTag != 0); |
| 350 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); | 350 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); |
| 351 ASSERT(IsFlat()); | 351 DCHECK(IsFlat()); |
| 352 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { | 352 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { |
| 353 case kOneByteStringTag: | 353 case kOneByteStringTag: |
| 354 return true; | 354 return true; |
| 355 case kTwoByteStringTag: | 355 case kTwoByteStringTag: |
| 356 return false; | 356 return false; |
| 357 default: // Cons or sliced string. Need to go deeper. | 357 default: // Cons or sliced string. Need to go deeper. |
| 358 return GetUnderlying()->IsOneByteRepresentation(); | 358 return GetUnderlying()->IsOneByteRepresentation(); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 | 362 |
| 363 bool String::IsTwoByteRepresentationUnderneath() { | 363 bool String::IsTwoByteRepresentationUnderneath() { |
| 364 uint32_t type = map()->instance_type(); | 364 uint32_t type = map()->instance_type(); |
| 365 STATIC_ASSERT(kIsIndirectStringTag != 0); | 365 STATIC_ASSERT(kIsIndirectStringTag != 0); |
| 366 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); | 366 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); |
| 367 ASSERT(IsFlat()); | 367 DCHECK(IsFlat()); |
| 368 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { | 368 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { |
| 369 case kOneByteStringTag: | 369 case kOneByteStringTag: |
| 370 return false; | 370 return false; |
| 371 case kTwoByteStringTag: | 371 case kTwoByteStringTag: |
| 372 return true; | 372 return true; |
| 373 default: // Cons or sliced string. Need to go deeper. | 373 default: // Cons or sliced string. Need to go deeper. |
| 374 return GetUnderlying()->IsTwoByteRepresentation(); | 374 return GetUnderlying()->IsTwoByteRepresentation(); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); | 456 return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); |
| 457 } | 457 } |
| 458 | 458 |
| 459 | 459 |
| 460 STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) == | 460 STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) == |
| 461 Internals::kExternalTwoByteRepresentationTag); | 461 Internals::kExternalTwoByteRepresentationTag); |
| 462 | 462 |
| 463 STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag); | 463 STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag); |
| 464 | 464 |
| 465 uc32 FlatStringReader::Get(int index) { | 465 uc32 FlatStringReader::Get(int index) { |
| 466 ASSERT(0 <= index && index <= length_); | 466 DCHECK(0 <= index && index <= length_); |
| 467 if (is_ascii_) { | 467 if (is_ascii_) { |
| 468 return static_cast<const byte*>(start_)[index]; | 468 return static_cast<const byte*>(start_)[index]; |
| 469 } else { | 469 } else { |
| 470 return static_cast<const uc16*>(start_)[index]; | 470 return static_cast<const uc16*>(start_)[index]; |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 | 474 |
| 475 Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) { | 475 Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) { |
| 476 return key->AsHandle(isolate); | 476 return key->AsHandle(isolate); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 498 public: | 498 public: |
| 499 explicit SequentialStringKey(Vector<const Char> string, uint32_t seed) | 499 explicit SequentialStringKey(Vector<const Char> string, uint32_t seed) |
| 500 : string_(string), hash_field_(0), seed_(seed) { } | 500 : string_(string), hash_field_(0), seed_(seed) { } |
| 501 | 501 |
| 502 virtual uint32_t Hash() V8_OVERRIDE { | 502 virtual uint32_t Hash() V8_OVERRIDE { |
| 503 hash_field_ = StringHasher::HashSequentialString<Char>(string_.start(), | 503 hash_field_ = StringHasher::HashSequentialString<Char>(string_.start(), |
| 504 string_.length(), | 504 string_.length(), |
| 505 seed_); | 505 seed_); |
| 506 | 506 |
| 507 uint32_t result = hash_field_ >> String::kHashShift; | 507 uint32_t result = hash_field_ >> String::kHashShift; |
| 508 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. | 508 DCHECK(result != 0); // Ensure that the hash value of 0 is never computed. |
| 509 return result; | 509 return result; |
| 510 } | 510 } |
| 511 | 511 |
| 512 | 512 |
| 513 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { | 513 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { |
| 514 return String::cast(other)->Hash(); | 514 return String::cast(other)->Hash(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 Vector<const Char> string_; | 517 Vector<const Char> string_; |
| 518 uint32_t hash_field_; | 518 uint32_t hash_field_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 534 | 534 |
| 535 | 535 |
| 536 template<class Char> | 536 template<class Char> |
| 537 class SubStringKey : public HashTableKey { | 537 class SubStringKey : public HashTableKey { |
| 538 public: | 538 public: |
| 539 SubStringKey(Handle<String> string, int from, int length) | 539 SubStringKey(Handle<String> string, int from, int length) |
| 540 : string_(string), from_(from), length_(length) { | 540 : string_(string), from_(from), length_(length) { |
| 541 if (string_->IsSlicedString()) { | 541 if (string_->IsSlicedString()) { |
| 542 string_ = Handle<String>(Unslice(*string_, &from_)); | 542 string_ = Handle<String>(Unslice(*string_, &from_)); |
| 543 } | 543 } |
| 544 ASSERT(string_->IsSeqString() || string->IsExternalString()); | 544 DCHECK(string_->IsSeqString() || string->IsExternalString()); |
| 545 } | 545 } |
| 546 | 546 |
| 547 virtual uint32_t Hash() V8_OVERRIDE { | 547 virtual uint32_t Hash() V8_OVERRIDE { |
| 548 ASSERT(length_ >= 0); | 548 DCHECK(length_ >= 0); |
| 549 ASSERT(from_ + length_ <= string_->length()); | 549 DCHECK(from_ + length_ <= string_->length()); |
| 550 const Char* chars = GetChars() + from_; | 550 const Char* chars = GetChars() + from_; |
| 551 hash_field_ = StringHasher::HashSequentialString( | 551 hash_field_ = StringHasher::HashSequentialString( |
| 552 chars, length_, string_->GetHeap()->HashSeed()); | 552 chars, length_, string_->GetHeap()->HashSeed()); |
| 553 uint32_t result = hash_field_ >> String::kHashShift; | 553 uint32_t result = hash_field_ >> String::kHashShift; |
| 554 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. | 554 DCHECK(result != 0); // Ensure that the hash value of 0 is never computed. |
| 555 return result; | 555 return result; |
| 556 } | 556 } |
| 557 | 557 |
| 558 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { | 558 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { |
| 559 return String::cast(other)->Hash(); | 559 return String::cast(other)->Hash(); |
| 560 } | 560 } |
| 561 | 561 |
| 562 virtual bool IsMatch(Object* string) V8_OVERRIDE; | 562 virtual bool IsMatch(Object* string) V8_OVERRIDE; |
| 563 virtual Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE; | 563 virtual Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE; |
| 564 | 564 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 : string_(string), hash_field_(0), seed_(seed) { } | 600 : string_(string), hash_field_(0), seed_(seed) { } |
| 601 | 601 |
| 602 virtual bool IsMatch(Object* string) V8_OVERRIDE { | 602 virtual bool IsMatch(Object* string) V8_OVERRIDE { |
| 603 return String::cast(string)->IsUtf8EqualTo(string_); | 603 return String::cast(string)->IsUtf8EqualTo(string_); |
| 604 } | 604 } |
| 605 | 605 |
| 606 virtual uint32_t Hash() V8_OVERRIDE { | 606 virtual uint32_t Hash() V8_OVERRIDE { |
| 607 if (hash_field_ != 0) return hash_field_ >> String::kHashShift; | 607 if (hash_field_ != 0) return hash_field_ >> String::kHashShift; |
| 608 hash_field_ = StringHasher::ComputeUtf8Hash(string_, seed_, &chars_); | 608 hash_field_ = StringHasher::ComputeUtf8Hash(string_, seed_, &chars_); |
| 609 uint32_t result = hash_field_ >> String::kHashShift; | 609 uint32_t result = hash_field_ >> String::kHashShift; |
| 610 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. | 610 DCHECK(result != 0); // Ensure that the hash value of 0 is never computed. |
| 611 return result; | 611 return result; |
| 612 } | 612 } |
| 613 | 613 |
| 614 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { | 614 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { |
| 615 return String::cast(other)->Hash(); | 615 return String::cast(other)->Hash(); |
| 616 } | 616 } |
| 617 | 617 |
| 618 virtual Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 618 virtual Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { |
| 619 if (hash_field_ == 0) Hash(); | 619 if (hash_field_ == 0) Hash(); |
| 620 return isolate->factory()->NewInternalizedStringFromUtf8( | 620 return isolate->factory()->NewInternalizedStringFromUtf8( |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 | 975 |
| 976 bool Object::IsPrimitive() const { | 976 bool Object::IsPrimitive() const { |
| 977 return IsOddball() || IsNumber() || IsString(); | 977 return IsOddball() || IsNumber() || IsString(); |
| 978 } | 978 } |
| 979 | 979 |
| 980 | 980 |
| 981 bool Object::IsJSGlobalProxy() const { | 981 bool Object::IsJSGlobalProxy() const { |
| 982 bool result = IsHeapObject() && | 982 bool result = IsHeapObject() && |
| 983 (HeapObject::cast(this)->map()->instance_type() == | 983 (HeapObject::cast(this)->map()->instance_type() == |
| 984 JS_GLOBAL_PROXY_TYPE); | 984 JS_GLOBAL_PROXY_TYPE); |
| 985 ASSERT(!result || | 985 DCHECK(!result || |
| 986 HeapObject::cast(this)->map()->is_access_check_needed()); | 986 HeapObject::cast(this)->map()->is_access_check_needed()); |
| 987 return result; | 987 return result; |
| 988 } | 988 } |
| 989 | 989 |
| 990 | 990 |
| 991 bool Object::IsGlobalObject() const { | 991 bool Object::IsGlobalObject() const { |
| 992 if (!IsHeapObject()) return false; | 992 if (!IsHeapObject()) return false; |
| 993 | 993 |
| 994 InstanceType type = HeapObject::cast(this)->map()->instance_type(); | 994 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
| 995 return type == JS_GLOBAL_OBJECT_TYPE || | 995 return type == JS_GLOBAL_OBJECT_TYPE || |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse; | 1072 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse; |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 | 1075 |
| 1076 bool Object::IsArgumentsMarker() const { | 1076 bool Object::IsArgumentsMarker() const { |
| 1077 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kArgumentMarker; | 1077 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kArgumentMarker; |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 | 1080 |
| 1081 double Object::Number() { | 1081 double Object::Number() { |
| 1082 ASSERT(IsNumber()); | 1082 DCHECK(IsNumber()); |
| 1083 return IsSmi() | 1083 return IsSmi() |
| 1084 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) | 1084 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) |
| 1085 : reinterpret_cast<HeapNumber*>(this)->value(); | 1085 : reinterpret_cast<HeapNumber*>(this)->value(); |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 | 1088 |
| 1089 bool Object::IsNaN() const { | 1089 bool Object::IsNaN() const { |
| 1090 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); | 1090 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 Handle<Name> name) { | 1126 Handle<Name> name) { |
| 1127 LookupIterator it(object, name); | 1127 LookupIterator it(object, name); |
| 1128 return GetProperty(&it); | 1128 return GetProperty(&it); |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 | 1131 |
| 1132 MaybeHandle<Object> Object::GetElement(Isolate* isolate, | 1132 MaybeHandle<Object> Object::GetElement(Isolate* isolate, |
| 1133 Handle<Object> object, | 1133 Handle<Object> object, |
| 1134 uint32_t index) { | 1134 uint32_t index) { |
| 1135 // GetElement can trigger a getter which can cause allocation. | 1135 // GetElement can trigger a getter which can cause allocation. |
| 1136 // This was not always the case. This ASSERT is here to catch | 1136 // This was not always the case. This DCHECK is here to catch |
| 1137 // leftover incorrect uses. | 1137 // leftover incorrect uses. |
| 1138 ASSERT(AllowHeapAllocation::IsAllowed()); | 1138 DCHECK(AllowHeapAllocation::IsAllowed()); |
| 1139 return Object::GetElementWithReceiver(isolate, object, object, index); | 1139 return Object::GetElementWithReceiver(isolate, object, object, index); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 | 1142 |
| 1143 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object, | 1143 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object, |
| 1144 Handle<Name> name) { | 1144 Handle<Name> name) { |
| 1145 uint32_t index; | 1145 uint32_t index; |
| 1146 Isolate* isolate = name->GetIsolate(); | 1146 Isolate* isolate = name->GetIsolate(); |
| 1147 if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index); | 1147 if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index); |
| 1148 return GetProperty(object, name); | 1148 return GetProperty(object, name); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 | 1151 |
| 1152 MaybeHandle<Object> Object::GetProperty(Isolate* isolate, | 1152 MaybeHandle<Object> Object::GetProperty(Isolate* isolate, |
| 1153 Handle<Object> object, | 1153 Handle<Object> object, |
| 1154 const char* name) { | 1154 const char* name) { |
| 1155 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); | 1155 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); |
| 1156 ASSERT(!str.is_null()); | 1156 DCHECK(!str.is_null()); |
| 1157 #ifdef DEBUG | 1157 #ifdef DEBUG |
| 1158 uint32_t index; // Assert that the name is not an array index. | 1158 uint32_t index; // Assert that the name is not an array index. |
| 1159 ASSERT(!str->AsArrayIndex(&index)); | 1159 DCHECK(!str->AsArrayIndex(&index)); |
| 1160 #endif // DEBUG | 1160 #endif // DEBUG |
| 1161 return GetProperty(object, str); | 1161 return GetProperty(object, str); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 | 1164 |
| 1165 MaybeHandle<Object> JSProxy::GetElementWithHandler(Handle<JSProxy> proxy, | 1165 MaybeHandle<Object> JSProxy::GetElementWithHandler(Handle<JSProxy> proxy, |
| 1166 Handle<Object> receiver, | 1166 Handle<Object> receiver, |
| 1167 uint32_t index) { | 1167 uint32_t index) { |
| 1168 return GetPropertyWithHandler( | 1168 return GetPropertyWithHandler( |
| 1169 proxy, receiver, proxy->GetIsolate()->factory()->Uint32ToString(index)); | 1169 proxy, receiver, proxy->GetIsolate()->factory()->Uint32ToString(index)); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset)); | 1331 return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset)); |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 | 1334 |
| 1335 int Smi::value() const { | 1335 int Smi::value() const { |
| 1336 return Internals::SmiValue(this); | 1336 return Internals::SmiValue(this); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 | 1339 |
| 1340 Smi* Smi::FromInt(int value) { | 1340 Smi* Smi::FromInt(int value) { |
| 1341 ASSERT(Smi::IsValid(value)); | 1341 DCHECK(Smi::IsValid(value)); |
| 1342 return reinterpret_cast<Smi*>(Internals::IntToSmi(value)); | 1342 return reinterpret_cast<Smi*>(Internals::IntToSmi(value)); |
| 1343 } | 1343 } |
| 1344 | 1344 |
| 1345 | 1345 |
| 1346 Smi* Smi::FromIntptr(intptr_t value) { | 1346 Smi* Smi::FromIntptr(intptr_t value) { |
| 1347 ASSERT(Smi::IsValid(value)); | 1347 DCHECK(Smi::IsValid(value)); |
| 1348 int smi_shift_bits = kSmiTagSize + kSmiShiftSize; | 1348 int smi_shift_bits = kSmiTagSize + kSmiShiftSize; |
| 1349 return reinterpret_cast<Smi*>((value << smi_shift_bits) | kSmiTag); | 1349 return reinterpret_cast<Smi*>((value << smi_shift_bits) | kSmiTag); |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 | 1352 |
| 1353 bool Smi::IsValid(intptr_t value) { | 1353 bool Smi::IsValid(intptr_t value) { |
| 1354 bool result = Internals::IsValidSmi(value); | 1354 bool result = Internals::IsValidSmi(value); |
| 1355 ASSERT_EQ(result, value >= kMinValue && value <= kMaxValue); | 1355 DCHECK_EQ(result, value >= kMinValue && value <= kMaxValue); |
| 1356 return result; | 1356 return result; |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 | 1359 |
| 1360 MapWord MapWord::FromMap(const Map* map) { | 1360 MapWord MapWord::FromMap(const Map* map) { |
| 1361 return MapWord(reinterpret_cast<uintptr_t>(map)); | 1361 return MapWord(reinterpret_cast<uintptr_t>(map)); |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 | 1364 |
| 1365 Map* MapWord::ToMap() { | 1365 Map* MapWord::ToMap() { |
| 1366 return reinterpret_cast<Map*>(value_); | 1366 return reinterpret_cast<Map*>(value_); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 | 1369 |
| 1370 bool MapWord::IsForwardingAddress() { | 1370 bool MapWord::IsForwardingAddress() { |
| 1371 return HAS_SMI_TAG(reinterpret_cast<Object*>(value_)); | 1371 return HAS_SMI_TAG(reinterpret_cast<Object*>(value_)); |
| 1372 } | 1372 } |
| 1373 | 1373 |
| 1374 | 1374 |
| 1375 MapWord MapWord::FromForwardingAddress(HeapObject* object) { | 1375 MapWord MapWord::FromForwardingAddress(HeapObject* object) { |
| 1376 Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag; | 1376 Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag; |
| 1377 return MapWord(reinterpret_cast<uintptr_t>(raw)); | 1377 return MapWord(reinterpret_cast<uintptr_t>(raw)); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 | 1380 |
| 1381 HeapObject* MapWord::ToForwardingAddress() { | 1381 HeapObject* MapWord::ToForwardingAddress() { |
| 1382 ASSERT(IsForwardingAddress()); | 1382 DCHECK(IsForwardingAddress()); |
| 1383 return HeapObject::FromAddress(reinterpret_cast<Address>(value_)); | 1383 return HeapObject::FromAddress(reinterpret_cast<Address>(value_)); |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 | 1386 |
| 1387 #ifdef VERIFY_HEAP | 1387 #ifdef VERIFY_HEAP |
| 1388 void HeapObject::VerifyObjectField(int offset) { | 1388 void HeapObject::VerifyObjectField(int offset) { |
| 1389 VerifyPointer(READ_FIELD(this, offset)); | 1389 VerifyPointer(READ_FIELD(this, offset)); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 void HeapObject::VerifySmiField(int offset) { | 1392 void HeapObject::VerifySmiField(int offset) { |
| 1393 CHECK(READ_FIELD(this, offset)->IsSmi()); | 1393 CHECK(READ_FIELD(this, offset)->IsSmi()); |
| 1394 } | 1394 } |
| 1395 #endif | 1395 #endif |
| 1396 | 1396 |
| 1397 | 1397 |
| 1398 Heap* HeapObject::GetHeap() const { | 1398 Heap* HeapObject::GetHeap() const { |
| 1399 Heap* heap = | 1399 Heap* heap = |
| 1400 MemoryChunk::FromAddress(reinterpret_cast<const byte*>(this))->heap(); | 1400 MemoryChunk::FromAddress(reinterpret_cast<const byte*>(this))->heap(); |
| 1401 SLOW_ASSERT(heap != NULL); | 1401 SLOW_DCHECK(heap != NULL); |
| 1402 return heap; | 1402 return heap; |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 | 1405 |
| 1406 Isolate* HeapObject::GetIsolate() const { | 1406 Isolate* HeapObject::GetIsolate() const { |
| 1407 return GetHeap()->isolate(); | 1407 return GetHeap()->isolate(); |
| 1408 } | 1408 } |
| 1409 | 1409 |
| 1410 | 1410 |
| 1411 Map* HeapObject::map() const { | 1411 Map* HeapObject::map() const { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 | 1476 |
| 1477 void HeapObject::synchronized_set_map_word(MapWord map_word) { | 1477 void HeapObject::synchronized_set_map_word(MapWord map_word) { |
| 1478 RELEASE_WRITE_FIELD( | 1478 RELEASE_WRITE_FIELD( |
| 1479 this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); | 1479 this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 | 1482 |
| 1483 HeapObject* HeapObject::FromAddress(Address address) { | 1483 HeapObject* HeapObject::FromAddress(Address address) { |
| 1484 ASSERT_TAG_ALIGNED(address); | 1484 DCHECK_TAG_ALIGNED(address); |
| 1485 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1485 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 | 1488 |
| 1489 Address HeapObject::address() { | 1489 Address HeapObject::address() { |
| 1490 return reinterpret_cast<Address>(this) - kHeapObjectTag; | 1490 return reinterpret_cast<Address>(this) - kHeapObjectTag; |
| 1491 } | 1491 } |
| 1492 | 1492 |
| 1493 | 1493 |
| 1494 int HeapObject::Size() { | 1494 int HeapObject::Size() { |
| 1495 return SizeFromMap(map()); | 1495 return SizeFromMap(map()); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 | 1498 |
| 1499 bool HeapObject::MayContainNewSpacePointers() { | 1499 bool HeapObject::MayContainNewSpacePointers() { |
| 1500 InstanceType type = map()->instance_type(); | 1500 InstanceType type = map()->instance_type(); |
| 1501 if (type <= LAST_NAME_TYPE) { | 1501 if (type <= LAST_NAME_TYPE) { |
| 1502 if (type == SYMBOL_TYPE) { | 1502 if (type == SYMBOL_TYPE) { |
| 1503 return true; | 1503 return true; |
| 1504 } | 1504 } |
| 1505 ASSERT(type < FIRST_NONSTRING_TYPE); | 1505 DCHECK(type < FIRST_NONSTRING_TYPE); |
| 1506 // There are four string representations: sequential strings, external | 1506 // There are four string representations: sequential strings, external |
| 1507 // strings, cons strings, and sliced strings. | 1507 // strings, cons strings, and sliced strings. |
| 1508 // Only the latter two contain non-map-word pointers to heap objects. | 1508 // Only the latter two contain non-map-word pointers to heap objects. |
| 1509 return ((type & kIsIndirectStringMask) == kIsIndirectStringTag); | 1509 return ((type & kIsIndirectStringMask) == kIsIndirectStringTag); |
| 1510 } | 1510 } |
| 1511 // The ConstantPoolArray contains heap pointers, but not new space pointers. | 1511 // The ConstantPoolArray contains heap pointers, but not new space pointers. |
| 1512 if (type == CONSTANT_POOL_ARRAY_TYPE) return false; | 1512 if (type == CONSTANT_POOL_ARRAY_TYPE) return false; |
| 1513 return (type > LAST_DATA_TYPE); | 1513 return (type > LAST_DATA_TYPE); |
| 1514 } | 1514 } |
| 1515 | 1515 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 } | 1570 } |
| 1571 | 1571 |
| 1572 | 1572 |
| 1573 FixedArrayBase* JSObject::elements() const { | 1573 FixedArrayBase* JSObject::elements() const { |
| 1574 Object* array = READ_FIELD(this, kElementsOffset); | 1574 Object* array = READ_FIELD(this, kElementsOffset); |
| 1575 return static_cast<FixedArrayBase*>(array); | 1575 return static_cast<FixedArrayBase*>(array); |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 | 1578 |
| 1579 void JSObject::ValidateElements(Handle<JSObject> object) { | 1579 void JSObject::ValidateElements(Handle<JSObject> object) { |
| 1580 #ifdef ENABLE_SLOW_ASSERTS | 1580 #ifdef ENABLE_SLOW_DCHECKS |
| 1581 if (FLAG_enable_slow_asserts) { | 1581 if (FLAG_enable_slow_asserts) { |
| 1582 ElementsAccessor* accessor = object->GetElementsAccessor(); | 1582 ElementsAccessor* accessor = object->GetElementsAccessor(); |
| 1583 accessor->Validate(object); | 1583 accessor->Validate(object); |
| 1584 } | 1584 } |
| 1585 #endif | 1585 #endif |
| 1586 } | 1586 } |
| 1587 | 1587 |
| 1588 | 1588 |
| 1589 void AllocationSite::Initialize() { | 1589 void AllocationSite::Initialize() { |
| 1590 set_transition_info(Smi::FromInt(0)); | 1590 set_transition_info(Smi::FromInt(0)); |
| 1591 SetElementsKind(GetInitialFastElementsKind()); | 1591 SetElementsKind(GetInitialFastElementsKind()); |
| 1592 set_nested_site(Smi::FromInt(0)); | 1592 set_nested_site(Smi::FromInt(0)); |
| 1593 set_pretenure_data(Smi::FromInt(0)); | 1593 set_pretenure_data(Smi::FromInt(0)); |
| 1594 set_pretenure_create_count(Smi::FromInt(0)); | 1594 set_pretenure_create_count(Smi::FromInt(0)); |
| 1595 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), | 1595 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
| 1596 SKIP_WRITE_BARRIER); | 1596 SKIP_WRITE_BARRIER); |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 | 1599 |
| 1600 void AllocationSite::MarkZombie() { | 1600 void AllocationSite::MarkZombie() { |
| 1601 ASSERT(!IsZombie()); | 1601 DCHECK(!IsZombie()); |
| 1602 Initialize(); | 1602 Initialize(); |
| 1603 set_pretenure_decision(kZombie); | 1603 set_pretenure_decision(kZombie); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 | 1606 |
| 1607 // Heuristic: We only need to create allocation site info if the boilerplate | 1607 // Heuristic: We only need to create allocation site info if the boilerplate |
| 1608 // elements kind is the initial elements kind. | 1608 // elements kind is the initial elements kind. |
| 1609 AllocationSiteMode AllocationSite::GetMode( | 1609 AllocationSiteMode AllocationSite::GetMode( |
| 1610 ElementsKind boilerplate_elements_kind) { | 1610 ElementsKind boilerplate_elements_kind) { |
| 1611 if (FLAG_pretenuring_call_new || | 1611 if (FLAG_pretenuring_call_new || |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 } | 1651 } |
| 1652 UNREACHABLE(); | 1652 UNREACHABLE(); |
| 1653 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1653 return DependentCode::kAllocationSiteTransitionChangedGroup; |
| 1654 } | 1654 } |
| 1655 | 1655 |
| 1656 | 1656 |
| 1657 inline void AllocationSite::set_memento_found_count(int count) { | 1657 inline void AllocationSite::set_memento_found_count(int count) { |
| 1658 int value = pretenure_data()->value(); | 1658 int value = pretenure_data()->value(); |
| 1659 // Verify that we can count more mementos than we can possibly find in one | 1659 // Verify that we can count more mementos than we can possibly find in one |
| 1660 // new space collection. | 1660 // new space collection. |
| 1661 ASSERT((GetHeap()->MaxSemiSpaceSize() / | 1661 DCHECK((GetHeap()->MaxSemiSpaceSize() / |
| 1662 (StaticVisitorBase::kMinObjectSizeInWords * kPointerSize + | 1662 (StaticVisitorBase::kMinObjectSizeInWords * kPointerSize + |
| 1663 AllocationMemento::kSize)) < MementoFoundCountBits::kMax); | 1663 AllocationMemento::kSize)) < MementoFoundCountBits::kMax); |
| 1664 ASSERT(count < MementoFoundCountBits::kMax); | 1664 DCHECK(count < MementoFoundCountBits::kMax); |
| 1665 set_pretenure_data( | 1665 set_pretenure_data( |
| 1666 Smi::FromInt(MementoFoundCountBits::update(value, count)), | 1666 Smi::FromInt(MementoFoundCountBits::update(value, count)), |
| 1667 SKIP_WRITE_BARRIER); | 1667 SKIP_WRITE_BARRIER); |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 inline bool AllocationSite::IncrementMementoFoundCount() { | 1670 inline bool AllocationSite::IncrementMementoFoundCount() { |
| 1671 if (IsZombie()) return false; | 1671 if (IsZombie()) return false; |
| 1672 | 1672 |
| 1673 int value = memento_found_count(); | 1673 int value = memento_found_count(); |
| 1674 set_memento_found_count(value + 1); | 1674 set_memento_found_count(value + 1); |
| 1675 return memento_found_count() == kPretenureMinimumCreated; | 1675 return memento_found_count() == kPretenureMinimumCreated; |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 | 1678 |
| 1679 inline void AllocationSite::IncrementMementoCreateCount() { | 1679 inline void AllocationSite::IncrementMementoCreateCount() { |
| 1680 ASSERT(FLAG_allocation_site_pretenuring); | 1680 DCHECK(FLAG_allocation_site_pretenuring); |
| 1681 int value = memento_create_count(); | 1681 int value = memento_create_count(); |
| 1682 set_memento_create_count(value + 1); | 1682 set_memento_create_count(value + 1); |
| 1683 } | 1683 } |
| 1684 | 1684 |
| 1685 | 1685 |
| 1686 inline bool AllocationSite::MakePretenureDecision( | 1686 inline bool AllocationSite::MakePretenureDecision( |
| 1687 PretenureDecision current_decision, | 1687 PretenureDecision current_decision, |
| 1688 double ratio, | 1688 double ratio, |
| 1689 bool maximum_size_scavenge) { | 1689 bool maximum_size_scavenge) { |
| 1690 // Here we just allow state transitions from undecided or maybe tenure | 1690 // Here we just allow state transitions from undecided or maybe tenure |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 | 1754 |
| 1755 | 1755 |
| 1756 void JSObject::EnsureCanContainElements(Handle<JSObject> object, | 1756 void JSObject::EnsureCanContainElements(Handle<JSObject> object, |
| 1757 Object** objects, | 1757 Object** objects, |
| 1758 uint32_t count, | 1758 uint32_t count, |
| 1759 EnsureElementsMode mode) { | 1759 EnsureElementsMode mode) { |
| 1760 ElementsKind current_kind = object->map()->elements_kind(); | 1760 ElementsKind current_kind = object->map()->elements_kind(); |
| 1761 ElementsKind target_kind = current_kind; | 1761 ElementsKind target_kind = current_kind; |
| 1762 { | 1762 { |
| 1763 DisallowHeapAllocation no_allocation; | 1763 DisallowHeapAllocation no_allocation; |
| 1764 ASSERT(mode != ALLOW_COPIED_DOUBLE_ELEMENTS); | 1764 DCHECK(mode != ALLOW_COPIED_DOUBLE_ELEMENTS); |
| 1765 bool is_holey = IsFastHoleyElementsKind(current_kind); | 1765 bool is_holey = IsFastHoleyElementsKind(current_kind); |
| 1766 if (current_kind == FAST_HOLEY_ELEMENTS) return; | 1766 if (current_kind == FAST_HOLEY_ELEMENTS) return; |
| 1767 Heap* heap = object->GetHeap(); | 1767 Heap* heap = object->GetHeap(); |
| 1768 Object* the_hole = heap->the_hole_value(); | 1768 Object* the_hole = heap->the_hole_value(); |
| 1769 for (uint32_t i = 0; i < count; ++i) { | 1769 for (uint32_t i = 0; i < count; ++i) { |
| 1770 Object* current = *objects++; | 1770 Object* current = *objects++; |
| 1771 if (current == the_hole) { | 1771 if (current == the_hole) { |
| 1772 is_holey = true; | 1772 is_holey = true; |
| 1773 target_kind = GetHoleyElementsKind(target_kind); | 1773 target_kind = GetHoleyElementsKind(target_kind); |
| 1774 } else if (!current->IsSmi()) { | 1774 } else if (!current->IsSmi()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1794 } | 1794 } |
| 1795 } | 1795 } |
| 1796 | 1796 |
| 1797 | 1797 |
| 1798 void JSObject::EnsureCanContainElements(Handle<JSObject> object, | 1798 void JSObject::EnsureCanContainElements(Handle<JSObject> object, |
| 1799 Handle<FixedArrayBase> elements, | 1799 Handle<FixedArrayBase> elements, |
| 1800 uint32_t length, | 1800 uint32_t length, |
| 1801 EnsureElementsMode mode) { | 1801 EnsureElementsMode mode) { |
| 1802 Heap* heap = object->GetHeap(); | 1802 Heap* heap = object->GetHeap(); |
| 1803 if (elements->map() != heap->fixed_double_array_map()) { | 1803 if (elements->map() != heap->fixed_double_array_map()) { |
| 1804 ASSERT(elements->map() == heap->fixed_array_map() || | 1804 DCHECK(elements->map() == heap->fixed_array_map() || |
| 1805 elements->map() == heap->fixed_cow_array_map()); | 1805 elements->map() == heap->fixed_cow_array_map()); |
| 1806 if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) { | 1806 if (mode == ALLOW_COPIED_DOUBLE_ELEMENTS) { |
| 1807 mode = DONT_ALLOW_DOUBLE_ELEMENTS; | 1807 mode = DONT_ALLOW_DOUBLE_ELEMENTS; |
| 1808 } | 1808 } |
| 1809 Object** objects = | 1809 Object** objects = |
| 1810 Handle<FixedArray>::cast(elements)->GetFirstElementAddress(); | 1810 Handle<FixedArray>::cast(elements)->GetFirstElementAddress(); |
| 1811 EnsureCanContainElements(object, objects, length, mode); | 1811 EnsureCanContainElements(object, objects, length, mode); |
| 1812 return; | 1812 return; |
| 1813 } | 1813 } |
| 1814 | 1814 |
| 1815 ASSERT(mode == ALLOW_COPIED_DOUBLE_ELEMENTS); | 1815 DCHECK(mode == ALLOW_COPIED_DOUBLE_ELEMENTS); |
| 1816 if (object->GetElementsKind() == FAST_HOLEY_SMI_ELEMENTS) { | 1816 if (object->GetElementsKind() == FAST_HOLEY_SMI_ELEMENTS) { |
| 1817 TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS); | 1817 TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS); |
| 1818 } else if (object->GetElementsKind() == FAST_SMI_ELEMENTS) { | 1818 } else if (object->GetElementsKind() == FAST_SMI_ELEMENTS) { |
| 1819 Handle<FixedDoubleArray> double_array = | 1819 Handle<FixedDoubleArray> double_array = |
| 1820 Handle<FixedDoubleArray>::cast(elements); | 1820 Handle<FixedDoubleArray>::cast(elements); |
| 1821 for (uint32_t i = 0; i < length; ++i) { | 1821 for (uint32_t i = 0; i < length; ++i) { |
| 1822 if (double_array->is_the_hole(i)) { | 1822 if (double_array->is_the_hole(i)) { |
| 1823 TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS); | 1823 TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS); |
| 1824 return; | 1824 return; |
| 1825 } | 1825 } |
| 1826 } | 1826 } |
| 1827 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); | 1827 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); |
| 1828 } | 1828 } |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 | 1831 |
| 1832 void JSObject::SetMapAndElements(Handle<JSObject> object, | 1832 void JSObject::SetMapAndElements(Handle<JSObject> object, |
| 1833 Handle<Map> new_map, | 1833 Handle<Map> new_map, |
| 1834 Handle<FixedArrayBase> value) { | 1834 Handle<FixedArrayBase> value) { |
| 1835 JSObject::MigrateToMap(object, new_map); | 1835 JSObject::MigrateToMap(object, new_map); |
| 1836 ASSERT((object->map()->has_fast_smi_or_object_elements() || | 1836 DCHECK((object->map()->has_fast_smi_or_object_elements() || |
| 1837 (*value == object->GetHeap()->empty_fixed_array())) == | 1837 (*value == object->GetHeap()->empty_fixed_array())) == |
| 1838 (value->map() == object->GetHeap()->fixed_array_map() || | 1838 (value->map() == object->GetHeap()->fixed_array_map() || |
| 1839 value->map() == object->GetHeap()->fixed_cow_array_map())); | 1839 value->map() == object->GetHeap()->fixed_cow_array_map())); |
| 1840 ASSERT((*value == object->GetHeap()->empty_fixed_array()) || | 1840 DCHECK((*value == object->GetHeap()->empty_fixed_array()) || |
| 1841 (object->map()->has_fast_double_elements() == | 1841 (object->map()->has_fast_double_elements() == |
| 1842 value->IsFixedDoubleArray())); | 1842 value->IsFixedDoubleArray())); |
| 1843 object->set_elements(*value); | 1843 object->set_elements(*value); |
| 1844 } | 1844 } |
| 1845 | 1845 |
| 1846 | 1846 |
| 1847 void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) { | 1847 void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) { |
| 1848 WRITE_FIELD(this, kElementsOffset, value); | 1848 WRITE_FIELD(this, kElementsOffset, value); |
| 1849 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode); | 1849 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, value, mode); |
| 1850 } | 1850 } |
| 1851 | 1851 |
| 1852 | 1852 |
| 1853 void JSObject::initialize_properties() { | 1853 void JSObject::initialize_properties() { |
| 1854 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 1854 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
| 1855 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); | 1855 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); |
| 1856 } | 1856 } |
| 1857 | 1857 |
| 1858 | 1858 |
| 1859 void JSObject::initialize_elements() { | 1859 void JSObject::initialize_elements() { |
| 1860 FixedArrayBase* elements = map()->GetInitialElements(); | 1860 FixedArrayBase* elements = map()->GetInitialElements(); |
| 1861 WRITE_FIELD(this, kElementsOffset, elements); | 1861 WRITE_FIELD(this, kElementsOffset, elements); |
| 1862 } | 1862 } |
| 1863 | 1863 |
| 1864 | 1864 |
| 1865 Handle<String> Map::ExpectedTransitionKey(Handle<Map> map) { | 1865 Handle<String> Map::ExpectedTransitionKey(Handle<Map> map) { |
| 1866 DisallowHeapAllocation no_gc; | 1866 DisallowHeapAllocation no_gc; |
| 1867 if (!map->HasTransitionArray()) return Handle<String>::null(); | 1867 if (!map->HasTransitionArray()) return Handle<String>::null(); |
| 1868 TransitionArray* transitions = map->transitions(); | 1868 TransitionArray* transitions = map->transitions(); |
| 1869 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); | 1869 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); |
| 1870 int transition = TransitionArray::kSimpleTransitionIndex; | 1870 int transition = TransitionArray::kSimpleTransitionIndex; |
| 1871 PropertyDetails details = transitions->GetTargetDetails(transition); | 1871 PropertyDetails details = transitions->GetTargetDetails(transition); |
| 1872 Name* name = transitions->GetKey(transition); | 1872 Name* name = transitions->GetKey(transition); |
| 1873 if (details.type() != FIELD) return Handle<String>::null(); | 1873 if (details.type() != FIELD) return Handle<String>::null(); |
| 1874 if (details.attributes() != NONE) return Handle<String>::null(); | 1874 if (details.attributes() != NONE) return Handle<String>::null(); |
| 1875 if (!name->IsString()) return Handle<String>::null(); | 1875 if (!name->IsString()) return Handle<String>::null(); |
| 1876 return Handle<String>(String::cast(name)); | 1876 return Handle<String>(String::cast(name)); |
| 1877 } | 1877 } |
| 1878 | 1878 |
| 1879 | 1879 |
| 1880 Handle<Map> Map::ExpectedTransitionTarget(Handle<Map> map) { | 1880 Handle<Map> Map::ExpectedTransitionTarget(Handle<Map> map) { |
| 1881 ASSERT(!ExpectedTransitionKey(map).is_null()); | 1881 DCHECK(!ExpectedTransitionKey(map).is_null()); |
| 1882 return Handle<Map>(map->transitions()->GetTarget( | 1882 return Handle<Map>(map->transitions()->GetTarget( |
| 1883 TransitionArray::kSimpleTransitionIndex)); | 1883 TransitionArray::kSimpleTransitionIndex)); |
| 1884 } | 1884 } |
| 1885 | 1885 |
| 1886 | 1886 |
| 1887 Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) { | 1887 Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) { |
| 1888 DisallowHeapAllocation no_allocation; | 1888 DisallowHeapAllocation no_allocation; |
| 1889 if (!map->HasTransitionArray()) return Handle<Map>::null(); | 1889 if (!map->HasTransitionArray()) return Handle<Map>::null(); |
| 1890 TransitionArray* transitions = map->transitions(); | 1890 TransitionArray* transitions = map->transitions(); |
| 1891 int transition = transitions->Search(*key); | 1891 int transition = transitions->Search(*key); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1911 } | 1911 } |
| 1912 | 1912 |
| 1913 | 1913 |
| 1914 Object* Cell::value() const { | 1914 Object* Cell::value() const { |
| 1915 return READ_FIELD(this, kValueOffset); | 1915 return READ_FIELD(this, kValueOffset); |
| 1916 } | 1916 } |
| 1917 | 1917 |
| 1918 | 1918 |
| 1919 void Cell::set_value(Object* val, WriteBarrierMode ignored) { | 1919 void Cell::set_value(Object* val, WriteBarrierMode ignored) { |
| 1920 // The write barrier is not used for global property cells. | 1920 // The write barrier is not used for global property cells. |
| 1921 ASSERT(!val->IsPropertyCell() && !val->IsCell()); | 1921 DCHECK(!val->IsPropertyCell() && !val->IsCell()); |
| 1922 WRITE_FIELD(this, kValueOffset, val); | 1922 WRITE_FIELD(this, kValueOffset, val); |
| 1923 } | 1923 } |
| 1924 | 1924 |
| 1925 ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset) | 1925 ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset) |
| 1926 | 1926 |
| 1927 Object* PropertyCell::type_raw() const { | 1927 Object* PropertyCell::type_raw() const { |
| 1928 return READ_FIELD(this, kTypeOffset); | 1928 return READ_FIELD(this, kTypeOffset); |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 | 1931 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 default: | 1986 default: |
| 1987 // TODO(jkummerow): Re-enable this. Blink currently hits this | 1987 // TODO(jkummerow): Re-enable this. Blink currently hits this |
| 1988 // from its CustomElementConstructorBuilder. | 1988 // from its CustomElementConstructorBuilder. |
| 1989 // UNREACHABLE(); | 1989 // UNREACHABLE(); |
| 1990 return 0; | 1990 return 0; |
| 1991 } | 1991 } |
| 1992 } | 1992 } |
| 1993 | 1993 |
| 1994 | 1994 |
| 1995 int JSObject::GetInternalFieldCount() { | 1995 int JSObject::GetInternalFieldCount() { |
| 1996 ASSERT(1 << kPointerSizeLog2 == kPointerSize); | 1996 DCHECK(1 << kPointerSizeLog2 == kPointerSize); |
| 1997 // Make sure to adjust for the number of in-object properties. These | 1997 // Make sure to adjust for the number of in-object properties. These |
| 1998 // properties do contribute to the size, but are not internal fields. | 1998 // properties do contribute to the size, but are not internal fields. |
| 1999 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - | 1999 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - |
| 2000 map()->inobject_properties(); | 2000 map()->inobject_properties(); |
| 2001 } | 2001 } |
| 2002 | 2002 |
| 2003 | 2003 |
| 2004 int JSObject::GetInternalFieldOffset(int index) { | 2004 int JSObject::GetInternalFieldOffset(int index) { |
| 2005 ASSERT(index < GetInternalFieldCount() && index >= 0); | 2005 DCHECK(index < GetInternalFieldCount() && index >= 0); |
| 2006 return GetHeaderSize() + (kPointerSize * index); | 2006 return GetHeaderSize() + (kPointerSize * index); |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 | 2009 |
| 2010 Object* JSObject::GetInternalField(int index) { | 2010 Object* JSObject::GetInternalField(int index) { |
| 2011 ASSERT(index < GetInternalFieldCount() && index >= 0); | 2011 DCHECK(index < GetInternalFieldCount() && index >= 0); |
| 2012 // Internal objects do follow immediately after the header, whereas in-object | 2012 // Internal objects do follow immediately after the header, whereas in-object |
| 2013 // properties are at the end of the object. Therefore there is no need | 2013 // properties are at the end of the object. Therefore there is no need |
| 2014 // to adjust the index here. | 2014 // to adjust the index here. |
| 2015 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); | 2015 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); |
| 2016 } | 2016 } |
| 2017 | 2017 |
| 2018 | 2018 |
| 2019 void JSObject::SetInternalField(int index, Object* value) { | 2019 void JSObject::SetInternalField(int index, Object* value) { |
| 2020 ASSERT(index < GetInternalFieldCount() && index >= 0); | 2020 DCHECK(index < GetInternalFieldCount() && index >= 0); |
| 2021 // Internal objects do follow immediately after the header, whereas in-object | 2021 // Internal objects do follow immediately after the header, whereas in-object |
| 2022 // properties are at the end of the object. Therefore there is no need | 2022 // properties are at the end of the object. Therefore there is no need |
| 2023 // to adjust the index here. | 2023 // to adjust the index here. |
| 2024 int offset = GetHeaderSize() + (kPointerSize * index); | 2024 int offset = GetHeaderSize() + (kPointerSize * index); |
| 2025 WRITE_FIELD(this, offset, value); | 2025 WRITE_FIELD(this, offset, value); |
| 2026 WRITE_BARRIER(GetHeap(), this, offset, value); | 2026 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2027 } | 2027 } |
| 2028 | 2028 |
| 2029 | 2029 |
| 2030 void JSObject::SetInternalField(int index, Smi* value) { | 2030 void JSObject::SetInternalField(int index, Smi* value) { |
| 2031 ASSERT(index < GetInternalFieldCount() && index >= 0); | 2031 DCHECK(index < GetInternalFieldCount() && index >= 0); |
| 2032 // Internal objects do follow immediately after the header, whereas in-object | 2032 // Internal objects do follow immediately after the header, whereas in-object |
| 2033 // properties are at the end of the object. Therefore there is no need | 2033 // properties are at the end of the object. Therefore there is no need |
| 2034 // to adjust the index here. | 2034 // to adjust the index here. |
| 2035 int offset = GetHeaderSize() + (kPointerSize * index); | 2035 int offset = GetHeaderSize() + (kPointerSize * index); |
| 2036 WRITE_FIELD(this, offset, value); | 2036 WRITE_FIELD(this, offset, value); |
| 2037 } | 2037 } |
| 2038 | 2038 |
| 2039 | 2039 |
| 2040 // Access fast-case object properties at index. The use of these routines | 2040 // Access fast-case object properties at index. The use of these routines |
| 2041 // is needed to correctly distinguish between properties stored in-object and | 2041 // is needed to correctly distinguish between properties stored in-object and |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 WRITE_FIELD(this, offset, value); | 2079 WRITE_FIELD(this, offset, value); |
| 2080 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 2080 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
| 2081 return value; | 2081 return value; |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 | 2084 |
| 2085 | 2085 |
| 2086 void JSObject::InitializeBody(Map* map, | 2086 void JSObject::InitializeBody(Map* map, |
| 2087 Object* pre_allocated_value, | 2087 Object* pre_allocated_value, |
| 2088 Object* filler_value) { | 2088 Object* filler_value) { |
| 2089 ASSERT(!filler_value->IsHeapObject() || | 2089 DCHECK(!filler_value->IsHeapObject() || |
| 2090 !GetHeap()->InNewSpace(filler_value)); | 2090 !GetHeap()->InNewSpace(filler_value)); |
| 2091 ASSERT(!pre_allocated_value->IsHeapObject() || | 2091 DCHECK(!pre_allocated_value->IsHeapObject() || |
| 2092 !GetHeap()->InNewSpace(pre_allocated_value)); | 2092 !GetHeap()->InNewSpace(pre_allocated_value)); |
| 2093 int size = map->instance_size(); | 2093 int size = map->instance_size(); |
| 2094 int offset = kHeaderSize; | 2094 int offset = kHeaderSize; |
| 2095 if (filler_value != pre_allocated_value) { | 2095 if (filler_value != pre_allocated_value) { |
| 2096 int pre_allocated = map->pre_allocated_property_fields(); | 2096 int pre_allocated = map->pre_allocated_property_fields(); |
| 2097 ASSERT(pre_allocated * kPointerSize + kHeaderSize <= size); | 2097 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size); |
| 2098 for (int i = 0; i < pre_allocated; i++) { | 2098 for (int i = 0; i < pre_allocated; i++) { |
| 2099 WRITE_FIELD(this, offset, pre_allocated_value); | 2099 WRITE_FIELD(this, offset, pre_allocated_value); |
| 2100 offset += kPointerSize; | 2100 offset += kPointerSize; |
| 2101 } | 2101 } |
| 2102 } | 2102 } |
| 2103 while (offset < size) { | 2103 while (offset < size) { |
| 2104 WRITE_FIELD(this, offset, filler_value); | 2104 WRITE_FIELD(this, offset, filler_value); |
| 2105 offset += kPointerSize; | 2105 offset += kPointerSize; |
| 2106 } | 2106 } |
| 2107 } | 2107 } |
| 2108 | 2108 |
| 2109 | 2109 |
| 2110 bool JSObject::HasFastProperties() { | 2110 bool JSObject::HasFastProperties() { |
| 2111 ASSERT(properties()->IsDictionary() == map()->is_dictionary_map()); | 2111 DCHECK(properties()->IsDictionary() == map()->is_dictionary_map()); |
| 2112 return !properties()->IsDictionary(); | 2112 return !properties()->IsDictionary(); |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 | 2115 |
| 2116 bool Map::TooManyFastProperties(StoreFromKeyed store_mode) { | 2116 bool Map::TooManyFastProperties(StoreFromKeyed store_mode) { |
| 2117 if (unused_property_fields() != 0) return false; | 2117 if (unused_property_fields() != 0) return false; |
| 2118 int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12; | 2118 int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12; |
| 2119 int limit = Max(minimum, inobject_properties()); | 2119 int limit = Max(minimum, inobject_properties()); |
| 2120 int external = NumberOfFields() - inobject_properties(); | 2120 int external = NumberOfFields() - inobject_properties(); |
| 2121 return external > limit; | 2121 return external > limit; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 IsTrue() || | 2173 IsTrue() || |
| 2174 IsFalse() || | 2174 IsFalse() || |
| 2175 IsNull())) { | 2175 IsNull())) { |
| 2176 FATAL("API call returned invalid object"); | 2176 FATAL("API call returned invalid object"); |
| 2177 } | 2177 } |
| 2178 #endif // ENABLE_EXTRA_CHECKS | 2178 #endif // ENABLE_EXTRA_CHECKS |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 | 2181 |
| 2182 Object* FixedArray::get(int index) { | 2182 Object* FixedArray::get(int index) { |
| 2183 SLOW_ASSERT(index >= 0 && index < this->length()); | 2183 SLOW_DCHECK(index >= 0 && index < this->length()); |
| 2184 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 2184 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
| 2185 } | 2185 } |
| 2186 | 2186 |
| 2187 | 2187 |
| 2188 Handle<Object> FixedArray::get(Handle<FixedArray> array, int index) { | 2188 Handle<Object> FixedArray::get(Handle<FixedArray> array, int index) { |
| 2189 return handle(array->get(index), array->GetIsolate()); | 2189 return handle(array->get(index), array->GetIsolate()); |
| 2190 } | 2190 } |
| 2191 | 2191 |
| 2192 | 2192 |
| 2193 bool FixedArray::is_the_hole(int index) { | 2193 bool FixedArray::is_the_hole(int index) { |
| 2194 return get(index) == GetHeap()->the_hole_value(); | 2194 return get(index) == GetHeap()->the_hole_value(); |
| 2195 } | 2195 } |
| 2196 | 2196 |
| 2197 | 2197 |
| 2198 void FixedArray::set(int index, Smi* value) { | 2198 void FixedArray::set(int index, Smi* value) { |
| 2199 ASSERT(map() != GetHeap()->fixed_cow_array_map()); | 2199 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2200 ASSERT(index >= 0 && index < this->length()); | 2200 DCHECK(index >= 0 && index < this->length()); |
| 2201 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); | 2201 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); |
| 2202 int offset = kHeaderSize + index * kPointerSize; | 2202 int offset = kHeaderSize + index * kPointerSize; |
| 2203 WRITE_FIELD(this, offset, value); | 2203 WRITE_FIELD(this, offset, value); |
| 2204 } | 2204 } |
| 2205 | 2205 |
| 2206 | 2206 |
| 2207 void FixedArray::set(int index, Object* value) { | 2207 void FixedArray::set(int index, Object* value) { |
| 2208 ASSERT(map() != GetHeap()->fixed_cow_array_map()); | 2208 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2209 ASSERT(index >= 0 && index < this->length()); | 2209 DCHECK(index >= 0 && index < this->length()); |
| 2210 int offset = kHeaderSize + index * kPointerSize; | 2210 int offset = kHeaderSize + index * kPointerSize; |
| 2211 WRITE_FIELD(this, offset, value); | 2211 WRITE_FIELD(this, offset, value); |
| 2212 WRITE_BARRIER(GetHeap(), this, offset, value); | 2212 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2213 } | 2213 } |
| 2214 | 2214 |
| 2215 | 2215 |
| 2216 inline bool FixedDoubleArray::is_the_hole_nan(double value) { | 2216 inline bool FixedDoubleArray::is_the_hole_nan(double value) { |
| 2217 return BitCast<uint64_t, double>(value) == kHoleNanInt64; | 2217 return BitCast<uint64_t, double>(value) == kHoleNanInt64; |
| 2218 } | 2218 } |
| 2219 | 2219 |
| 2220 | 2220 |
| 2221 inline double FixedDoubleArray::hole_nan_as_double() { | 2221 inline double FixedDoubleArray::hole_nan_as_double() { |
| 2222 return BitCast<double, uint64_t>(kHoleNanInt64); | 2222 return BitCast<double, uint64_t>(kHoleNanInt64); |
| 2223 } | 2223 } |
| 2224 | 2224 |
| 2225 | 2225 |
| 2226 inline double FixedDoubleArray::canonical_not_the_hole_nan_as_double() { | 2226 inline double FixedDoubleArray::canonical_not_the_hole_nan_as_double() { |
| 2227 ASSERT(BitCast<uint64_t>(base::OS::nan_value()) != kHoleNanInt64); | 2227 DCHECK(BitCast<uint64_t>(base::OS::nan_value()) != kHoleNanInt64); |
| 2228 ASSERT((BitCast<uint64_t>(base::OS::nan_value()) >> 32) != kHoleNanUpper32); | 2228 DCHECK((BitCast<uint64_t>(base::OS::nan_value()) >> 32) != kHoleNanUpper32); |
| 2229 return base::OS::nan_value(); | 2229 return base::OS::nan_value(); |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 | 2232 |
| 2233 double FixedDoubleArray::get_scalar(int index) { | 2233 double FixedDoubleArray::get_scalar(int index) { |
| 2234 ASSERT(map() != GetHeap()->fixed_cow_array_map() && | 2234 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2235 map() != GetHeap()->fixed_array_map()); | 2235 map() != GetHeap()->fixed_array_map()); |
| 2236 ASSERT(index >= 0 && index < this->length()); | 2236 DCHECK(index >= 0 && index < this->length()); |
| 2237 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); | 2237 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); |
| 2238 ASSERT(!is_the_hole_nan(result)); | 2238 DCHECK(!is_the_hole_nan(result)); |
| 2239 return result; | 2239 return result; |
| 2240 } | 2240 } |
| 2241 | 2241 |
| 2242 int64_t FixedDoubleArray::get_representation(int index) { | 2242 int64_t FixedDoubleArray::get_representation(int index) { |
| 2243 ASSERT(map() != GetHeap()->fixed_cow_array_map() && | 2243 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2244 map() != GetHeap()->fixed_array_map()); | 2244 map() != GetHeap()->fixed_array_map()); |
| 2245 ASSERT(index >= 0 && index < this->length()); | 2245 DCHECK(index >= 0 && index < this->length()); |
| 2246 return READ_INT64_FIELD(this, kHeaderSize + index * kDoubleSize); | 2246 return READ_INT64_FIELD(this, kHeaderSize + index * kDoubleSize); |
| 2247 } | 2247 } |
| 2248 | 2248 |
| 2249 | 2249 |
| 2250 Handle<Object> FixedDoubleArray::get(Handle<FixedDoubleArray> array, | 2250 Handle<Object> FixedDoubleArray::get(Handle<FixedDoubleArray> array, |
| 2251 int index) { | 2251 int index) { |
| 2252 if (array->is_the_hole(index)) { | 2252 if (array->is_the_hole(index)) { |
| 2253 return array->GetIsolate()->factory()->the_hole_value(); | 2253 return array->GetIsolate()->factory()->the_hole_value(); |
| 2254 } else { | 2254 } else { |
| 2255 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | 2255 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); |
| 2256 } | 2256 } |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 | 2259 |
| 2260 void FixedDoubleArray::set(int index, double value) { | 2260 void FixedDoubleArray::set(int index, double value) { |
| 2261 ASSERT(map() != GetHeap()->fixed_cow_array_map() && | 2261 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2262 map() != GetHeap()->fixed_array_map()); | 2262 map() != GetHeap()->fixed_array_map()); |
| 2263 int offset = kHeaderSize + index * kDoubleSize; | 2263 int offset = kHeaderSize + index * kDoubleSize; |
| 2264 if (std::isnan(value)) value = canonical_not_the_hole_nan_as_double(); | 2264 if (std::isnan(value)) value = canonical_not_the_hole_nan_as_double(); |
| 2265 WRITE_DOUBLE_FIELD(this, offset, value); | 2265 WRITE_DOUBLE_FIELD(this, offset, value); |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 | 2268 |
| 2269 void FixedDoubleArray::set_the_hole(int index) { | 2269 void FixedDoubleArray::set_the_hole(int index) { |
| 2270 ASSERT(map() != GetHeap()->fixed_cow_array_map() && | 2270 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2271 map() != GetHeap()->fixed_array_map()); | 2271 map() != GetHeap()->fixed_array_map()); |
| 2272 int offset = kHeaderSize + index * kDoubleSize; | 2272 int offset = kHeaderSize + index * kDoubleSize; |
| 2273 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | 2273 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); |
| 2274 } | 2274 } |
| 2275 | 2275 |
| 2276 | 2276 |
| 2277 bool FixedDoubleArray::is_the_hole(int index) { | 2277 bool FixedDoubleArray::is_the_hole(int index) { |
| 2278 int offset = kHeaderSize + index * kDoubleSize; | 2278 int offset = kHeaderSize + index * kDoubleSize; |
| 2279 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); | 2279 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); |
| 2280 } | 2280 } |
| 2281 | 2281 |
| 2282 | 2282 |
| 2283 double* FixedDoubleArray::data_start() { | 2283 double* FixedDoubleArray::data_start() { |
| 2284 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize)); | 2284 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize)); |
| 2285 } | 2285 } |
| 2286 | 2286 |
| 2287 | 2287 |
| 2288 void FixedDoubleArray::FillWithHoles(int from, int to) { | 2288 void FixedDoubleArray::FillWithHoles(int from, int to) { |
| 2289 for (int i = from; i < to; i++) { | 2289 for (int i = from; i < to; i++) { |
| 2290 set_the_hole(i); | 2290 set_the_hole(i); |
| 2291 } | 2291 } |
| 2292 } | 2292 } |
| 2293 | 2293 |
| 2294 | 2294 |
| 2295 void ConstantPoolArray::NumberOfEntries::increment(Type type) { | 2295 void ConstantPoolArray::NumberOfEntries::increment(Type type) { |
| 2296 ASSERT(type < NUMBER_OF_TYPES); | 2296 DCHECK(type < NUMBER_OF_TYPES); |
| 2297 element_counts_[type]++; | 2297 element_counts_[type]++; |
| 2298 } | 2298 } |
| 2299 | 2299 |
| 2300 | 2300 |
| 2301 int ConstantPoolArray::NumberOfEntries::equals( | 2301 int ConstantPoolArray::NumberOfEntries::equals( |
| 2302 const ConstantPoolArray::NumberOfEntries& other) const { | 2302 const ConstantPoolArray::NumberOfEntries& other) const { |
| 2303 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | 2303 for (int i = 0; i < NUMBER_OF_TYPES; i++) { |
| 2304 if (element_counts_[i] != other.element_counts_[i]) return false; | 2304 if (element_counts_[i] != other.element_counts_[i]) return false; |
| 2305 } | 2305 } |
| 2306 return true; | 2306 return true; |
| 2307 } | 2307 } |
| 2308 | 2308 |
| 2309 | 2309 |
| 2310 bool ConstantPoolArray::NumberOfEntries::is_empty() const { | 2310 bool ConstantPoolArray::NumberOfEntries::is_empty() const { |
| 2311 return total_count() == 0; | 2311 return total_count() == 0; |
| 2312 } | 2312 } |
| 2313 | 2313 |
| 2314 | 2314 |
| 2315 int ConstantPoolArray::NumberOfEntries::count_of(Type type) const { | 2315 int ConstantPoolArray::NumberOfEntries::count_of(Type type) const { |
| 2316 ASSERT(type < NUMBER_OF_TYPES); | 2316 DCHECK(type < NUMBER_OF_TYPES); |
| 2317 return element_counts_[type]; | 2317 return element_counts_[type]; |
| 2318 } | 2318 } |
| 2319 | 2319 |
| 2320 | 2320 |
| 2321 int ConstantPoolArray::NumberOfEntries::base_of(Type type) const { | 2321 int ConstantPoolArray::NumberOfEntries::base_of(Type type) const { |
| 2322 int base = 0; | 2322 int base = 0; |
| 2323 ASSERT(type < NUMBER_OF_TYPES); | 2323 DCHECK(type < NUMBER_OF_TYPES); |
| 2324 for (int i = 0; i < type; i++) { | 2324 for (int i = 0; i < type; i++) { |
| 2325 base += element_counts_[i]; | 2325 base += element_counts_[i]; |
| 2326 } | 2326 } |
| 2327 return base; | 2327 return base; |
| 2328 } | 2328 } |
| 2329 | 2329 |
| 2330 | 2330 |
| 2331 int ConstantPoolArray::NumberOfEntries::total_count() const { | 2331 int ConstantPoolArray::NumberOfEntries::total_count() const { |
| 2332 int count = 0; | 2332 int count = 0; |
| 2333 for (int i = 0; i < NUMBER_OF_TYPES; i++) { | 2333 for (int i = 0; i < NUMBER_OF_TYPES; i++) { |
| 2334 count += element_counts_[i]; | 2334 count += element_counts_[i]; |
| 2335 } | 2335 } |
| 2336 return count; | 2336 return count; |
| 2337 } | 2337 } |
| 2338 | 2338 |
| 2339 | 2339 |
| 2340 int ConstantPoolArray::NumberOfEntries::are_in_range(int min, int max) const { | 2340 int ConstantPoolArray::NumberOfEntries::are_in_range(int min, int max) const { |
| 2341 for (int i = FIRST_TYPE; i < NUMBER_OF_TYPES; i++) { | 2341 for (int i = FIRST_TYPE; i < NUMBER_OF_TYPES; i++) { |
| 2342 if (element_counts_[i] < min || element_counts_[i] > max) { | 2342 if (element_counts_[i] < min || element_counts_[i] > max) { |
| 2343 return false; | 2343 return false; |
| 2344 } | 2344 } |
| 2345 } | 2345 } |
| 2346 return true; | 2346 return true; |
| 2347 } | 2347 } |
| 2348 | 2348 |
| 2349 | 2349 |
| 2350 int ConstantPoolArray::Iterator::next_index() { | 2350 int ConstantPoolArray::Iterator::next_index() { |
| 2351 ASSERT(!is_finished()); | 2351 DCHECK(!is_finished()); |
| 2352 int ret = next_index_++; | 2352 int ret = next_index_++; |
| 2353 update_section(); | 2353 update_section(); |
| 2354 return ret; | 2354 return ret; |
| 2355 } | 2355 } |
| 2356 | 2356 |
| 2357 | 2357 |
| 2358 bool ConstantPoolArray::Iterator::is_finished() { | 2358 bool ConstantPoolArray::Iterator::is_finished() { |
| 2359 return next_index_ > array_->last_index(type_, final_section_); | 2359 return next_index_ > array_->last_index(type_, final_section_); |
| 2360 } | 2360 } |
| 2361 | 2361 |
| 2362 | 2362 |
| 2363 void ConstantPoolArray::Iterator::update_section() { | 2363 void ConstantPoolArray::Iterator::update_section() { |
| 2364 if (next_index_ > array_->last_index(type_, current_section_) && | 2364 if (next_index_ > array_->last_index(type_, current_section_) && |
| 2365 current_section_ != final_section_) { | 2365 current_section_ != final_section_) { |
| 2366 ASSERT(final_section_ == EXTENDED_SECTION); | 2366 DCHECK(final_section_ == EXTENDED_SECTION); |
| 2367 current_section_ = EXTENDED_SECTION; | 2367 current_section_ = EXTENDED_SECTION; |
| 2368 next_index_ = array_->first_index(type_, EXTENDED_SECTION); | 2368 next_index_ = array_->first_index(type_, EXTENDED_SECTION); |
| 2369 } | 2369 } |
| 2370 } | 2370 } |
| 2371 | 2371 |
| 2372 | 2372 |
| 2373 bool ConstantPoolArray::is_extended_layout() { | 2373 bool ConstantPoolArray::is_extended_layout() { |
| 2374 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | 2374 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); |
| 2375 return IsExtendedField::decode(small_layout_1); | 2375 return IsExtendedField::decode(small_layout_1); |
| 2376 } | 2376 } |
| 2377 | 2377 |
| 2378 | 2378 |
| 2379 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { | 2379 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { |
| 2380 return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; | 2380 return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; |
| 2381 } | 2381 } |
| 2382 | 2382 |
| 2383 | 2383 |
| 2384 int ConstantPoolArray::first_extended_section_index() { | 2384 int ConstantPoolArray::first_extended_section_index() { |
| 2385 ASSERT(is_extended_layout()); | 2385 DCHECK(is_extended_layout()); |
| 2386 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2386 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); |
| 2387 return TotalCountField::decode(small_layout_2); | 2387 return TotalCountField::decode(small_layout_2); |
| 2388 } | 2388 } |
| 2389 | 2389 |
| 2390 | 2390 |
| 2391 int ConstantPoolArray::get_extended_section_header_offset() { | 2391 int ConstantPoolArray::get_extended_section_header_offset() { |
| 2392 return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); | 2392 return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); |
| 2393 } | 2393 } |
| 2394 | 2394 |
| 2395 | 2395 |
| 2396 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { | 2396 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { |
| 2397 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2397 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); |
| 2398 return WeakObjectStateField::decode(small_layout_2); | 2398 return WeakObjectStateField::decode(small_layout_2); |
| 2399 } | 2399 } |
| 2400 | 2400 |
| 2401 | 2401 |
| 2402 void ConstantPoolArray::set_weak_object_state( | 2402 void ConstantPoolArray::set_weak_object_state( |
| 2403 ConstantPoolArray::WeakObjectState state) { | 2403 ConstantPoolArray::WeakObjectState state) { |
| 2404 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2404 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); |
| 2405 small_layout_2 = WeakObjectStateField::update(small_layout_2, state); | 2405 small_layout_2 = WeakObjectStateField::update(small_layout_2, state); |
| 2406 WRITE_INT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | 2406 WRITE_INT32_FIELD(this, kSmallLayout2Offset, small_layout_2); |
| 2407 } | 2407 } |
| 2408 | 2408 |
| 2409 | 2409 |
| 2410 int ConstantPoolArray::first_index(Type type, LayoutSection section) { | 2410 int ConstantPoolArray::first_index(Type type, LayoutSection section) { |
| 2411 int index = 0; | 2411 int index = 0; |
| 2412 if (section == EXTENDED_SECTION) { | 2412 if (section == EXTENDED_SECTION) { |
| 2413 ASSERT(is_extended_layout()); | 2413 DCHECK(is_extended_layout()); |
| 2414 index += first_extended_section_index(); | 2414 index += first_extended_section_index(); |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 for (Type type_iter = FIRST_TYPE; type_iter < type; | 2417 for (Type type_iter = FIRST_TYPE; type_iter < type; |
| 2418 type_iter = next_type(type_iter)) { | 2418 type_iter = next_type(type_iter)) { |
| 2419 index += number_of_entries(type_iter, section); | 2419 index += number_of_entries(type_iter, section); |
| 2420 } | 2420 } |
| 2421 | 2421 |
| 2422 return index; | 2422 return index; |
| 2423 } | 2423 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2439 return CodePtrCountField::decode(small_layout_1); | 2439 return CodePtrCountField::decode(small_layout_1); |
| 2440 case HEAP_PTR: | 2440 case HEAP_PTR: |
| 2441 return HeapPtrCountField::decode(small_layout_1); | 2441 return HeapPtrCountField::decode(small_layout_1); |
| 2442 case INT32: | 2442 case INT32: |
| 2443 return Int32CountField::decode(small_layout_2); | 2443 return Int32CountField::decode(small_layout_2); |
| 2444 default: | 2444 default: |
| 2445 UNREACHABLE(); | 2445 UNREACHABLE(); |
| 2446 return 0; | 2446 return 0; |
| 2447 } | 2447 } |
| 2448 } else { | 2448 } else { |
| 2449 ASSERT(section == EXTENDED_SECTION && is_extended_layout()); | 2449 DCHECK(section == EXTENDED_SECTION && is_extended_layout()); |
| 2450 int offset = get_extended_section_header_offset(); | 2450 int offset = get_extended_section_header_offset(); |
| 2451 switch (type) { | 2451 switch (type) { |
| 2452 case INT64: | 2452 case INT64: |
| 2453 offset += kExtendedInt64CountOffset; | 2453 offset += kExtendedInt64CountOffset; |
| 2454 break; | 2454 break; |
| 2455 case CODE_PTR: | 2455 case CODE_PTR: |
| 2456 offset += kExtendedCodePtrCountOffset; | 2456 offset += kExtendedCodePtrCountOffset; |
| 2457 break; | 2457 break; |
| 2458 case HEAP_PTR: | 2458 case HEAP_PTR: |
| 2459 offset += kExtendedHeapPtrCountOffset; | 2459 offset += kExtendedHeapPtrCountOffset; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2483 if (is_extended_layout() && index >= first_extended_section_index()) { | 2483 if (is_extended_layout() && index >= first_extended_section_index()) { |
| 2484 section = EXTENDED_SECTION; | 2484 section = EXTENDED_SECTION; |
| 2485 } else { | 2485 } else { |
| 2486 section = SMALL_SECTION; | 2486 section = SMALL_SECTION; |
| 2487 } | 2487 } |
| 2488 | 2488 |
| 2489 Type type = FIRST_TYPE; | 2489 Type type = FIRST_TYPE; |
| 2490 while (index > last_index(type, section)) { | 2490 while (index > last_index(type, section)) { |
| 2491 type = next_type(type); | 2491 type = next_type(type); |
| 2492 } | 2492 } |
| 2493 ASSERT(type <= LAST_TYPE); | 2493 DCHECK(type <= LAST_TYPE); |
| 2494 return type; | 2494 return type; |
| 2495 } | 2495 } |
| 2496 | 2496 |
| 2497 | 2497 |
| 2498 int64_t ConstantPoolArray::get_int64_entry(int index) { | 2498 int64_t ConstantPoolArray::get_int64_entry(int index) { |
| 2499 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2499 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2500 ASSERT(get_type(index) == INT64); | 2500 DCHECK(get_type(index) == INT64); |
| 2501 return READ_INT64_FIELD(this, OffsetOfElementAt(index)); | 2501 return READ_INT64_FIELD(this, OffsetOfElementAt(index)); |
| 2502 } | 2502 } |
| 2503 | 2503 |
| 2504 | 2504 |
| 2505 double ConstantPoolArray::get_int64_entry_as_double(int index) { | 2505 double ConstantPoolArray::get_int64_entry_as_double(int index) { |
| 2506 STATIC_ASSERT(kDoubleSize == kInt64Size); | 2506 STATIC_ASSERT(kDoubleSize == kInt64Size); |
| 2507 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2507 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2508 ASSERT(get_type(index) == INT64); | 2508 DCHECK(get_type(index) == INT64); |
| 2509 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); | 2509 return READ_DOUBLE_FIELD(this, OffsetOfElementAt(index)); |
| 2510 } | 2510 } |
| 2511 | 2511 |
| 2512 | 2512 |
| 2513 Address ConstantPoolArray::get_code_ptr_entry(int index) { | 2513 Address ConstantPoolArray::get_code_ptr_entry(int index) { |
| 2514 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2514 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2515 ASSERT(get_type(index) == CODE_PTR); | 2515 DCHECK(get_type(index) == CODE_PTR); |
| 2516 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index))); | 2516 return reinterpret_cast<Address>(READ_FIELD(this, OffsetOfElementAt(index))); |
| 2517 } | 2517 } |
| 2518 | 2518 |
| 2519 | 2519 |
| 2520 Object* ConstantPoolArray::get_heap_ptr_entry(int index) { | 2520 Object* ConstantPoolArray::get_heap_ptr_entry(int index) { |
| 2521 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2521 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2522 ASSERT(get_type(index) == HEAP_PTR); | 2522 DCHECK(get_type(index) == HEAP_PTR); |
| 2523 return READ_FIELD(this, OffsetOfElementAt(index)); | 2523 return READ_FIELD(this, OffsetOfElementAt(index)); |
| 2524 } | 2524 } |
| 2525 | 2525 |
| 2526 | 2526 |
| 2527 int32_t ConstantPoolArray::get_int32_entry(int index) { | 2527 int32_t ConstantPoolArray::get_int32_entry(int index) { |
| 2528 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2528 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2529 ASSERT(get_type(index) == INT32); | 2529 DCHECK(get_type(index) == INT32); |
| 2530 return READ_INT32_FIELD(this, OffsetOfElementAt(index)); | 2530 return READ_INT32_FIELD(this, OffsetOfElementAt(index)); |
| 2531 } | 2531 } |
| 2532 | 2532 |
| 2533 | 2533 |
| 2534 void ConstantPoolArray::set(int index, int64_t value) { | 2534 void ConstantPoolArray::set(int index, int64_t value) { |
| 2535 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2535 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2536 ASSERT(get_type(index) == INT64); | 2536 DCHECK(get_type(index) == INT64); |
| 2537 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); | 2537 WRITE_INT64_FIELD(this, OffsetOfElementAt(index), value); |
| 2538 } | 2538 } |
| 2539 | 2539 |
| 2540 | 2540 |
| 2541 void ConstantPoolArray::set(int index, double value) { | 2541 void ConstantPoolArray::set(int index, double value) { |
| 2542 STATIC_ASSERT(kDoubleSize == kInt64Size); | 2542 STATIC_ASSERT(kDoubleSize == kInt64Size); |
| 2543 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2543 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2544 ASSERT(get_type(index) == INT64); | 2544 DCHECK(get_type(index) == INT64); |
| 2545 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value); | 2545 WRITE_DOUBLE_FIELD(this, OffsetOfElementAt(index), value); |
| 2546 } | 2546 } |
| 2547 | 2547 |
| 2548 | 2548 |
| 2549 void ConstantPoolArray::set(int index, Address value) { | 2549 void ConstantPoolArray::set(int index, Address value) { |
| 2550 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2550 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2551 ASSERT(get_type(index) == CODE_PTR); | 2551 DCHECK(get_type(index) == CODE_PTR); |
| 2552 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value)); | 2552 WRITE_FIELD(this, OffsetOfElementAt(index), reinterpret_cast<Object*>(value)); |
| 2553 } | 2553 } |
| 2554 | 2554 |
| 2555 | 2555 |
| 2556 void ConstantPoolArray::set(int index, Object* value) { | 2556 void ConstantPoolArray::set(int index, Object* value) { |
| 2557 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2557 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2558 ASSERT(!GetHeap()->InNewSpace(value)); | 2558 DCHECK(!GetHeap()->InNewSpace(value)); |
| 2559 ASSERT(get_type(index) == HEAP_PTR); | 2559 DCHECK(get_type(index) == HEAP_PTR); |
| 2560 WRITE_FIELD(this, OffsetOfElementAt(index), value); | 2560 WRITE_FIELD(this, OffsetOfElementAt(index), value); |
| 2561 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); | 2561 WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value); |
| 2562 } | 2562 } |
| 2563 | 2563 |
| 2564 | 2564 |
| 2565 void ConstantPoolArray::set(int index, int32_t value) { | 2565 void ConstantPoolArray::set(int index, int32_t value) { |
| 2566 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2566 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2567 ASSERT(get_type(index) == INT32); | 2567 DCHECK(get_type(index) == INT32); |
| 2568 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value); | 2568 WRITE_INT32_FIELD(this, OffsetOfElementAt(index), value); |
| 2569 } | 2569 } |
| 2570 | 2570 |
| 2571 | 2571 |
| 2572 void ConstantPoolArray::set_at_offset(int offset, int32_t value) { | 2572 void ConstantPoolArray::set_at_offset(int offset, int32_t value) { |
| 2573 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2573 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2574 ASSERT(offset_is_type(offset, INT32)); | 2574 DCHECK(offset_is_type(offset, INT32)); |
| 2575 WRITE_INT32_FIELD(this, offset, value); | 2575 WRITE_INT32_FIELD(this, offset, value); |
| 2576 } | 2576 } |
| 2577 | 2577 |
| 2578 | 2578 |
| 2579 void ConstantPoolArray::set_at_offset(int offset, int64_t value) { | 2579 void ConstantPoolArray::set_at_offset(int offset, int64_t value) { |
| 2580 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2580 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2581 ASSERT(offset_is_type(offset, INT64)); | 2581 DCHECK(offset_is_type(offset, INT64)); |
| 2582 WRITE_INT64_FIELD(this, offset, value); | 2582 WRITE_INT64_FIELD(this, offset, value); |
| 2583 } | 2583 } |
| 2584 | 2584 |
| 2585 | 2585 |
| 2586 void ConstantPoolArray::set_at_offset(int offset, double value) { | 2586 void ConstantPoolArray::set_at_offset(int offset, double value) { |
| 2587 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2587 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2588 ASSERT(offset_is_type(offset, INT64)); | 2588 DCHECK(offset_is_type(offset, INT64)); |
| 2589 WRITE_DOUBLE_FIELD(this, offset, value); | 2589 WRITE_DOUBLE_FIELD(this, offset, value); |
| 2590 } | 2590 } |
| 2591 | 2591 |
| 2592 | 2592 |
| 2593 void ConstantPoolArray::set_at_offset(int offset, Address value) { | 2593 void ConstantPoolArray::set_at_offset(int offset, Address value) { |
| 2594 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2594 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2595 ASSERT(offset_is_type(offset, CODE_PTR)); | 2595 DCHECK(offset_is_type(offset, CODE_PTR)); |
| 2596 WRITE_FIELD(this, offset, reinterpret_cast<Object*>(value)); | 2596 WRITE_FIELD(this, offset, reinterpret_cast<Object*>(value)); |
| 2597 WRITE_BARRIER(GetHeap(), this, offset, reinterpret_cast<Object*>(value)); | 2597 WRITE_BARRIER(GetHeap(), this, offset, reinterpret_cast<Object*>(value)); |
| 2598 } | 2598 } |
| 2599 | 2599 |
| 2600 | 2600 |
| 2601 void ConstantPoolArray::set_at_offset(int offset, Object* value) { | 2601 void ConstantPoolArray::set_at_offset(int offset, Object* value) { |
| 2602 ASSERT(map() == GetHeap()->constant_pool_array_map()); | 2602 DCHECK(map() == GetHeap()->constant_pool_array_map()); |
| 2603 ASSERT(!GetHeap()->InNewSpace(value)); | 2603 DCHECK(!GetHeap()->InNewSpace(value)); |
| 2604 ASSERT(offset_is_type(offset, HEAP_PTR)); | 2604 DCHECK(offset_is_type(offset, HEAP_PTR)); |
| 2605 WRITE_FIELD(this, offset, value); | 2605 WRITE_FIELD(this, offset, value); |
| 2606 WRITE_BARRIER(GetHeap(), this, offset, value); | 2606 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2607 } | 2607 } |
| 2608 | 2608 |
| 2609 | 2609 |
| 2610 void ConstantPoolArray::Init(const NumberOfEntries& small) { | 2610 void ConstantPoolArray::Init(const NumberOfEntries& small) { |
| 2611 uint32_t small_layout_1 = | 2611 uint32_t small_layout_1 = |
| 2612 Int64CountField::encode(small.count_of(INT64)) | | 2612 Int64CountField::encode(small.count_of(INT64)) | |
| 2613 CodePtrCountField::encode(small.count_of(CODE_PTR)) | | 2613 CodePtrCountField::encode(small.count_of(CODE_PTR)) | |
| 2614 HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | | 2614 HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | |
| 2615 IsExtendedField::encode(false); | 2615 IsExtendedField::encode(false); |
| 2616 uint32_t small_layout_2 = | 2616 uint32_t small_layout_2 = |
| 2617 Int32CountField::encode(small.count_of(INT32)) | | 2617 Int32CountField::encode(small.count_of(INT32)) | |
| 2618 TotalCountField::encode(small.total_count()) | | 2618 TotalCountField::encode(small.total_count()) | |
| 2619 WeakObjectStateField::encode(NO_WEAK_OBJECTS); | 2619 WeakObjectStateField::encode(NO_WEAK_OBJECTS); |
| 2620 WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | 2620 WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); |
| 2621 WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | 2621 WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); |
| 2622 if (kHeaderSize != kFirstEntryOffset) { | 2622 if (kHeaderSize != kFirstEntryOffset) { |
| 2623 ASSERT(kFirstEntryOffset - kHeaderSize == kInt32Size); | 2623 DCHECK(kFirstEntryOffset - kHeaderSize == kInt32Size); |
| 2624 WRITE_UINT32_FIELD(this, kHeaderSize, 0); // Zero out header padding. | 2624 WRITE_UINT32_FIELD(this, kHeaderSize, 0); // Zero out header padding. |
| 2625 } | 2625 } |
| 2626 } | 2626 } |
| 2627 | 2627 |
| 2628 | 2628 |
| 2629 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, | 2629 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, |
| 2630 const NumberOfEntries& extended) { | 2630 const NumberOfEntries& extended) { |
| 2631 // Initialize small layout fields first. | 2631 // Initialize small layout fields first. |
| 2632 Init(small); | 2632 Init(small); |
| 2633 | 2633 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 Heap* heap = GetHeap(); | 2678 Heap* heap = GetHeap(); |
| 2679 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; | 2679 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; |
| 2680 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 2680 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; |
| 2681 return UPDATE_WRITE_BARRIER; | 2681 return UPDATE_WRITE_BARRIER; |
| 2682 } | 2682 } |
| 2683 | 2683 |
| 2684 | 2684 |
| 2685 void FixedArray::set(int index, | 2685 void FixedArray::set(int index, |
| 2686 Object* value, | 2686 Object* value, |
| 2687 WriteBarrierMode mode) { | 2687 WriteBarrierMode mode) { |
| 2688 ASSERT(map() != GetHeap()->fixed_cow_array_map()); | 2688 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2689 ASSERT(index >= 0 && index < this->length()); | 2689 DCHECK(index >= 0 && index < this->length()); |
| 2690 int offset = kHeaderSize + index * kPointerSize; | 2690 int offset = kHeaderSize + index * kPointerSize; |
| 2691 WRITE_FIELD(this, offset, value); | 2691 WRITE_FIELD(this, offset, value); |
| 2692 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 2692 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
| 2693 } | 2693 } |
| 2694 | 2694 |
| 2695 | 2695 |
| 2696 void FixedArray::NoIncrementalWriteBarrierSet(FixedArray* array, | 2696 void FixedArray::NoIncrementalWriteBarrierSet(FixedArray* array, |
| 2697 int index, | 2697 int index, |
| 2698 Object* value) { | 2698 Object* value) { |
| 2699 ASSERT(array->map() != array->GetHeap()->fixed_cow_array_map()); | 2699 DCHECK(array->map() != array->GetHeap()->fixed_cow_array_map()); |
| 2700 ASSERT(index >= 0 && index < array->length()); | 2700 DCHECK(index >= 0 && index < array->length()); |
| 2701 int offset = kHeaderSize + index * kPointerSize; | 2701 int offset = kHeaderSize + index * kPointerSize; |
| 2702 WRITE_FIELD(array, offset, value); | 2702 WRITE_FIELD(array, offset, value); |
| 2703 Heap* heap = array->GetHeap(); | 2703 Heap* heap = array->GetHeap(); |
| 2704 if (heap->InNewSpace(value)) { | 2704 if (heap->InNewSpace(value)) { |
| 2705 heap->RecordWrite(array->address(), offset); | 2705 heap->RecordWrite(array->address(), offset); |
| 2706 } | 2706 } |
| 2707 } | 2707 } |
| 2708 | 2708 |
| 2709 | 2709 |
| 2710 void FixedArray::NoWriteBarrierSet(FixedArray* array, | 2710 void FixedArray::NoWriteBarrierSet(FixedArray* array, |
| 2711 int index, | 2711 int index, |
| 2712 Object* value) { | 2712 Object* value) { |
| 2713 ASSERT(array->map() != array->GetHeap()->fixed_cow_array_map()); | 2713 DCHECK(array->map() != array->GetHeap()->fixed_cow_array_map()); |
| 2714 ASSERT(index >= 0 && index < array->length()); | 2714 DCHECK(index >= 0 && index < array->length()); |
| 2715 ASSERT(!array->GetHeap()->InNewSpace(value)); | 2715 DCHECK(!array->GetHeap()->InNewSpace(value)); |
| 2716 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); | 2716 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); |
| 2717 } | 2717 } |
| 2718 | 2718 |
| 2719 | 2719 |
| 2720 void FixedArray::set_undefined(int index) { | 2720 void FixedArray::set_undefined(int index) { |
| 2721 ASSERT(map() != GetHeap()->fixed_cow_array_map()); | 2721 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2722 ASSERT(index >= 0 && index < this->length()); | 2722 DCHECK(index >= 0 && index < this->length()); |
| 2723 ASSERT(!GetHeap()->InNewSpace(GetHeap()->undefined_value())); | 2723 DCHECK(!GetHeap()->InNewSpace(GetHeap()->undefined_value())); |
| 2724 WRITE_FIELD(this, | 2724 WRITE_FIELD(this, |
| 2725 kHeaderSize + index * kPointerSize, | 2725 kHeaderSize + index * kPointerSize, |
| 2726 GetHeap()->undefined_value()); | 2726 GetHeap()->undefined_value()); |
| 2727 } | 2727 } |
| 2728 | 2728 |
| 2729 | 2729 |
| 2730 void FixedArray::set_null(int index) { | 2730 void FixedArray::set_null(int index) { |
| 2731 ASSERT(index >= 0 && index < this->length()); | 2731 DCHECK(index >= 0 && index < this->length()); |
| 2732 ASSERT(!GetHeap()->InNewSpace(GetHeap()->null_value())); | 2732 DCHECK(!GetHeap()->InNewSpace(GetHeap()->null_value())); |
| 2733 WRITE_FIELD(this, | 2733 WRITE_FIELD(this, |
| 2734 kHeaderSize + index * kPointerSize, | 2734 kHeaderSize + index * kPointerSize, |
| 2735 GetHeap()->null_value()); | 2735 GetHeap()->null_value()); |
| 2736 } | 2736 } |
| 2737 | 2737 |
| 2738 | 2738 |
| 2739 void FixedArray::set_the_hole(int index) { | 2739 void FixedArray::set_the_hole(int index) { |
| 2740 ASSERT(map() != GetHeap()->fixed_cow_array_map()); | 2740 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
| 2741 ASSERT(index >= 0 && index < this->length()); | 2741 DCHECK(index >= 0 && index < this->length()); |
| 2742 ASSERT(!GetHeap()->InNewSpace(GetHeap()->the_hole_value())); | 2742 DCHECK(!GetHeap()->InNewSpace(GetHeap()->the_hole_value())); |
| 2743 WRITE_FIELD(this, | 2743 WRITE_FIELD(this, |
| 2744 kHeaderSize + index * kPointerSize, | 2744 kHeaderSize + index * kPointerSize, |
| 2745 GetHeap()->the_hole_value()); | 2745 GetHeap()->the_hole_value()); |
| 2746 } | 2746 } |
| 2747 | 2747 |
| 2748 | 2748 |
| 2749 void FixedArray::FillWithHoles(int from, int to) { | 2749 void FixedArray::FillWithHoles(int from, int to) { |
| 2750 for (int i = from; i < to; i++) { | 2750 for (int i = from; i < to; i++) { |
| 2751 set_the_hole(i); | 2751 set_the_hole(i); |
| 2752 } | 2752 } |
| 2753 } | 2753 } |
| 2754 | 2754 |
| 2755 | 2755 |
| 2756 Object** FixedArray::data_start() { | 2756 Object** FixedArray::data_start() { |
| 2757 return HeapObject::RawField(this, kHeaderSize); | 2757 return HeapObject::RawField(this, kHeaderSize); |
| 2758 } | 2758 } |
| 2759 | 2759 |
| 2760 | 2760 |
| 2761 bool DescriptorArray::IsEmpty() { | 2761 bool DescriptorArray::IsEmpty() { |
| 2762 ASSERT(length() >= kFirstIndex || | 2762 DCHECK(length() >= kFirstIndex || |
| 2763 this == GetHeap()->empty_descriptor_array()); | 2763 this == GetHeap()->empty_descriptor_array()); |
| 2764 return length() < kFirstIndex; | 2764 return length() < kFirstIndex; |
| 2765 } | 2765 } |
| 2766 | 2766 |
| 2767 | 2767 |
| 2768 void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) { | 2768 void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) { |
| 2769 WRITE_FIELD( | 2769 WRITE_FIELD( |
| 2770 this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors)); | 2770 this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors)); |
| 2771 } | 2771 } |
| 2772 | 2772 |
| 2773 | 2773 |
| 2774 // Perform a binary search in a fixed array. Low and high are entry indices. If | 2774 // Perform a binary search in a fixed array. Low and high are entry indices. If |
| 2775 // there are three entries in this array it should be called with low=0 and | 2775 // there are three entries in this array it should be called with low=0 and |
| 2776 // high=2. | 2776 // high=2. |
| 2777 template<SearchMode search_mode, typename T> | 2777 template<SearchMode search_mode, typename T> |
| 2778 int BinarySearch(T* array, Name* name, int low, int high, int valid_entries) { | 2778 int BinarySearch(T* array, Name* name, int low, int high, int valid_entries) { |
| 2779 uint32_t hash = name->Hash(); | 2779 uint32_t hash = name->Hash(); |
| 2780 int limit = high; | 2780 int limit = high; |
| 2781 | 2781 |
| 2782 ASSERT(low <= high); | 2782 DCHECK(low <= high); |
| 2783 | 2783 |
| 2784 while (low != high) { | 2784 while (low != high) { |
| 2785 int mid = (low + high) / 2; | 2785 int mid = (low + high) / 2; |
| 2786 Name* mid_name = array->GetSortedKey(mid); | 2786 Name* mid_name = array->GetSortedKey(mid); |
| 2787 uint32_t mid_hash = mid_name->Hash(); | 2787 uint32_t mid_hash = mid_name->Hash(); |
| 2788 | 2788 |
| 2789 if (mid_hash >= hash) { | 2789 if (mid_hash >= hash) { |
| 2790 high = mid; | 2790 high = mid; |
| 2791 } else { | 2791 } else { |
| 2792 low = mid + 1; | 2792 low = mid + 1; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2816 uint32_t hash = name->Hash(); | 2816 uint32_t hash = name->Hash(); |
| 2817 if (search_mode == ALL_ENTRIES) { | 2817 if (search_mode == ALL_ENTRIES) { |
| 2818 for (int number = 0; number < len; number++) { | 2818 for (int number = 0; number < len; number++) { |
| 2819 int sorted_index = array->GetSortedKeyIndex(number); | 2819 int sorted_index = array->GetSortedKeyIndex(number); |
| 2820 Name* entry = array->GetKey(sorted_index); | 2820 Name* entry = array->GetKey(sorted_index); |
| 2821 uint32_t current_hash = entry->Hash(); | 2821 uint32_t current_hash = entry->Hash(); |
| 2822 if (current_hash > hash) break; | 2822 if (current_hash > hash) break; |
| 2823 if (current_hash == hash && entry->Equals(name)) return sorted_index; | 2823 if (current_hash == hash && entry->Equals(name)) return sorted_index; |
| 2824 } | 2824 } |
| 2825 } else { | 2825 } else { |
| 2826 ASSERT(len >= valid_entries); | 2826 DCHECK(len >= valid_entries); |
| 2827 for (int number = 0; number < valid_entries; number++) { | 2827 for (int number = 0; number < valid_entries; number++) { |
| 2828 Name* entry = array->GetKey(number); | 2828 Name* entry = array->GetKey(number); |
| 2829 uint32_t current_hash = entry->Hash(); | 2829 uint32_t current_hash = entry->Hash(); |
| 2830 if (current_hash == hash && entry->Equals(name)) return number; | 2830 if (current_hash == hash && entry->Equals(name)) return number; |
| 2831 } | 2831 } |
| 2832 } | 2832 } |
| 2833 return T::kNotFound; | 2833 return T::kNotFound; |
| 2834 } | 2834 } |
| 2835 | 2835 |
| 2836 | 2836 |
| 2837 template<SearchMode search_mode, typename T> | 2837 template<SearchMode search_mode, typename T> |
| 2838 int Search(T* array, Name* name, int valid_entries) { | 2838 int Search(T* array, Name* name, int valid_entries) { |
| 2839 if (search_mode == VALID_ENTRIES) { | 2839 if (search_mode == VALID_ENTRIES) { |
| 2840 SLOW_ASSERT(array->IsSortedNoDuplicates(valid_entries)); | 2840 SLOW_DCHECK(array->IsSortedNoDuplicates(valid_entries)); |
| 2841 } else { | 2841 } else { |
| 2842 SLOW_ASSERT(array->IsSortedNoDuplicates()); | 2842 SLOW_DCHECK(array->IsSortedNoDuplicates()); |
| 2843 } | 2843 } |
| 2844 | 2844 |
| 2845 int nof = array->number_of_entries(); | 2845 int nof = array->number_of_entries(); |
| 2846 if (nof == 0) return T::kNotFound; | 2846 if (nof == 0) return T::kNotFound; |
| 2847 | 2847 |
| 2848 // Fast case: do linear search for small arrays. | 2848 // Fast case: do linear search for small arrays. |
| 2849 const int kMaxElementsForLinearSearch = 8; | 2849 const int kMaxElementsForLinearSearch = 8; |
| 2850 if ((search_mode == ALL_ENTRIES && | 2850 if ((search_mode == ALL_ENTRIES && |
| 2851 nof <= kMaxElementsForLinearSearch) || | 2851 nof <= kMaxElementsForLinearSearch) || |
| 2852 (search_mode == VALID_ENTRIES && | 2852 (search_mode == VALID_ENTRIES && |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 LookupResult* result) { | 2900 LookupResult* result) { |
| 2901 int transition_index = this->SearchTransition(name); | 2901 int transition_index = this->SearchTransition(name); |
| 2902 if (transition_index == TransitionArray::kNotFound) return result->NotFound(); | 2902 if (transition_index == TransitionArray::kNotFound) return result->NotFound(); |
| 2903 result->TransitionResult(holder, this->GetTransition(transition_index)); | 2903 result->TransitionResult(holder, this->GetTransition(transition_index)); |
| 2904 } | 2904 } |
| 2905 | 2905 |
| 2906 | 2906 |
| 2907 FixedArrayBase* Map::GetInitialElements() { | 2907 FixedArrayBase* Map::GetInitialElements() { |
| 2908 if (has_fast_smi_or_object_elements() || | 2908 if (has_fast_smi_or_object_elements() || |
| 2909 has_fast_double_elements()) { | 2909 has_fast_double_elements()) { |
| 2910 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 2910 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
| 2911 return GetHeap()->empty_fixed_array(); | 2911 return GetHeap()->empty_fixed_array(); |
| 2912 } else if (has_external_array_elements()) { | 2912 } else if (has_external_array_elements()) { |
| 2913 ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(this); | 2913 ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(this); |
| 2914 ASSERT(!GetHeap()->InNewSpace(empty_array)); | 2914 DCHECK(!GetHeap()->InNewSpace(empty_array)); |
| 2915 return empty_array; | 2915 return empty_array; |
| 2916 } else if (has_fixed_typed_array_elements()) { | 2916 } else if (has_fixed_typed_array_elements()) { |
| 2917 FixedTypedArrayBase* empty_array = | 2917 FixedTypedArrayBase* empty_array = |
| 2918 GetHeap()->EmptyFixedTypedArrayForMap(this); | 2918 GetHeap()->EmptyFixedTypedArrayForMap(this); |
| 2919 ASSERT(!GetHeap()->InNewSpace(empty_array)); | 2919 DCHECK(!GetHeap()->InNewSpace(empty_array)); |
| 2920 return empty_array; | 2920 return empty_array; |
| 2921 } else if (has_dictionary_elements()) { | 2921 } else if (has_dictionary_elements()) { |
| 2922 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_slow_element_dictionary())); | 2922 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_slow_element_dictionary())); |
| 2923 return GetHeap()->empty_slow_element_dictionary(); | 2923 return GetHeap()->empty_slow_element_dictionary(); |
| 2924 } else { | 2924 } else { |
| 2925 UNREACHABLE(); | 2925 UNREACHABLE(); |
| 2926 } | 2926 } |
| 2927 return NULL; | 2927 return NULL; |
| 2928 } | 2928 } |
| 2929 | 2929 |
| 2930 | 2930 |
| 2931 Object** DescriptorArray::GetKeySlot(int descriptor_number) { | 2931 Object** DescriptorArray::GetKeySlot(int descriptor_number) { |
| 2932 ASSERT(descriptor_number < number_of_descriptors()); | 2932 DCHECK(descriptor_number < number_of_descriptors()); |
| 2933 return RawFieldOfElementAt(ToKeyIndex(descriptor_number)); | 2933 return RawFieldOfElementAt(ToKeyIndex(descriptor_number)); |
| 2934 } | 2934 } |
| 2935 | 2935 |
| 2936 | 2936 |
| 2937 Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) { | 2937 Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) { |
| 2938 return GetKeySlot(descriptor_number); | 2938 return GetKeySlot(descriptor_number); |
| 2939 } | 2939 } |
| 2940 | 2940 |
| 2941 | 2941 |
| 2942 Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) { | 2942 Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) { |
| 2943 return GetValueSlot(descriptor_number - 1) + 1; | 2943 return GetValueSlot(descriptor_number - 1) + 1; |
| 2944 } | 2944 } |
| 2945 | 2945 |
| 2946 | 2946 |
| 2947 Name* DescriptorArray::GetKey(int descriptor_number) { | 2947 Name* DescriptorArray::GetKey(int descriptor_number) { |
| 2948 ASSERT(descriptor_number < number_of_descriptors()); | 2948 DCHECK(descriptor_number < number_of_descriptors()); |
| 2949 return Name::cast(get(ToKeyIndex(descriptor_number))); | 2949 return Name::cast(get(ToKeyIndex(descriptor_number))); |
| 2950 } | 2950 } |
| 2951 | 2951 |
| 2952 | 2952 |
| 2953 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { | 2953 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { |
| 2954 return GetDetails(descriptor_number).pointer(); | 2954 return GetDetails(descriptor_number).pointer(); |
| 2955 } | 2955 } |
| 2956 | 2956 |
| 2957 | 2957 |
| 2958 Name* DescriptorArray::GetSortedKey(int descriptor_number) { | 2958 Name* DescriptorArray::GetSortedKey(int descriptor_number) { |
| 2959 return GetKey(GetSortedKeyIndex(descriptor_number)); | 2959 return GetKey(GetSortedKeyIndex(descriptor_number)); |
| 2960 } | 2960 } |
| 2961 | 2961 |
| 2962 | 2962 |
| 2963 void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) { | 2963 void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) { |
| 2964 PropertyDetails details = GetDetails(descriptor_index); | 2964 PropertyDetails details = GetDetails(descriptor_index); |
| 2965 set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi()); | 2965 set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi()); |
| 2966 } | 2966 } |
| 2967 | 2967 |
| 2968 | 2968 |
| 2969 void DescriptorArray::SetRepresentation(int descriptor_index, | 2969 void DescriptorArray::SetRepresentation(int descriptor_index, |
| 2970 Representation representation) { | 2970 Representation representation) { |
| 2971 ASSERT(!representation.IsNone()); | 2971 DCHECK(!representation.IsNone()); |
| 2972 PropertyDetails details = GetDetails(descriptor_index); | 2972 PropertyDetails details = GetDetails(descriptor_index); |
| 2973 set(ToDetailsIndex(descriptor_index), | 2973 set(ToDetailsIndex(descriptor_index), |
| 2974 details.CopyWithRepresentation(representation).AsSmi()); | 2974 details.CopyWithRepresentation(representation).AsSmi()); |
| 2975 } | 2975 } |
| 2976 | 2976 |
| 2977 | 2977 |
| 2978 Object** DescriptorArray::GetValueSlot(int descriptor_number) { | 2978 Object** DescriptorArray::GetValueSlot(int descriptor_number) { |
| 2979 ASSERT(descriptor_number < number_of_descriptors()); | 2979 DCHECK(descriptor_number < number_of_descriptors()); |
| 2980 return RawFieldOfElementAt(ToValueIndex(descriptor_number)); | 2980 return RawFieldOfElementAt(ToValueIndex(descriptor_number)); |
| 2981 } | 2981 } |
| 2982 | 2982 |
| 2983 | 2983 |
| 2984 Object* DescriptorArray::GetValue(int descriptor_number) { | 2984 Object* DescriptorArray::GetValue(int descriptor_number) { |
| 2985 ASSERT(descriptor_number < number_of_descriptors()); | 2985 DCHECK(descriptor_number < number_of_descriptors()); |
| 2986 return get(ToValueIndex(descriptor_number)); | 2986 return get(ToValueIndex(descriptor_number)); |
| 2987 } | 2987 } |
| 2988 | 2988 |
| 2989 | 2989 |
| 2990 void DescriptorArray::SetValue(int descriptor_index, Object* value) { | 2990 void DescriptorArray::SetValue(int descriptor_index, Object* value) { |
| 2991 set(ToValueIndex(descriptor_index), value); | 2991 set(ToValueIndex(descriptor_index), value); |
| 2992 } | 2992 } |
| 2993 | 2993 |
| 2994 | 2994 |
| 2995 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { | 2995 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { |
| 2996 ASSERT(descriptor_number < number_of_descriptors()); | 2996 DCHECK(descriptor_number < number_of_descriptors()); |
| 2997 Object* details = get(ToDetailsIndex(descriptor_number)); | 2997 Object* details = get(ToDetailsIndex(descriptor_number)); |
| 2998 return PropertyDetails(Smi::cast(details)); | 2998 return PropertyDetails(Smi::cast(details)); |
| 2999 } | 2999 } |
| 3000 | 3000 |
| 3001 | 3001 |
| 3002 PropertyType DescriptorArray::GetType(int descriptor_number) { | 3002 PropertyType DescriptorArray::GetType(int descriptor_number) { |
| 3003 return GetDetails(descriptor_number).type(); | 3003 return GetDetails(descriptor_number).type(); |
| 3004 } | 3004 } |
| 3005 | 3005 |
| 3006 | 3006 |
| 3007 int DescriptorArray::GetFieldIndex(int descriptor_number) { | 3007 int DescriptorArray::GetFieldIndex(int descriptor_number) { |
| 3008 ASSERT(GetDetails(descriptor_number).type() == FIELD); | 3008 DCHECK(GetDetails(descriptor_number).type() == FIELD); |
| 3009 return GetDetails(descriptor_number).field_index(); | 3009 return GetDetails(descriptor_number).field_index(); |
| 3010 } | 3010 } |
| 3011 | 3011 |
| 3012 | 3012 |
| 3013 HeapType* DescriptorArray::GetFieldType(int descriptor_number) { | 3013 HeapType* DescriptorArray::GetFieldType(int descriptor_number) { |
| 3014 ASSERT(GetDetails(descriptor_number).type() == FIELD); | 3014 DCHECK(GetDetails(descriptor_number).type() == FIELD); |
| 3015 return HeapType::cast(GetValue(descriptor_number)); | 3015 return HeapType::cast(GetValue(descriptor_number)); |
| 3016 } | 3016 } |
| 3017 | 3017 |
| 3018 | 3018 |
| 3019 Object* DescriptorArray::GetConstant(int descriptor_number) { | 3019 Object* DescriptorArray::GetConstant(int descriptor_number) { |
| 3020 return GetValue(descriptor_number); | 3020 return GetValue(descriptor_number); |
| 3021 } | 3021 } |
| 3022 | 3022 |
| 3023 | 3023 |
| 3024 Object* DescriptorArray::GetCallbacksObject(int descriptor_number) { | 3024 Object* DescriptorArray::GetCallbacksObject(int descriptor_number) { |
| 3025 ASSERT(GetType(descriptor_number) == CALLBACKS); | 3025 DCHECK(GetType(descriptor_number) == CALLBACKS); |
| 3026 return GetValue(descriptor_number); | 3026 return GetValue(descriptor_number); |
| 3027 } | 3027 } |
| 3028 | 3028 |
| 3029 | 3029 |
| 3030 AccessorDescriptor* DescriptorArray::GetCallbacks(int descriptor_number) { | 3030 AccessorDescriptor* DescriptorArray::GetCallbacks(int descriptor_number) { |
| 3031 ASSERT(GetType(descriptor_number) == CALLBACKS); | 3031 DCHECK(GetType(descriptor_number) == CALLBACKS); |
| 3032 Foreign* p = Foreign::cast(GetCallbacksObject(descriptor_number)); | 3032 Foreign* p = Foreign::cast(GetCallbacksObject(descriptor_number)); |
| 3033 return reinterpret_cast<AccessorDescriptor*>(p->foreign_address()); | 3033 return reinterpret_cast<AccessorDescriptor*>(p->foreign_address()); |
| 3034 } | 3034 } |
| 3035 | 3035 |
| 3036 | 3036 |
| 3037 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { | 3037 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { |
| 3038 desc->Init(handle(GetKey(descriptor_number), GetIsolate()), | 3038 desc->Init(handle(GetKey(descriptor_number), GetIsolate()), |
| 3039 handle(GetValue(descriptor_number), GetIsolate()), | 3039 handle(GetValue(descriptor_number), GetIsolate()), |
| 3040 GetDetails(descriptor_number)); | 3040 GetDetails(descriptor_number)); |
| 3041 } | 3041 } |
| 3042 | 3042 |
| 3043 | 3043 |
| 3044 void DescriptorArray::Set(int descriptor_number, | 3044 void DescriptorArray::Set(int descriptor_number, |
| 3045 Descriptor* desc, | 3045 Descriptor* desc, |
| 3046 const WhitenessWitness&) { | 3046 const WhitenessWitness&) { |
| 3047 // Range check. | 3047 // Range check. |
| 3048 ASSERT(descriptor_number < number_of_descriptors()); | 3048 DCHECK(descriptor_number < number_of_descriptors()); |
| 3049 | 3049 |
| 3050 NoIncrementalWriteBarrierSet(this, | 3050 NoIncrementalWriteBarrierSet(this, |
| 3051 ToKeyIndex(descriptor_number), | 3051 ToKeyIndex(descriptor_number), |
| 3052 *desc->GetKey()); | 3052 *desc->GetKey()); |
| 3053 NoIncrementalWriteBarrierSet(this, | 3053 NoIncrementalWriteBarrierSet(this, |
| 3054 ToValueIndex(descriptor_number), | 3054 ToValueIndex(descriptor_number), |
| 3055 *desc->GetValue()); | 3055 *desc->GetValue()); |
| 3056 NoIncrementalWriteBarrierSet(this, | 3056 NoIncrementalWriteBarrierSet(this, |
| 3057 ToDetailsIndex(descriptor_number), | 3057 ToDetailsIndex(descriptor_number), |
| 3058 desc->GetDetails().AsSmi()); | 3058 desc->GetDetails().AsSmi()); |
| 3059 } | 3059 } |
| 3060 | 3060 |
| 3061 | 3061 |
| 3062 void DescriptorArray::Set(int descriptor_number, Descriptor* desc) { | 3062 void DescriptorArray::Set(int descriptor_number, Descriptor* desc) { |
| 3063 // Range check. | 3063 // Range check. |
| 3064 ASSERT(descriptor_number < number_of_descriptors()); | 3064 DCHECK(descriptor_number < number_of_descriptors()); |
| 3065 | 3065 |
| 3066 set(ToKeyIndex(descriptor_number), *desc->GetKey()); | 3066 set(ToKeyIndex(descriptor_number), *desc->GetKey()); |
| 3067 set(ToValueIndex(descriptor_number), *desc->GetValue()); | 3067 set(ToValueIndex(descriptor_number), *desc->GetValue()); |
| 3068 set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi()); | 3068 set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi()); |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 | 3071 |
| 3072 void DescriptorArray::Append(Descriptor* desc, | 3072 void DescriptorArray::Append(Descriptor* desc, |
| 3073 const WhitenessWitness& witness) { | 3073 const WhitenessWitness& witness) { |
| 3074 DisallowHeapAllocation no_gc; | 3074 DisallowHeapAllocation no_gc; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3113 void DescriptorArray::SwapSortedKeys(int first, int second) { | 3113 void DescriptorArray::SwapSortedKeys(int first, int second) { |
| 3114 int first_key = GetSortedKeyIndex(first); | 3114 int first_key = GetSortedKeyIndex(first); |
| 3115 SetSortedKey(first, GetSortedKeyIndex(second)); | 3115 SetSortedKey(first, GetSortedKeyIndex(second)); |
| 3116 SetSortedKey(second, first_key); | 3116 SetSortedKey(second, first_key); |
| 3117 } | 3117 } |
| 3118 | 3118 |
| 3119 | 3119 |
| 3120 DescriptorArray::WhitenessWitness::WhitenessWitness(DescriptorArray* array) | 3120 DescriptorArray::WhitenessWitness::WhitenessWitness(DescriptorArray* array) |
| 3121 : marking_(array->GetHeap()->incremental_marking()) { | 3121 : marking_(array->GetHeap()->incremental_marking()) { |
| 3122 marking_->EnterNoMarkingScope(); | 3122 marking_->EnterNoMarkingScope(); |
| 3123 ASSERT(!marking_->IsMarking() || | 3123 DCHECK(!marking_->IsMarking() || |
| 3124 Marking::Color(array) == Marking::WHITE_OBJECT); | 3124 Marking::Color(array) == Marking::WHITE_OBJECT); |
| 3125 } | 3125 } |
| 3126 | 3126 |
| 3127 | 3127 |
| 3128 DescriptorArray::WhitenessWitness::~WhitenessWitness() { | 3128 DescriptorArray::WhitenessWitness::~WhitenessWitness() { |
| 3129 marking_->LeaveNoMarkingScope(); | 3129 marking_->LeaveNoMarkingScope(); |
| 3130 } | 3130 } |
| 3131 | 3131 |
| 3132 | 3132 |
| 3133 template<typename Derived, typename Shape, typename Key> | 3133 template<typename Derived, typename Shape, typename Key> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 | 3168 |
| 3169 | 3169 |
| 3170 bool SeededNumberDictionary::requires_slow_elements() { | 3170 bool SeededNumberDictionary::requires_slow_elements() { |
| 3171 Object* max_index_object = get(kMaxNumberKeyIndex); | 3171 Object* max_index_object = get(kMaxNumberKeyIndex); |
| 3172 if (!max_index_object->IsSmi()) return false; | 3172 if (!max_index_object->IsSmi()) return false; |
| 3173 return 0 != | 3173 return 0 != |
| 3174 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); | 3174 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); |
| 3175 } | 3175 } |
| 3176 | 3176 |
| 3177 uint32_t SeededNumberDictionary::max_number_key() { | 3177 uint32_t SeededNumberDictionary::max_number_key() { |
| 3178 ASSERT(!requires_slow_elements()); | 3178 DCHECK(!requires_slow_elements()); |
| 3179 Object* max_index_object = get(kMaxNumberKeyIndex); | 3179 Object* max_index_object = get(kMaxNumberKeyIndex); |
| 3180 if (!max_index_object->IsSmi()) return 0; | 3180 if (!max_index_object->IsSmi()) return 0; |
| 3181 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); | 3181 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); |
| 3182 return value >> kRequiresSlowElementsTagSize; | 3182 return value >> kRequiresSlowElementsTagSize; |
| 3183 } | 3183 } |
| 3184 | 3184 |
| 3185 void SeededNumberDictionary::set_requires_slow_elements() { | 3185 void SeededNumberDictionary::set_requires_slow_elements() { |
| 3186 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 3186 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 3187 } | 3187 } |
| 3188 | 3188 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3273 CAST_ACCESSOR(String) | 3273 CAST_ACCESSOR(String) |
| 3274 CAST_ACCESSOR(StringTable) | 3274 CAST_ACCESSOR(StringTable) |
| 3275 CAST_ACCESSOR(Struct) | 3275 CAST_ACCESSOR(Struct) |
| 3276 CAST_ACCESSOR(Symbol) | 3276 CAST_ACCESSOR(Symbol) |
| 3277 CAST_ACCESSOR(UnseededNumberDictionary) | 3277 CAST_ACCESSOR(UnseededNumberDictionary) |
| 3278 CAST_ACCESSOR(WeakHashTable) | 3278 CAST_ACCESSOR(WeakHashTable) |
| 3279 | 3279 |
| 3280 | 3280 |
| 3281 template <class Traits> | 3281 template <class Traits> |
| 3282 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { | 3282 FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { |
| 3283 SLOW_ASSERT(object->IsHeapObject() && | 3283 SLOW_DCHECK(object->IsHeapObject() && |
| 3284 HeapObject::cast(object)->map()->instance_type() == | 3284 HeapObject::cast(object)->map()->instance_type() == |
| 3285 Traits::kInstanceType); | 3285 Traits::kInstanceType); |
| 3286 return reinterpret_cast<FixedTypedArray<Traits>*>(object); | 3286 return reinterpret_cast<FixedTypedArray<Traits>*>(object); |
| 3287 } | 3287 } |
| 3288 | 3288 |
| 3289 | 3289 |
| 3290 template <class Traits> | 3290 template <class Traits> |
| 3291 const FixedTypedArray<Traits>* | 3291 const FixedTypedArray<Traits>* |
| 3292 FixedTypedArray<Traits>::cast(const Object* object) { | 3292 FixedTypedArray<Traits>::cast(const Object* object) { |
| 3293 SLOW_ASSERT(object->IsHeapObject() && | 3293 SLOW_DCHECK(object->IsHeapObject() && |
| 3294 HeapObject::cast(object)->map()->instance_type() == | 3294 HeapObject::cast(object)->map()->instance_type() == |
| 3295 Traits::kInstanceType); | 3295 Traits::kInstanceType); |
| 3296 return reinterpret_cast<FixedTypedArray<Traits>*>(object); | 3296 return reinterpret_cast<FixedTypedArray<Traits>*>(object); |
| 3297 } | 3297 } |
| 3298 | 3298 |
| 3299 | 3299 |
| 3300 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) | 3300 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) |
| 3301 STRUCT_LIST(MAKE_STRUCT_CAST) | 3301 STRUCT_LIST(MAKE_STRUCT_CAST) |
| 3302 #undef MAKE_STRUCT_CAST | 3302 #undef MAKE_STRUCT_CAST |
| 3303 | 3303 |
| 3304 | 3304 |
| 3305 template <typename Derived, typename Shape, typename Key> | 3305 template <typename Derived, typename Shape, typename Key> |
| 3306 HashTable<Derived, Shape, Key>* | 3306 HashTable<Derived, Shape, Key>* |
| 3307 HashTable<Derived, Shape, Key>::cast(Object* obj) { | 3307 HashTable<Derived, Shape, Key>::cast(Object* obj) { |
| 3308 SLOW_ASSERT(obj->IsHashTable()); | 3308 SLOW_DCHECK(obj->IsHashTable()); |
| 3309 return reinterpret_cast<HashTable*>(obj); | 3309 return reinterpret_cast<HashTable*>(obj); |
| 3310 } | 3310 } |
| 3311 | 3311 |
| 3312 | 3312 |
| 3313 template <typename Derived, typename Shape, typename Key> | 3313 template <typename Derived, typename Shape, typename Key> |
| 3314 const HashTable<Derived, Shape, Key>* | 3314 const HashTable<Derived, Shape, Key>* |
| 3315 HashTable<Derived, Shape, Key>::cast(const Object* obj) { | 3315 HashTable<Derived, Shape, Key>::cast(const Object* obj) { |
| 3316 SLOW_ASSERT(obj->IsHashTable()); | 3316 SLOW_DCHECK(obj->IsHashTable()); |
| 3317 return reinterpret_cast<const HashTable*>(obj); | 3317 return reinterpret_cast<const HashTable*>(obj); |
| 3318 } | 3318 } |
| 3319 | 3319 |
| 3320 | 3320 |
| 3321 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) | 3321 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) |
| 3322 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) | 3322 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) |
| 3323 | 3323 |
| 3324 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) | 3324 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) |
| 3325 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset) | 3325 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset) |
| 3326 | 3326 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3387 | 3387 |
| 3388 Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) { | 3388 Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) { |
| 3389 if (!string->IsConsString()) return string; | 3389 if (!string->IsConsString()) return string; |
| 3390 Handle<ConsString> cons = Handle<ConsString>::cast(string); | 3390 Handle<ConsString> cons = Handle<ConsString>::cast(string); |
| 3391 if (cons->IsFlat()) return handle(cons->first()); | 3391 if (cons->IsFlat()) return handle(cons->first()); |
| 3392 return SlowFlatten(cons, pretenure); | 3392 return SlowFlatten(cons, pretenure); |
| 3393 } | 3393 } |
| 3394 | 3394 |
| 3395 | 3395 |
| 3396 uint16_t String::Get(int index) { | 3396 uint16_t String::Get(int index) { |
| 3397 ASSERT(index >= 0 && index < length()); | 3397 DCHECK(index >= 0 && index < length()); |
| 3398 switch (StringShape(this).full_representation_tag()) { | 3398 switch (StringShape(this).full_representation_tag()) { |
| 3399 case kSeqStringTag | kOneByteStringTag: | 3399 case kSeqStringTag | kOneByteStringTag: |
| 3400 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index); | 3400 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index); |
| 3401 case kSeqStringTag | kTwoByteStringTag: | 3401 case kSeqStringTag | kTwoByteStringTag: |
| 3402 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 3402 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
| 3403 case kConsStringTag | kOneByteStringTag: | 3403 case kConsStringTag | kOneByteStringTag: |
| 3404 case kConsStringTag | kTwoByteStringTag: | 3404 case kConsStringTag | kTwoByteStringTag: |
| 3405 return ConsString::cast(this)->ConsStringGet(index); | 3405 return ConsString::cast(this)->ConsStringGet(index); |
| 3406 case kExternalStringTag | kOneByteStringTag: | 3406 case kExternalStringTag | kOneByteStringTag: |
| 3407 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); | 3407 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); |
| 3408 case kExternalStringTag | kTwoByteStringTag: | 3408 case kExternalStringTag | kTwoByteStringTag: |
| 3409 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); | 3409 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); |
| 3410 case kSlicedStringTag | kOneByteStringTag: | 3410 case kSlicedStringTag | kOneByteStringTag: |
| 3411 case kSlicedStringTag | kTwoByteStringTag: | 3411 case kSlicedStringTag | kTwoByteStringTag: |
| 3412 return SlicedString::cast(this)->SlicedStringGet(index); | 3412 return SlicedString::cast(this)->SlicedStringGet(index); |
| 3413 default: | 3413 default: |
| 3414 break; | 3414 break; |
| 3415 } | 3415 } |
| 3416 | 3416 |
| 3417 UNREACHABLE(); | 3417 UNREACHABLE(); |
| 3418 return 0; | 3418 return 0; |
| 3419 } | 3419 } |
| 3420 | 3420 |
| 3421 | 3421 |
| 3422 void String::Set(int index, uint16_t value) { | 3422 void String::Set(int index, uint16_t value) { |
| 3423 ASSERT(index >= 0 && index < length()); | 3423 DCHECK(index >= 0 && index < length()); |
| 3424 ASSERT(StringShape(this).IsSequential()); | 3424 DCHECK(StringShape(this).IsSequential()); |
| 3425 | 3425 |
| 3426 return this->IsOneByteRepresentation() | 3426 return this->IsOneByteRepresentation() |
| 3427 ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value) | 3427 ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value) |
| 3428 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); | 3428 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); |
| 3429 } | 3429 } |
| 3430 | 3430 |
| 3431 | 3431 |
| 3432 bool String::IsFlat() { | 3432 bool String::IsFlat() { |
| 3433 if (!StringShape(this).IsCons()) return true; | 3433 if (!StringShape(this).IsCons()) return true; |
| 3434 return ConsString::cast(this)->second()->length() == 0; | 3434 return ConsString::cast(this)->second()->length() == 0; |
| 3435 } | 3435 } |
| 3436 | 3436 |
| 3437 | 3437 |
| 3438 String* String::GetUnderlying() { | 3438 String* String::GetUnderlying() { |
| 3439 // Giving direct access to underlying string only makes sense if the | 3439 // Giving direct access to underlying string only makes sense if the |
| 3440 // wrapping string is already flattened. | 3440 // wrapping string is already flattened. |
| 3441 ASSERT(this->IsFlat()); | 3441 DCHECK(this->IsFlat()); |
| 3442 ASSERT(StringShape(this).IsIndirect()); | 3442 DCHECK(StringShape(this).IsIndirect()); |
| 3443 STATIC_ASSERT(ConsString::kFirstOffset == SlicedString::kParentOffset); | 3443 STATIC_ASSERT(ConsString::kFirstOffset == SlicedString::kParentOffset); |
| 3444 const int kUnderlyingOffset = SlicedString::kParentOffset; | 3444 const int kUnderlyingOffset = SlicedString::kParentOffset; |
| 3445 return String::cast(READ_FIELD(this, kUnderlyingOffset)); | 3445 return String::cast(READ_FIELD(this, kUnderlyingOffset)); |
| 3446 } | 3446 } |
| 3447 | 3447 |
| 3448 | 3448 |
| 3449 template<class Visitor> | 3449 template<class Visitor> |
| 3450 ConsString* String::VisitFlat(Visitor* visitor, | 3450 ConsString* String::VisitFlat(Visitor* visitor, |
| 3451 String* string, | 3451 String* string, |
| 3452 const int offset) { | 3452 const int offset) { |
| 3453 int slice_offset = offset; | 3453 int slice_offset = offset; |
| 3454 const int length = string->length(); | 3454 const int length = string->length(); |
| 3455 ASSERT(offset <= length); | 3455 DCHECK(offset <= length); |
| 3456 while (true) { | 3456 while (true) { |
| 3457 int32_t type = string->map()->instance_type(); | 3457 int32_t type = string->map()->instance_type(); |
| 3458 switch (type & (kStringRepresentationMask | kStringEncodingMask)) { | 3458 switch (type & (kStringRepresentationMask | kStringEncodingMask)) { |
| 3459 case kSeqStringTag | kOneByteStringTag: | 3459 case kSeqStringTag | kOneByteStringTag: |
| 3460 visitor->VisitOneByteString( | 3460 visitor->VisitOneByteString( |
| 3461 SeqOneByteString::cast(string)->GetChars() + slice_offset, | 3461 SeqOneByteString::cast(string)->GetChars() + slice_offset, |
| 3462 length - offset); | 3462 length - offset); |
| 3463 return NULL; | 3463 return NULL; |
| 3464 | 3464 |
| 3465 case kSeqStringTag | kTwoByteStringTag: | 3465 case kSeqStringTag | kTwoByteStringTag: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3494 | 3494 |
| 3495 default: | 3495 default: |
| 3496 UNREACHABLE(); | 3496 UNREACHABLE(); |
| 3497 return NULL; | 3497 return NULL; |
| 3498 } | 3498 } |
| 3499 } | 3499 } |
| 3500 } | 3500 } |
| 3501 | 3501 |
| 3502 | 3502 |
| 3503 uint16_t SeqOneByteString::SeqOneByteStringGet(int index) { | 3503 uint16_t SeqOneByteString::SeqOneByteStringGet(int index) { |
| 3504 ASSERT(index >= 0 && index < length()); | 3504 DCHECK(index >= 0 && index < length()); |
| 3505 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 3505 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
| 3506 } | 3506 } |
| 3507 | 3507 |
| 3508 | 3508 |
| 3509 void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) { | 3509 void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) { |
| 3510 ASSERT(index >= 0 && index < length() && value <= kMaxOneByteCharCode); | 3510 DCHECK(index >= 0 && index < length() && value <= kMaxOneByteCharCode); |
| 3511 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, | 3511 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, |
| 3512 static_cast<byte>(value)); | 3512 static_cast<byte>(value)); |
| 3513 } | 3513 } |
| 3514 | 3514 |
| 3515 | 3515 |
| 3516 Address SeqOneByteString::GetCharsAddress() { | 3516 Address SeqOneByteString::GetCharsAddress() { |
| 3517 return FIELD_ADDR(this, kHeaderSize); | 3517 return FIELD_ADDR(this, kHeaderSize); |
| 3518 } | 3518 } |
| 3519 | 3519 |
| 3520 | 3520 |
| 3521 uint8_t* SeqOneByteString::GetChars() { | 3521 uint8_t* SeqOneByteString::GetChars() { |
| 3522 return reinterpret_cast<uint8_t*>(GetCharsAddress()); | 3522 return reinterpret_cast<uint8_t*>(GetCharsAddress()); |
| 3523 } | 3523 } |
| 3524 | 3524 |
| 3525 | 3525 |
| 3526 Address SeqTwoByteString::GetCharsAddress() { | 3526 Address SeqTwoByteString::GetCharsAddress() { |
| 3527 return FIELD_ADDR(this, kHeaderSize); | 3527 return FIELD_ADDR(this, kHeaderSize); |
| 3528 } | 3528 } |
| 3529 | 3529 |
| 3530 | 3530 |
| 3531 uc16* SeqTwoByteString::GetChars() { | 3531 uc16* SeqTwoByteString::GetChars() { |
| 3532 return reinterpret_cast<uc16*>(FIELD_ADDR(this, kHeaderSize)); | 3532 return reinterpret_cast<uc16*>(FIELD_ADDR(this, kHeaderSize)); |
| 3533 } | 3533 } |
| 3534 | 3534 |
| 3535 | 3535 |
| 3536 uint16_t SeqTwoByteString::SeqTwoByteStringGet(int index) { | 3536 uint16_t SeqTwoByteString::SeqTwoByteStringGet(int index) { |
| 3537 ASSERT(index >= 0 && index < length()); | 3537 DCHECK(index >= 0 && index < length()); |
| 3538 return READ_SHORT_FIELD(this, kHeaderSize + index * kShortSize); | 3538 return READ_SHORT_FIELD(this, kHeaderSize + index * kShortSize); |
| 3539 } | 3539 } |
| 3540 | 3540 |
| 3541 | 3541 |
| 3542 void SeqTwoByteString::SeqTwoByteStringSet(int index, uint16_t value) { | 3542 void SeqTwoByteString::SeqTwoByteStringSet(int index, uint16_t value) { |
| 3543 ASSERT(index >= 0 && index < length()); | 3543 DCHECK(index >= 0 && index < length()); |
| 3544 WRITE_SHORT_FIELD(this, kHeaderSize + index * kShortSize, value); | 3544 WRITE_SHORT_FIELD(this, kHeaderSize + index * kShortSize, value); |
| 3545 } | 3545 } |
| 3546 | 3546 |
| 3547 | 3547 |
| 3548 int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) { | 3548 int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) { |
| 3549 return SizeFor(length()); | 3549 return SizeFor(length()); |
| 3550 } | 3550 } |
| 3551 | 3551 |
| 3552 | 3552 |
| 3553 int SeqOneByteString::SeqOneByteStringSize(InstanceType instance_type) { | 3553 int SeqOneByteString::SeqOneByteStringSize(InstanceType instance_type) { |
| 3554 return SizeFor(length()); | 3554 return SizeFor(length()); |
| 3555 } | 3555 } |
| 3556 | 3556 |
| 3557 | 3557 |
| 3558 String* SlicedString::parent() { | 3558 String* SlicedString::parent() { |
| 3559 return String::cast(READ_FIELD(this, kParentOffset)); | 3559 return String::cast(READ_FIELD(this, kParentOffset)); |
| 3560 } | 3560 } |
| 3561 | 3561 |
| 3562 | 3562 |
| 3563 void SlicedString::set_parent(String* parent, WriteBarrierMode mode) { | 3563 void SlicedString::set_parent(String* parent, WriteBarrierMode mode) { |
| 3564 ASSERT(parent->IsSeqString() || parent->IsExternalString()); | 3564 DCHECK(parent->IsSeqString() || parent->IsExternalString()); |
| 3565 WRITE_FIELD(this, kParentOffset, parent); | 3565 WRITE_FIELD(this, kParentOffset, parent); |
| 3566 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, parent, mode); | 3566 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, parent, mode); |
| 3567 } | 3567 } |
| 3568 | 3568 |
| 3569 | 3569 |
| 3570 SMI_ACCESSORS(SlicedString, offset, kOffsetOffset) | 3570 SMI_ACCESSORS(SlicedString, offset, kOffsetOffset) |
| 3571 | 3571 |
| 3572 | 3572 |
| 3573 String* ConsString::first() { | 3573 String* ConsString::first() { |
| 3574 return String::cast(READ_FIELD(this, kFirstOffset)); | 3574 return String::cast(READ_FIELD(this, kFirstOffset)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3616 void ExternalAsciiString::update_data_cache() { | 3616 void ExternalAsciiString::update_data_cache() { |
| 3617 if (is_short()) return; | 3617 if (is_short()) return; |
| 3618 const char** data_field = | 3618 const char** data_field = |
| 3619 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); | 3619 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); |
| 3620 *data_field = resource()->data(); | 3620 *data_field = resource()->data(); |
| 3621 } | 3621 } |
| 3622 | 3622 |
| 3623 | 3623 |
| 3624 void ExternalAsciiString::set_resource( | 3624 void ExternalAsciiString::set_resource( |
| 3625 const ExternalAsciiString::Resource* resource) { | 3625 const ExternalAsciiString::Resource* resource) { |
| 3626 ASSERT(IsAligned(reinterpret_cast<intptr_t>(resource), kPointerSize)); | 3626 DCHECK(IsAligned(reinterpret_cast<intptr_t>(resource), kPointerSize)); |
| 3627 *reinterpret_cast<const Resource**>( | 3627 *reinterpret_cast<const Resource**>( |
| 3628 FIELD_ADDR(this, kResourceOffset)) = resource; | 3628 FIELD_ADDR(this, kResourceOffset)) = resource; |
| 3629 if (resource != NULL) update_data_cache(); | 3629 if (resource != NULL) update_data_cache(); |
| 3630 } | 3630 } |
| 3631 | 3631 |
| 3632 | 3632 |
| 3633 const uint8_t* ExternalAsciiString::GetChars() { | 3633 const uint8_t* ExternalAsciiString::GetChars() { |
| 3634 return reinterpret_cast<const uint8_t*>(resource()->data()); | 3634 return reinterpret_cast<const uint8_t*>(resource()->data()); |
| 3635 } | 3635 } |
| 3636 | 3636 |
| 3637 | 3637 |
| 3638 uint16_t ExternalAsciiString::ExternalAsciiStringGet(int index) { | 3638 uint16_t ExternalAsciiString::ExternalAsciiStringGet(int index) { |
| 3639 ASSERT(index >= 0 && index < length()); | 3639 DCHECK(index >= 0 && index < length()); |
| 3640 return GetChars()[index]; | 3640 return GetChars()[index]; |
| 3641 } | 3641 } |
| 3642 | 3642 |
| 3643 | 3643 |
| 3644 const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { | 3644 const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { |
| 3645 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 3645 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
| 3646 } | 3646 } |
| 3647 | 3647 |
| 3648 | 3648 |
| 3649 void ExternalTwoByteString::update_data_cache() { | 3649 void ExternalTwoByteString::update_data_cache() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3661 if (resource != NULL) update_data_cache(); | 3661 if (resource != NULL) update_data_cache(); |
| 3662 } | 3662 } |
| 3663 | 3663 |
| 3664 | 3664 |
| 3665 const uint16_t* ExternalTwoByteString::GetChars() { | 3665 const uint16_t* ExternalTwoByteString::GetChars() { |
| 3666 return resource()->data(); | 3666 return resource()->data(); |
| 3667 } | 3667 } |
| 3668 | 3668 |
| 3669 | 3669 |
| 3670 uint16_t ExternalTwoByteString::ExternalTwoByteStringGet(int index) { | 3670 uint16_t ExternalTwoByteString::ExternalTwoByteStringGet(int index) { |
| 3671 ASSERT(index >= 0 && index < length()); | 3671 DCHECK(index >= 0 && index < length()); |
| 3672 return GetChars()[index]; | 3672 return GetChars()[index]; |
| 3673 } | 3673 } |
| 3674 | 3674 |
| 3675 | 3675 |
| 3676 const uint16_t* ExternalTwoByteString::ExternalTwoByteStringGetData( | 3676 const uint16_t* ExternalTwoByteString::ExternalTwoByteStringGetData( |
| 3677 unsigned start) { | 3677 unsigned start) { |
| 3678 return GetChars() + start; | 3678 return GetChars() + start; |
| 3679 } | 3679 } |
| 3680 | 3680 |
| 3681 | 3681 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3694 frames_[(depth_-1) & kDepthMask] = string; | 3694 frames_[(depth_-1) & kDepthMask] = string; |
| 3695 } | 3695 } |
| 3696 | 3696 |
| 3697 | 3697 |
| 3698 void ConsStringIteratorOp::AdjustMaximumDepth() { | 3698 void ConsStringIteratorOp::AdjustMaximumDepth() { |
| 3699 if (depth_ > maximum_depth_) maximum_depth_ = depth_; | 3699 if (depth_ > maximum_depth_) maximum_depth_ = depth_; |
| 3700 } | 3700 } |
| 3701 | 3701 |
| 3702 | 3702 |
| 3703 void ConsStringIteratorOp::Pop() { | 3703 void ConsStringIteratorOp::Pop() { |
| 3704 ASSERT(depth_ > 0); | 3704 DCHECK(depth_ > 0); |
| 3705 ASSERT(depth_ <= maximum_depth_); | 3705 DCHECK(depth_ <= maximum_depth_); |
| 3706 depth_--; | 3706 depth_--; |
| 3707 } | 3707 } |
| 3708 | 3708 |
| 3709 | 3709 |
| 3710 uint16_t StringCharacterStream::GetNext() { | 3710 uint16_t StringCharacterStream::GetNext() { |
| 3711 ASSERT(buffer8_ != NULL && end_ != NULL); | 3711 DCHECK(buffer8_ != NULL && end_ != NULL); |
| 3712 // Advance cursor if needed. | 3712 // Advance cursor if needed. |
| 3713 if (buffer8_ == end_) HasMore(); | 3713 if (buffer8_ == end_) HasMore(); |
| 3714 ASSERT(buffer8_ < end_); | 3714 DCHECK(buffer8_ < end_); |
| 3715 return is_one_byte_ ? *buffer8_++ : *buffer16_++; | 3715 return is_one_byte_ ? *buffer8_++ : *buffer16_++; |
| 3716 } | 3716 } |
| 3717 | 3717 |
| 3718 | 3718 |
| 3719 StringCharacterStream::StringCharacterStream(String* string, | 3719 StringCharacterStream::StringCharacterStream(String* string, |
| 3720 ConsStringIteratorOp* op, | 3720 ConsStringIteratorOp* op, |
| 3721 int offset) | 3721 int offset) |
| 3722 : is_one_byte_(false), | 3722 : is_one_byte_(false), |
| 3723 op_(op) { | 3723 op_(op) { |
| 3724 Reset(string, offset); | 3724 Reset(string, offset); |
| 3725 } | 3725 } |
| 3726 | 3726 |
| 3727 | 3727 |
| 3728 void StringCharacterStream::Reset(String* string, int offset) { | 3728 void StringCharacterStream::Reset(String* string, int offset) { |
| 3729 buffer8_ = NULL; | 3729 buffer8_ = NULL; |
| 3730 end_ = NULL; | 3730 end_ = NULL; |
| 3731 ConsString* cons_string = String::VisitFlat(this, string, offset); | 3731 ConsString* cons_string = String::VisitFlat(this, string, offset); |
| 3732 op_->Reset(cons_string, offset); | 3732 op_->Reset(cons_string, offset); |
| 3733 if (cons_string != NULL) { | 3733 if (cons_string != NULL) { |
| 3734 string = op_->Next(&offset); | 3734 string = op_->Next(&offset); |
| 3735 if (string != NULL) String::VisitFlat(this, string, offset); | 3735 if (string != NULL) String::VisitFlat(this, string, offset); |
| 3736 } | 3736 } |
| 3737 } | 3737 } |
| 3738 | 3738 |
| 3739 | 3739 |
| 3740 bool StringCharacterStream::HasMore() { | 3740 bool StringCharacterStream::HasMore() { |
| 3741 if (buffer8_ != end_) return true; | 3741 if (buffer8_ != end_) return true; |
| 3742 int offset; | 3742 int offset; |
| 3743 String* string = op_->Next(&offset); | 3743 String* string = op_->Next(&offset); |
| 3744 ASSERT_EQ(offset, 0); | 3744 DCHECK_EQ(offset, 0); |
| 3745 if (string == NULL) return false; | 3745 if (string == NULL) return false; |
| 3746 String::VisitFlat(this, string); | 3746 String::VisitFlat(this, string); |
| 3747 ASSERT(buffer8_ != end_); | 3747 DCHECK(buffer8_ != end_); |
| 3748 return true; | 3748 return true; |
| 3749 } | 3749 } |
| 3750 | 3750 |
| 3751 | 3751 |
| 3752 void StringCharacterStream::VisitOneByteString( | 3752 void StringCharacterStream::VisitOneByteString( |
| 3753 const uint8_t* chars, int length) { | 3753 const uint8_t* chars, int length) { |
| 3754 is_one_byte_ = true; | 3754 is_one_byte_ = true; |
| 3755 buffer8_ = chars; | 3755 buffer8_ = chars; |
| 3756 end_ = chars + length; | 3756 end_ = chars + length; |
| 3757 } | 3757 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3795 return Smi::cast(get(kFingerIndex))->value(); | 3795 return Smi::cast(get(kFingerIndex))->value(); |
| 3796 } | 3796 } |
| 3797 | 3797 |
| 3798 | 3798 |
| 3799 void JSFunctionResultCache::set_finger_index(int finger_index) { | 3799 void JSFunctionResultCache::set_finger_index(int finger_index) { |
| 3800 set(kFingerIndex, Smi::FromInt(finger_index)); | 3800 set(kFingerIndex, Smi::FromInt(finger_index)); |
| 3801 } | 3801 } |
| 3802 | 3802 |
| 3803 | 3803 |
| 3804 byte ByteArray::get(int index) { | 3804 byte ByteArray::get(int index) { |
| 3805 ASSERT(index >= 0 && index < this->length()); | 3805 DCHECK(index >= 0 && index < this->length()); |
| 3806 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 3806 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
| 3807 } | 3807 } |
| 3808 | 3808 |
| 3809 | 3809 |
| 3810 void ByteArray::set(int index, byte value) { | 3810 void ByteArray::set(int index, byte value) { |
| 3811 ASSERT(index >= 0 && index < this->length()); | 3811 DCHECK(index >= 0 && index < this->length()); |
| 3812 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); | 3812 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
| 3813 } | 3813 } |
| 3814 | 3814 |
| 3815 | 3815 |
| 3816 int ByteArray::get_int(int index) { | 3816 int ByteArray::get_int(int index) { |
| 3817 ASSERT(index >= 0 && (index * kIntSize) < this->length()); | 3817 DCHECK(index >= 0 && (index * kIntSize) < this->length()); |
| 3818 return READ_INT_FIELD(this, kHeaderSize + index * kIntSize); | 3818 return READ_INT_FIELD(this, kHeaderSize + index * kIntSize); |
| 3819 } | 3819 } |
| 3820 | 3820 |
| 3821 | 3821 |
| 3822 ByteArray* ByteArray::FromDataStartAddress(Address address) { | 3822 ByteArray* ByteArray::FromDataStartAddress(Address address) { |
| 3823 ASSERT_TAG_ALIGNED(address); | 3823 DCHECK_TAG_ALIGNED(address); |
| 3824 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); | 3824 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); |
| 3825 } | 3825 } |
| 3826 | 3826 |
| 3827 | 3827 |
| 3828 Address ByteArray::GetDataStartAddress() { | 3828 Address ByteArray::GetDataStartAddress() { |
| 3829 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; | 3829 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; |
| 3830 } | 3830 } |
| 3831 | 3831 |
| 3832 | 3832 |
| 3833 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { | 3833 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { |
| 3834 return reinterpret_cast<uint8_t*>(external_pointer()); | 3834 return reinterpret_cast<uint8_t*>(external_pointer()); |
| 3835 } | 3835 } |
| 3836 | 3836 |
| 3837 | 3837 |
| 3838 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { | 3838 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { |
| 3839 ASSERT((index >= 0) && (index < this->length())); | 3839 DCHECK((index >= 0) && (index < this->length())); |
| 3840 uint8_t* ptr = external_uint8_clamped_pointer(); | 3840 uint8_t* ptr = external_uint8_clamped_pointer(); |
| 3841 return ptr[index]; | 3841 return ptr[index]; |
| 3842 } | 3842 } |
| 3843 | 3843 |
| 3844 | 3844 |
| 3845 Handle<Object> ExternalUint8ClampedArray::get( | 3845 Handle<Object> ExternalUint8ClampedArray::get( |
| 3846 Handle<ExternalUint8ClampedArray> array, | 3846 Handle<ExternalUint8ClampedArray> array, |
| 3847 int index) { | 3847 int index) { |
| 3848 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | 3848 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), |
| 3849 array->GetIsolate()); | 3849 array->GetIsolate()); |
| 3850 } | 3850 } |
| 3851 | 3851 |
| 3852 | 3852 |
| 3853 void ExternalUint8ClampedArray::set(int index, uint8_t value) { | 3853 void ExternalUint8ClampedArray::set(int index, uint8_t value) { |
| 3854 ASSERT((index >= 0) && (index < this->length())); | 3854 DCHECK((index >= 0) && (index < this->length())); |
| 3855 uint8_t* ptr = external_uint8_clamped_pointer(); | 3855 uint8_t* ptr = external_uint8_clamped_pointer(); |
| 3856 ptr[index] = value; | 3856 ptr[index] = value; |
| 3857 } | 3857 } |
| 3858 | 3858 |
| 3859 | 3859 |
| 3860 void* ExternalArray::external_pointer() const { | 3860 void* ExternalArray::external_pointer() const { |
| 3861 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); | 3861 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); |
| 3862 return reinterpret_cast<void*>(ptr); | 3862 return reinterpret_cast<void*>(ptr); |
| 3863 } | 3863 } |
| 3864 | 3864 |
| 3865 | 3865 |
| 3866 void ExternalArray::set_external_pointer(void* value, WriteBarrierMode mode) { | 3866 void ExternalArray::set_external_pointer(void* value, WriteBarrierMode mode) { |
| 3867 intptr_t ptr = reinterpret_cast<intptr_t>(value); | 3867 intptr_t ptr = reinterpret_cast<intptr_t>(value); |
| 3868 WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr); | 3868 WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr); |
| 3869 } | 3869 } |
| 3870 | 3870 |
| 3871 | 3871 |
| 3872 int8_t ExternalInt8Array::get_scalar(int index) { | 3872 int8_t ExternalInt8Array::get_scalar(int index) { |
| 3873 ASSERT((index >= 0) && (index < this->length())); | 3873 DCHECK((index >= 0) && (index < this->length())); |
| 3874 int8_t* ptr = static_cast<int8_t*>(external_pointer()); | 3874 int8_t* ptr = static_cast<int8_t*>(external_pointer()); |
| 3875 return ptr[index]; | 3875 return ptr[index]; |
| 3876 } | 3876 } |
| 3877 | 3877 |
| 3878 | 3878 |
| 3879 Handle<Object> ExternalInt8Array::get(Handle<ExternalInt8Array> array, | 3879 Handle<Object> ExternalInt8Array::get(Handle<ExternalInt8Array> array, |
| 3880 int index) { | 3880 int index) { |
| 3881 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | 3881 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), |
| 3882 array->GetIsolate()); | 3882 array->GetIsolate()); |
| 3883 } | 3883 } |
| 3884 | 3884 |
| 3885 | 3885 |
| 3886 void ExternalInt8Array::set(int index, int8_t value) { | 3886 void ExternalInt8Array::set(int index, int8_t value) { |
| 3887 ASSERT((index >= 0) && (index < this->length())); | 3887 DCHECK((index >= 0) && (index < this->length())); |
| 3888 int8_t* ptr = static_cast<int8_t*>(external_pointer()); | 3888 int8_t* ptr = static_cast<int8_t*>(external_pointer()); |
| 3889 ptr[index] = value; | 3889 ptr[index] = value; |
| 3890 } | 3890 } |
| 3891 | 3891 |
| 3892 | 3892 |
| 3893 uint8_t ExternalUint8Array::get_scalar(int index) { | 3893 uint8_t ExternalUint8Array::get_scalar(int index) { |
| 3894 ASSERT((index >= 0) && (index < this->length())); | 3894 DCHECK((index >= 0) && (index < this->length())); |
| 3895 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); | 3895 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); |
| 3896 return ptr[index]; | 3896 return ptr[index]; |
| 3897 } | 3897 } |
| 3898 | 3898 |
| 3899 | 3899 |
| 3900 Handle<Object> ExternalUint8Array::get(Handle<ExternalUint8Array> array, | 3900 Handle<Object> ExternalUint8Array::get(Handle<ExternalUint8Array> array, |
| 3901 int index) { | 3901 int index) { |
| 3902 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | 3902 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), |
| 3903 array->GetIsolate()); | 3903 array->GetIsolate()); |
| 3904 } | 3904 } |
| 3905 | 3905 |
| 3906 | 3906 |
| 3907 void ExternalUint8Array::set(int index, uint8_t value) { | 3907 void ExternalUint8Array::set(int index, uint8_t value) { |
| 3908 ASSERT((index >= 0) && (index < this->length())); | 3908 DCHECK((index >= 0) && (index < this->length())); |
| 3909 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); | 3909 uint8_t* ptr = static_cast<uint8_t*>(external_pointer()); |
| 3910 ptr[index] = value; | 3910 ptr[index] = value; |
| 3911 } | 3911 } |
| 3912 | 3912 |
| 3913 | 3913 |
| 3914 int16_t ExternalInt16Array::get_scalar(int index) { | 3914 int16_t ExternalInt16Array::get_scalar(int index) { |
| 3915 ASSERT((index >= 0) && (index < this->length())); | 3915 DCHECK((index >= 0) && (index < this->length())); |
| 3916 int16_t* ptr = static_cast<int16_t*>(external_pointer()); | 3916 int16_t* ptr = static_cast<int16_t*>(external_pointer()); |
| 3917 return ptr[index]; | 3917 return ptr[index]; |
| 3918 } | 3918 } |
| 3919 | 3919 |
| 3920 | 3920 |
| 3921 Handle<Object> ExternalInt16Array::get(Handle<ExternalInt16Array> array, | 3921 Handle<Object> ExternalInt16Array::get(Handle<ExternalInt16Array> array, |
| 3922 int index) { | 3922 int index) { |
| 3923 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | 3923 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), |
| 3924 array->GetIsolate()); | 3924 array->GetIsolate()); |
| 3925 } | 3925 } |
| 3926 | 3926 |
| 3927 | 3927 |
| 3928 void ExternalInt16Array::set(int index, int16_t value) { | 3928 void ExternalInt16Array::set(int index, int16_t value) { |
| 3929 ASSERT((index >= 0) && (index < this->length())); | 3929 DCHECK((index >= 0) && (index < this->length())); |
| 3930 int16_t* ptr = static_cast<int16_t*>(external_pointer()); | 3930 int16_t* ptr = static_cast<int16_t*>(external_pointer()); |
| 3931 ptr[index] = value; | 3931 ptr[index] = value; |
| 3932 } | 3932 } |
| 3933 | 3933 |
| 3934 | 3934 |
| 3935 uint16_t ExternalUint16Array::get_scalar(int index) { | 3935 uint16_t ExternalUint16Array::get_scalar(int index) { |
| 3936 ASSERT((index >= 0) && (index < this->length())); | 3936 DCHECK((index >= 0) && (index < this->length())); |
| 3937 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); | 3937 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); |
| 3938 return ptr[index]; | 3938 return ptr[index]; |
| 3939 } | 3939 } |
| 3940 | 3940 |
| 3941 | 3941 |
| 3942 Handle<Object> ExternalUint16Array::get(Handle<ExternalUint16Array> array, | 3942 Handle<Object> ExternalUint16Array::get(Handle<ExternalUint16Array> array, |
| 3943 int index) { | 3943 int index) { |
| 3944 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), | 3944 return Handle<Smi>(Smi::FromInt(array->get_scalar(index)), |
| 3945 array->GetIsolate()); | 3945 array->GetIsolate()); |
| 3946 } | 3946 } |
| 3947 | 3947 |
| 3948 | 3948 |
| 3949 void ExternalUint16Array::set(int index, uint16_t value) { | 3949 void ExternalUint16Array::set(int index, uint16_t value) { |
| 3950 ASSERT((index >= 0) && (index < this->length())); | 3950 DCHECK((index >= 0) && (index < this->length())); |
| 3951 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); | 3951 uint16_t* ptr = static_cast<uint16_t*>(external_pointer()); |
| 3952 ptr[index] = value; | 3952 ptr[index] = value; |
| 3953 } | 3953 } |
| 3954 | 3954 |
| 3955 | 3955 |
| 3956 int32_t ExternalInt32Array::get_scalar(int index) { | 3956 int32_t ExternalInt32Array::get_scalar(int index) { |
| 3957 ASSERT((index >= 0) && (index < this->length())); | 3957 DCHECK((index >= 0) && (index < this->length())); |
| 3958 int32_t* ptr = static_cast<int32_t*>(external_pointer()); | 3958 int32_t* ptr = static_cast<int32_t*>(external_pointer()); |
| 3959 return ptr[index]; | 3959 return ptr[index]; |
| 3960 } | 3960 } |
| 3961 | 3961 |
| 3962 | 3962 |
| 3963 Handle<Object> ExternalInt32Array::get(Handle<ExternalInt32Array> array, | 3963 Handle<Object> ExternalInt32Array::get(Handle<ExternalInt32Array> array, |
| 3964 int index) { | 3964 int index) { |
| 3965 return array->GetIsolate()->factory()-> | 3965 return array->GetIsolate()->factory()-> |
| 3966 NewNumberFromInt(array->get_scalar(index)); | 3966 NewNumberFromInt(array->get_scalar(index)); |
| 3967 } | 3967 } |
| 3968 | 3968 |
| 3969 | 3969 |
| 3970 void ExternalInt32Array::set(int index, int32_t value) { | 3970 void ExternalInt32Array::set(int index, int32_t value) { |
| 3971 ASSERT((index >= 0) && (index < this->length())); | 3971 DCHECK((index >= 0) && (index < this->length())); |
| 3972 int32_t* ptr = static_cast<int32_t*>(external_pointer()); | 3972 int32_t* ptr = static_cast<int32_t*>(external_pointer()); |
| 3973 ptr[index] = value; | 3973 ptr[index] = value; |
| 3974 } | 3974 } |
| 3975 | 3975 |
| 3976 | 3976 |
| 3977 uint32_t ExternalUint32Array::get_scalar(int index) { | 3977 uint32_t ExternalUint32Array::get_scalar(int index) { |
| 3978 ASSERT((index >= 0) && (index < this->length())); | 3978 DCHECK((index >= 0) && (index < this->length())); |
| 3979 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); | 3979 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); |
| 3980 return ptr[index]; | 3980 return ptr[index]; |
| 3981 } | 3981 } |
| 3982 | 3982 |
| 3983 | 3983 |
| 3984 Handle<Object> ExternalUint32Array::get(Handle<ExternalUint32Array> array, | 3984 Handle<Object> ExternalUint32Array::get(Handle<ExternalUint32Array> array, |
| 3985 int index) { | 3985 int index) { |
| 3986 return array->GetIsolate()->factory()-> | 3986 return array->GetIsolate()->factory()-> |
| 3987 NewNumberFromUint(array->get_scalar(index)); | 3987 NewNumberFromUint(array->get_scalar(index)); |
| 3988 } | 3988 } |
| 3989 | 3989 |
| 3990 | 3990 |
| 3991 void ExternalUint32Array::set(int index, uint32_t value) { | 3991 void ExternalUint32Array::set(int index, uint32_t value) { |
| 3992 ASSERT((index >= 0) && (index < this->length())); | 3992 DCHECK((index >= 0) && (index < this->length())); |
| 3993 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); | 3993 uint32_t* ptr = static_cast<uint32_t*>(external_pointer()); |
| 3994 ptr[index] = value; | 3994 ptr[index] = value; |
| 3995 } | 3995 } |
| 3996 | 3996 |
| 3997 | 3997 |
| 3998 float ExternalFloat32Array::get_scalar(int index) { | 3998 float ExternalFloat32Array::get_scalar(int index) { |
| 3999 ASSERT((index >= 0) && (index < this->length())); | 3999 DCHECK((index >= 0) && (index < this->length())); |
| 4000 float* ptr = static_cast<float*>(external_pointer()); | 4000 float* ptr = static_cast<float*>(external_pointer()); |
| 4001 return ptr[index]; | 4001 return ptr[index]; |
| 4002 } | 4002 } |
| 4003 | 4003 |
| 4004 | 4004 |
| 4005 Handle<Object> ExternalFloat32Array::get(Handle<ExternalFloat32Array> array, | 4005 Handle<Object> ExternalFloat32Array::get(Handle<ExternalFloat32Array> array, |
| 4006 int index) { | 4006 int index) { |
| 4007 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | 4007 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); |
| 4008 } | 4008 } |
| 4009 | 4009 |
| 4010 | 4010 |
| 4011 void ExternalFloat32Array::set(int index, float value) { | 4011 void ExternalFloat32Array::set(int index, float value) { |
| 4012 ASSERT((index >= 0) && (index < this->length())); | 4012 DCHECK((index >= 0) && (index < this->length())); |
| 4013 float* ptr = static_cast<float*>(external_pointer()); | 4013 float* ptr = static_cast<float*>(external_pointer()); |
| 4014 ptr[index] = value; | 4014 ptr[index] = value; |
| 4015 } | 4015 } |
| 4016 | 4016 |
| 4017 | 4017 |
| 4018 double ExternalFloat64Array::get_scalar(int index) { | 4018 double ExternalFloat64Array::get_scalar(int index) { |
| 4019 ASSERT((index >= 0) && (index < this->length())); | 4019 DCHECK((index >= 0) && (index < this->length())); |
| 4020 double* ptr = static_cast<double*>(external_pointer()); | 4020 double* ptr = static_cast<double*>(external_pointer()); |
| 4021 return ptr[index]; | 4021 return ptr[index]; |
| 4022 } | 4022 } |
| 4023 | 4023 |
| 4024 | 4024 |
| 4025 Handle<Object> ExternalFloat64Array::get(Handle<ExternalFloat64Array> array, | 4025 Handle<Object> ExternalFloat64Array::get(Handle<ExternalFloat64Array> array, |
| 4026 int index) { | 4026 int index) { |
| 4027 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); | 4027 return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index)); |
| 4028 } | 4028 } |
| 4029 | 4029 |
| 4030 | 4030 |
| 4031 void ExternalFloat64Array::set(int index, double value) { | 4031 void ExternalFloat64Array::set(int index, double value) { |
| 4032 ASSERT((index >= 0) && (index < this->length())); | 4032 DCHECK((index >= 0) && (index < this->length())); |
| 4033 double* ptr = static_cast<double*>(external_pointer()); | 4033 double* ptr = static_cast<double*>(external_pointer()); |
| 4034 ptr[index] = value; | 4034 ptr[index] = value; |
| 4035 } | 4035 } |
| 4036 | 4036 |
| 4037 | 4037 |
| 4038 void* FixedTypedArrayBase::DataPtr() { | 4038 void* FixedTypedArrayBase::DataPtr() { |
| 4039 return FIELD_ADDR(this, kDataOffset); | 4039 return FIELD_ADDR(this, kDataOffset); |
| 4040 } | 4040 } |
| 4041 | 4041 |
| 4042 | 4042 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4097 float Float32ArrayTraits::defaultValue() { | 4097 float Float32ArrayTraits::defaultValue() { |
| 4098 return static_cast<float>(base::OS::nan_value()); | 4098 return static_cast<float>(base::OS::nan_value()); |
| 4099 } | 4099 } |
| 4100 | 4100 |
| 4101 | 4101 |
| 4102 double Float64ArrayTraits::defaultValue() { return base::OS::nan_value(); } | 4102 double Float64ArrayTraits::defaultValue() { return base::OS::nan_value(); } |
| 4103 | 4103 |
| 4104 | 4104 |
| 4105 template <class Traits> | 4105 template <class Traits> |
| 4106 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { | 4106 typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { |
| 4107 ASSERT((index >= 0) && (index < this->length())); | 4107 DCHECK((index >= 0) && (index < this->length())); |
| 4108 ElementType* ptr = reinterpret_cast<ElementType*>( | 4108 ElementType* ptr = reinterpret_cast<ElementType*>( |
| 4109 FIELD_ADDR(this, kDataOffset)); | 4109 FIELD_ADDR(this, kDataOffset)); |
| 4110 return ptr[index]; | 4110 return ptr[index]; |
| 4111 } | 4111 } |
| 4112 | 4112 |
| 4113 | 4113 |
| 4114 template<> inline | 4114 template<> inline |
| 4115 FixedTypedArray<Float64ArrayTraits>::ElementType | 4115 FixedTypedArray<Float64ArrayTraits>::ElementType |
| 4116 FixedTypedArray<Float64ArrayTraits>::get_scalar(int index) { | 4116 FixedTypedArray<Float64ArrayTraits>::get_scalar(int index) { |
| 4117 ASSERT((index >= 0) && (index < this->length())); | 4117 DCHECK((index >= 0) && (index < this->length())); |
| 4118 return READ_DOUBLE_FIELD(this, ElementOffset(index)); | 4118 return READ_DOUBLE_FIELD(this, ElementOffset(index)); |
| 4119 } | 4119 } |
| 4120 | 4120 |
| 4121 | 4121 |
| 4122 template <class Traits> | 4122 template <class Traits> |
| 4123 void FixedTypedArray<Traits>::set(int index, ElementType value) { | 4123 void FixedTypedArray<Traits>::set(int index, ElementType value) { |
| 4124 ASSERT((index >= 0) && (index < this->length())); | 4124 DCHECK((index >= 0) && (index < this->length())); |
| 4125 ElementType* ptr = reinterpret_cast<ElementType*>( | 4125 ElementType* ptr = reinterpret_cast<ElementType*>( |
| 4126 FIELD_ADDR(this, kDataOffset)); | 4126 FIELD_ADDR(this, kDataOffset)); |
| 4127 ptr[index] = value; | 4127 ptr[index] = value; |
| 4128 } | 4128 } |
| 4129 | 4129 |
| 4130 | 4130 |
| 4131 template<> inline | 4131 template<> inline |
| 4132 void FixedTypedArray<Float64ArrayTraits>::set( | 4132 void FixedTypedArray<Float64ArrayTraits>::set( |
| 4133 int index, Float64ArrayTraits::ElementType value) { | 4133 int index, Float64ArrayTraits::ElementType value) { |
| 4134 ASSERT((index >= 0) && (index < this->length())); | 4134 DCHECK((index >= 0) && (index < this->length())); |
| 4135 WRITE_DOUBLE_FIELD(this, ElementOffset(index), value); | 4135 WRITE_DOUBLE_FIELD(this, ElementOffset(index), value); |
| 4136 } | 4136 } |
| 4137 | 4137 |
| 4138 | 4138 |
| 4139 template <class Traits> | 4139 template <class Traits> |
| 4140 typename Traits::ElementType FixedTypedArray<Traits>::from_int(int value) { | 4140 typename Traits::ElementType FixedTypedArray<Traits>::from_int(int value) { |
| 4141 return static_cast<ElementType>(value); | 4141 return static_cast<ElementType>(value); |
| 4142 } | 4142 } |
| 4143 | 4143 |
| 4144 | 4144 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4194 if (index < static_cast<uint32_t>(array->length())) { | 4194 if (index < static_cast<uint32_t>(array->length())) { |
| 4195 if (value->IsSmi()) { | 4195 if (value->IsSmi()) { |
| 4196 int int_value = Handle<Smi>::cast(value)->value(); | 4196 int int_value = Handle<Smi>::cast(value)->value(); |
| 4197 cast_value = from_int(int_value); | 4197 cast_value = from_int(int_value); |
| 4198 } else if (value->IsHeapNumber()) { | 4198 } else if (value->IsHeapNumber()) { |
| 4199 double double_value = Handle<HeapNumber>::cast(value)->value(); | 4199 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 4200 cast_value = from_double(double_value); | 4200 cast_value = from_double(double_value); |
| 4201 } else { | 4201 } else { |
| 4202 // Clamp undefined to the default value. All other types have been | 4202 // Clamp undefined to the default value. All other types have been |
| 4203 // converted to a number type further up in the call chain. | 4203 // converted to a number type further up in the call chain. |
| 4204 ASSERT(value->IsUndefined()); | 4204 DCHECK(value->IsUndefined()); |
| 4205 } | 4205 } |
| 4206 array->set(index, cast_value); | 4206 array->set(index, cast_value); |
| 4207 } | 4207 } |
| 4208 return Traits::ToHandle(array->GetIsolate(), cast_value); | 4208 return Traits::ToHandle(array->GetIsolate(), cast_value); |
| 4209 } | 4209 } |
| 4210 | 4210 |
| 4211 | 4211 |
| 4212 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { | 4212 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { |
| 4213 return handle(Smi::FromInt(scalar), isolate); | 4213 return handle(Smi::FromInt(scalar), isolate); |
| 4214 } | 4214 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4254 return isolate->factory()->NewNumber(scalar); | 4254 return isolate->factory()->NewNumber(scalar); |
| 4255 } | 4255 } |
| 4256 | 4256 |
| 4257 | 4257 |
| 4258 int Map::visitor_id() { | 4258 int Map::visitor_id() { |
| 4259 return READ_BYTE_FIELD(this, kVisitorIdOffset); | 4259 return READ_BYTE_FIELD(this, kVisitorIdOffset); |
| 4260 } | 4260 } |
| 4261 | 4261 |
| 4262 | 4262 |
| 4263 void Map::set_visitor_id(int id) { | 4263 void Map::set_visitor_id(int id) { |
| 4264 ASSERT(0 <= id && id < 256); | 4264 DCHECK(0 <= id && id < 256); |
| 4265 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); | 4265 WRITE_BYTE_FIELD(this, kVisitorIdOffset, static_cast<byte>(id)); |
| 4266 } | 4266 } |
| 4267 | 4267 |
| 4268 | 4268 |
| 4269 int Map::instance_size() { | 4269 int Map::instance_size() { |
| 4270 return NOBARRIER_READ_BYTE_FIELD( | 4270 return NOBARRIER_READ_BYTE_FIELD( |
| 4271 this, kInstanceSizeOffset) << kPointerSizeLog2; | 4271 this, kInstanceSizeOffset) << kPointerSizeLog2; |
| 4272 } | 4272 } |
| 4273 | 4273 |
| 4274 | 4274 |
| 4275 int Map::inobject_properties() { | 4275 int Map::inobject_properties() { |
| 4276 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); | 4276 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); |
| 4277 } | 4277 } |
| 4278 | 4278 |
| 4279 | 4279 |
| 4280 int Map::pre_allocated_property_fields() { | 4280 int Map::pre_allocated_property_fields() { |
| 4281 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 4281 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
| 4282 } | 4282 } |
| 4283 | 4283 |
| 4284 | 4284 |
| 4285 int Map::GetInObjectPropertyOffset(int index) { | 4285 int Map::GetInObjectPropertyOffset(int index) { |
| 4286 // Adjust for the number of properties stored in the object. | 4286 // Adjust for the number of properties stored in the object. |
| 4287 index -= inobject_properties(); | 4287 index -= inobject_properties(); |
| 4288 ASSERT(index <= 0); | 4288 DCHECK(index <= 0); |
| 4289 return instance_size() + (index * kPointerSize); | 4289 return instance_size() + (index * kPointerSize); |
| 4290 } | 4290 } |
| 4291 | 4291 |
| 4292 | 4292 |
| 4293 int HeapObject::SizeFromMap(Map* map) { | 4293 int HeapObject::SizeFromMap(Map* map) { |
| 4294 int instance_size = map->instance_size(); | 4294 int instance_size = map->instance_size(); |
| 4295 if (instance_size != kVariableSizeSentinel) return instance_size; | 4295 if (instance_size != kVariableSizeSentinel) return instance_size; |
| 4296 // Only inline the most frequent cases. | 4296 // Only inline the most frequent cases. |
| 4297 InstanceType instance_type = map->instance_type(); | 4297 InstanceType instance_type = map->instance_type(); |
| 4298 if (instance_type == FIXED_ARRAY_TYPE) { | 4298 if (instance_type == FIXED_ARRAY_TYPE) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4319 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 4319 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
| 4320 } | 4320 } |
| 4321 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { | 4321 if (instance_type == CONSTANT_POOL_ARRAY_TYPE) { |
| 4322 return reinterpret_cast<ConstantPoolArray*>(this)->size(); | 4322 return reinterpret_cast<ConstantPoolArray*>(this)->size(); |
| 4323 } | 4323 } |
| 4324 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && | 4324 if (instance_type >= FIRST_FIXED_TYPED_ARRAY_TYPE && |
| 4325 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { | 4325 instance_type <= LAST_FIXED_TYPED_ARRAY_TYPE) { |
| 4326 return reinterpret_cast<FixedTypedArrayBase*>( | 4326 return reinterpret_cast<FixedTypedArrayBase*>( |
| 4327 this)->TypedArraySize(instance_type); | 4327 this)->TypedArraySize(instance_type); |
| 4328 } | 4328 } |
| 4329 ASSERT(instance_type == CODE_TYPE); | 4329 DCHECK(instance_type == CODE_TYPE); |
| 4330 return reinterpret_cast<Code*>(this)->CodeSize(); | 4330 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 4331 } | 4331 } |
| 4332 | 4332 |
| 4333 | 4333 |
| 4334 void Map::set_instance_size(int value) { | 4334 void Map::set_instance_size(int value) { |
| 4335 ASSERT_EQ(0, value & (kPointerSize - 1)); | 4335 DCHECK_EQ(0, value & (kPointerSize - 1)); |
| 4336 value >>= kPointerSizeLog2; | 4336 value >>= kPointerSizeLog2; |
| 4337 ASSERT(0 <= value && value < 256); | 4337 DCHECK(0 <= value && value < 256); |
| 4338 NOBARRIER_WRITE_BYTE_FIELD( | 4338 NOBARRIER_WRITE_BYTE_FIELD( |
| 4339 this, kInstanceSizeOffset, static_cast<byte>(value)); | 4339 this, kInstanceSizeOffset, static_cast<byte>(value)); |
| 4340 } | 4340 } |
| 4341 | 4341 |
| 4342 | 4342 |
| 4343 void Map::set_inobject_properties(int value) { | 4343 void Map::set_inobject_properties(int value) { |
| 4344 ASSERT(0 <= value && value < 256); | 4344 DCHECK(0 <= value && value < 256); |
| 4345 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); | 4345 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); |
| 4346 } | 4346 } |
| 4347 | 4347 |
| 4348 | 4348 |
| 4349 void Map::set_pre_allocated_property_fields(int value) { | 4349 void Map::set_pre_allocated_property_fields(int value) { |
| 4350 ASSERT(0 <= value && value < 256); | 4350 DCHECK(0 <= value && value < 256); |
| 4351 WRITE_BYTE_FIELD(this, | 4351 WRITE_BYTE_FIELD(this, |
| 4352 kPreAllocatedPropertyFieldsOffset, | 4352 kPreAllocatedPropertyFieldsOffset, |
| 4353 static_cast<byte>(value)); | 4353 static_cast<byte>(value)); |
| 4354 } | 4354 } |
| 4355 | 4355 |
| 4356 | 4356 |
| 4357 InstanceType Map::instance_type() { | 4357 InstanceType Map::instance_type() { |
| 4358 return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset)); | 4358 return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset)); |
| 4359 } | 4359 } |
| 4360 | 4360 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4664 kind() == COMPARE_IC || kind() == COMPARE_NIL_IC || | 4664 kind() == COMPARE_IC || kind() == COMPARE_NIL_IC || |
| 4665 kind() == TO_BOOLEAN_IC; | 4665 kind() == TO_BOOLEAN_IC; |
| 4666 } | 4666 } |
| 4667 | 4667 |
| 4668 | 4668 |
| 4669 InlineCacheState Code::ic_state() { | 4669 InlineCacheState Code::ic_state() { |
| 4670 InlineCacheState result = ExtractICStateFromFlags(flags()); | 4670 InlineCacheState result = ExtractICStateFromFlags(flags()); |
| 4671 // Only allow uninitialized or debugger states for non-IC code | 4671 // Only allow uninitialized or debugger states for non-IC code |
| 4672 // objects. This is used in the debugger to determine whether or not | 4672 // objects. This is used in the debugger to determine whether or not |
| 4673 // a call to code object has been replaced with a debug break call. | 4673 // a call to code object has been replaced with a debug break call. |
| 4674 ASSERT(is_inline_cache_stub() || | 4674 DCHECK(is_inline_cache_stub() || |
| 4675 result == UNINITIALIZED || | 4675 result == UNINITIALIZED || |
| 4676 result == DEBUG_STUB); | 4676 result == DEBUG_STUB); |
| 4677 return result; | 4677 return result; |
| 4678 } | 4678 } |
| 4679 | 4679 |
| 4680 | 4680 |
| 4681 ExtraICState Code::extra_ic_state() { | 4681 ExtraICState Code::extra_ic_state() { |
| 4682 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB); | 4682 DCHECK(is_inline_cache_stub() || ic_state() == DEBUG_STUB); |
| 4683 return ExtractExtraICStateFromFlags(flags()); | 4683 return ExtractExtraICStateFromFlags(flags()); |
| 4684 } | 4684 } |
| 4685 | 4685 |
| 4686 | 4686 |
| 4687 Code::StubType Code::type() { | 4687 Code::StubType Code::type() { |
| 4688 return ExtractTypeFromFlags(flags()); | 4688 return ExtractTypeFromFlags(flags()); |
| 4689 } | 4689 } |
| 4690 | 4690 |
| 4691 | 4691 |
| 4692 // For initialization. | 4692 // For initialization. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4712 | 4712 |
| 4713 | 4713 |
| 4714 inline void Code::set_is_crankshafted(bool value) { | 4714 inline void Code::set_is_crankshafted(bool value) { |
| 4715 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4715 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 4716 int updated = IsCrankshaftedField::update(previous, value); | 4716 int updated = IsCrankshaftedField::update(previous, value); |
| 4717 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4717 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
| 4718 } | 4718 } |
| 4719 | 4719 |
| 4720 | 4720 |
| 4721 inline bool Code::is_turbofanned() { | 4721 inline bool Code::is_turbofanned() { |
| 4722 ASSERT(kind() == OPTIMIZED_FUNCTION || kind() == STUB); | 4722 DCHECK(kind() == OPTIMIZED_FUNCTION || kind() == STUB); |
| 4723 return IsTurbofannedField::decode( | 4723 return IsTurbofannedField::decode( |
| 4724 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4724 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4725 } | 4725 } |
| 4726 | 4726 |
| 4727 | 4727 |
| 4728 inline void Code::set_is_turbofanned(bool value) { | 4728 inline void Code::set_is_turbofanned(bool value) { |
| 4729 ASSERT(kind() == OPTIMIZED_FUNCTION || kind() == STUB); | 4729 DCHECK(kind() == OPTIMIZED_FUNCTION || kind() == STUB); |
| 4730 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | 4730 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4731 int updated = IsTurbofannedField::update(previous, value); | 4731 int updated = IsTurbofannedField::update(previous, value); |
| 4732 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | 4732 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4733 } | 4733 } |
| 4734 | 4734 |
| 4735 | 4735 |
| 4736 bool Code::optimizable() { | 4736 bool Code::optimizable() { |
| 4737 ASSERT_EQ(FUNCTION, kind()); | 4737 DCHECK_EQ(FUNCTION, kind()); |
| 4738 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; | 4738 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; |
| 4739 } | 4739 } |
| 4740 | 4740 |
| 4741 | 4741 |
| 4742 void Code::set_optimizable(bool value) { | 4742 void Code::set_optimizable(bool value) { |
| 4743 ASSERT_EQ(FUNCTION, kind()); | 4743 DCHECK_EQ(FUNCTION, kind()); |
| 4744 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); | 4744 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); |
| 4745 } | 4745 } |
| 4746 | 4746 |
| 4747 | 4747 |
| 4748 bool Code::has_deoptimization_support() { | 4748 bool Code::has_deoptimization_support() { |
| 4749 ASSERT_EQ(FUNCTION, kind()); | 4749 DCHECK_EQ(FUNCTION, kind()); |
| 4750 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 4750 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 4751 return FullCodeFlagsHasDeoptimizationSupportField::decode(flags); | 4751 return FullCodeFlagsHasDeoptimizationSupportField::decode(flags); |
| 4752 } | 4752 } |
| 4753 | 4753 |
| 4754 | 4754 |
| 4755 void Code::set_has_deoptimization_support(bool value) { | 4755 void Code::set_has_deoptimization_support(bool value) { |
| 4756 ASSERT_EQ(FUNCTION, kind()); | 4756 DCHECK_EQ(FUNCTION, kind()); |
| 4757 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 4757 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 4758 flags = FullCodeFlagsHasDeoptimizationSupportField::update(flags, value); | 4758 flags = FullCodeFlagsHasDeoptimizationSupportField::update(flags, value); |
| 4759 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); | 4759 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); |
| 4760 } | 4760 } |
| 4761 | 4761 |
| 4762 | 4762 |
| 4763 bool Code::has_debug_break_slots() { | 4763 bool Code::has_debug_break_slots() { |
| 4764 ASSERT_EQ(FUNCTION, kind()); | 4764 DCHECK_EQ(FUNCTION, kind()); |
| 4765 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 4765 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 4766 return FullCodeFlagsHasDebugBreakSlotsField::decode(flags); | 4766 return FullCodeFlagsHasDebugBreakSlotsField::decode(flags); |
| 4767 } | 4767 } |
| 4768 | 4768 |
| 4769 | 4769 |
| 4770 void Code::set_has_debug_break_slots(bool value) { | 4770 void Code::set_has_debug_break_slots(bool value) { |
| 4771 ASSERT_EQ(FUNCTION, kind()); | 4771 DCHECK_EQ(FUNCTION, kind()); |
| 4772 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 4772 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 4773 flags = FullCodeFlagsHasDebugBreakSlotsField::update(flags, value); | 4773 flags = FullCodeFlagsHasDebugBreakSlotsField::update(flags, value); |
| 4774 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); | 4774 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); |
| 4775 } | 4775 } |
| 4776 | 4776 |
| 4777 | 4777 |
| 4778 bool Code::is_compiled_optimizable() { | 4778 bool Code::is_compiled_optimizable() { |
| 4779 ASSERT_EQ(FUNCTION, kind()); | 4779 DCHECK_EQ(FUNCTION, kind()); |
| 4780 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 4780 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 4781 return FullCodeFlagsIsCompiledOptimizable::decode(flags); | 4781 return FullCodeFlagsIsCompiledOptimizable::decode(flags); |
| 4782 } | 4782 } |
| 4783 | 4783 |
| 4784 | 4784 |
| 4785 void Code::set_compiled_optimizable(bool value) { | 4785 void Code::set_compiled_optimizable(bool value) { |
| 4786 ASSERT_EQ(FUNCTION, kind()); | 4786 DCHECK_EQ(FUNCTION, kind()); |
| 4787 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); | 4787 byte flags = READ_BYTE_FIELD(this, kFullCodeFlags); |
| 4788 flags = FullCodeFlagsIsCompiledOptimizable::update(flags, value); | 4788 flags = FullCodeFlagsIsCompiledOptimizable::update(flags, value); |
| 4789 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); | 4789 WRITE_BYTE_FIELD(this, kFullCodeFlags, flags); |
| 4790 } | 4790 } |
| 4791 | 4791 |
| 4792 | 4792 |
| 4793 int Code::allow_osr_at_loop_nesting_level() { | 4793 int Code::allow_osr_at_loop_nesting_level() { |
| 4794 ASSERT_EQ(FUNCTION, kind()); | 4794 DCHECK_EQ(FUNCTION, kind()); |
| 4795 int fields = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4795 int fields = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 4796 return AllowOSRAtLoopNestingLevelField::decode(fields); | 4796 return AllowOSRAtLoopNestingLevelField::decode(fields); |
| 4797 } | 4797 } |
| 4798 | 4798 |
| 4799 | 4799 |
| 4800 void Code::set_allow_osr_at_loop_nesting_level(int level) { | 4800 void Code::set_allow_osr_at_loop_nesting_level(int level) { |
| 4801 ASSERT_EQ(FUNCTION, kind()); | 4801 DCHECK_EQ(FUNCTION, kind()); |
| 4802 ASSERT(level >= 0 && level <= kMaxLoopNestingMarker); | 4802 DCHECK(level >= 0 && level <= kMaxLoopNestingMarker); |
| 4803 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4803 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 4804 int updated = AllowOSRAtLoopNestingLevelField::update(previous, level); | 4804 int updated = AllowOSRAtLoopNestingLevelField::update(previous, level); |
| 4805 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4805 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
| 4806 } | 4806 } |
| 4807 | 4807 |
| 4808 | 4808 |
| 4809 int Code::profiler_ticks() { | 4809 int Code::profiler_ticks() { |
| 4810 ASSERT_EQ(FUNCTION, kind()); | 4810 DCHECK_EQ(FUNCTION, kind()); |
| 4811 return READ_BYTE_FIELD(this, kProfilerTicksOffset); | 4811 return READ_BYTE_FIELD(this, kProfilerTicksOffset); |
| 4812 } | 4812 } |
| 4813 | 4813 |
| 4814 | 4814 |
| 4815 void Code::set_profiler_ticks(int ticks) { | 4815 void Code::set_profiler_ticks(int ticks) { |
| 4816 ASSERT_EQ(FUNCTION, kind()); | 4816 DCHECK_EQ(FUNCTION, kind()); |
| 4817 ASSERT(ticks < 256); | 4817 DCHECK(ticks < 256); |
| 4818 WRITE_BYTE_FIELD(this, kProfilerTicksOffset, ticks); | 4818 WRITE_BYTE_FIELD(this, kProfilerTicksOffset, ticks); |
| 4819 } | 4819 } |
| 4820 | 4820 |
| 4821 | 4821 |
| 4822 int Code::builtin_index() { | 4822 int Code::builtin_index() { |
| 4823 ASSERT_EQ(BUILTIN, kind()); | 4823 DCHECK_EQ(BUILTIN, kind()); |
| 4824 return READ_INT32_FIELD(this, kKindSpecificFlags1Offset); | 4824 return READ_INT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4825 } | 4825 } |
| 4826 | 4826 |
| 4827 | 4827 |
| 4828 void Code::set_builtin_index(int index) { | 4828 void Code::set_builtin_index(int index) { |
| 4829 ASSERT_EQ(BUILTIN, kind()); | 4829 DCHECK_EQ(BUILTIN, kind()); |
| 4830 WRITE_INT32_FIELD(this, kKindSpecificFlags1Offset, index); | 4830 WRITE_INT32_FIELD(this, kKindSpecificFlags1Offset, index); |
| 4831 } | 4831 } |
| 4832 | 4832 |
| 4833 | 4833 |
| 4834 unsigned Code::stack_slots() { | 4834 unsigned Code::stack_slots() { |
| 4835 ASSERT(is_crankshafted()); | 4835 DCHECK(is_crankshafted()); |
| 4836 return StackSlotsField::decode( | 4836 return StackSlotsField::decode( |
| 4837 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4837 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4838 } | 4838 } |
| 4839 | 4839 |
| 4840 | 4840 |
| 4841 void Code::set_stack_slots(unsigned slots) { | 4841 void Code::set_stack_slots(unsigned slots) { |
| 4842 CHECK(slots <= (1 << kStackSlotsBitCount)); | 4842 CHECK(slots <= (1 << kStackSlotsBitCount)); |
| 4843 ASSERT(is_crankshafted()); | 4843 DCHECK(is_crankshafted()); |
| 4844 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | 4844 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4845 int updated = StackSlotsField::update(previous, slots); | 4845 int updated = StackSlotsField::update(previous, slots); |
| 4846 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | 4846 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4847 } | 4847 } |
| 4848 | 4848 |
| 4849 | 4849 |
| 4850 unsigned Code::safepoint_table_offset() { | 4850 unsigned Code::safepoint_table_offset() { |
| 4851 ASSERT(is_crankshafted()); | 4851 DCHECK(is_crankshafted()); |
| 4852 return SafepointTableOffsetField::decode( | 4852 return SafepointTableOffsetField::decode( |
| 4853 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)); | 4853 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)); |
| 4854 } | 4854 } |
| 4855 | 4855 |
| 4856 | 4856 |
| 4857 void Code::set_safepoint_table_offset(unsigned offset) { | 4857 void Code::set_safepoint_table_offset(unsigned offset) { |
| 4858 CHECK(offset <= (1 << kSafepointTableOffsetBitCount)); | 4858 CHECK(offset <= (1 << kSafepointTableOffsetBitCount)); |
| 4859 ASSERT(is_crankshafted()); | 4859 DCHECK(is_crankshafted()); |
| 4860 ASSERT(IsAligned(offset, static_cast<unsigned>(kIntSize))); | 4860 DCHECK(IsAligned(offset, static_cast<unsigned>(kIntSize))); |
| 4861 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4861 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 4862 int updated = SafepointTableOffsetField::update(previous, offset); | 4862 int updated = SafepointTableOffsetField::update(previous, offset); |
| 4863 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4863 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
| 4864 } | 4864 } |
| 4865 | 4865 |
| 4866 | 4866 |
| 4867 unsigned Code::back_edge_table_offset() { | 4867 unsigned Code::back_edge_table_offset() { |
| 4868 ASSERT_EQ(FUNCTION, kind()); | 4868 DCHECK_EQ(FUNCTION, kind()); |
| 4869 return BackEdgeTableOffsetField::decode( | 4869 return BackEdgeTableOffsetField::decode( |
| 4870 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)) << kPointerSizeLog2; | 4870 READ_UINT32_FIELD(this, kKindSpecificFlags2Offset)) << kPointerSizeLog2; |
| 4871 } | 4871 } |
| 4872 | 4872 |
| 4873 | 4873 |
| 4874 void Code::set_back_edge_table_offset(unsigned offset) { | 4874 void Code::set_back_edge_table_offset(unsigned offset) { |
| 4875 ASSERT_EQ(FUNCTION, kind()); | 4875 DCHECK_EQ(FUNCTION, kind()); |
| 4876 ASSERT(IsAligned(offset, static_cast<unsigned>(kPointerSize))); | 4876 DCHECK(IsAligned(offset, static_cast<unsigned>(kPointerSize))); |
| 4877 offset = offset >> kPointerSizeLog2; | 4877 offset = offset >> kPointerSizeLog2; |
| 4878 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4878 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 4879 int updated = BackEdgeTableOffsetField::update(previous, offset); | 4879 int updated = BackEdgeTableOffsetField::update(previous, offset); |
| 4880 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4880 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
| 4881 } | 4881 } |
| 4882 | 4882 |
| 4883 | 4883 |
| 4884 bool Code::back_edges_patched_for_osr() { | 4884 bool Code::back_edges_patched_for_osr() { |
| 4885 ASSERT_EQ(FUNCTION, kind()); | 4885 DCHECK_EQ(FUNCTION, kind()); |
| 4886 return allow_osr_at_loop_nesting_level() > 0; | 4886 return allow_osr_at_loop_nesting_level() > 0; |
| 4887 } | 4887 } |
| 4888 | 4888 |
| 4889 | 4889 |
| 4890 byte Code::to_boolean_state() { | 4890 byte Code::to_boolean_state() { |
| 4891 return extra_ic_state(); | 4891 return extra_ic_state(); |
| 4892 } | 4892 } |
| 4893 | 4893 |
| 4894 | 4894 |
| 4895 bool Code::has_function_cache() { | 4895 bool Code::has_function_cache() { |
| 4896 ASSERT(kind() == STUB); | 4896 DCHECK(kind() == STUB); |
| 4897 return HasFunctionCacheField::decode( | 4897 return HasFunctionCacheField::decode( |
| 4898 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4898 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4899 } | 4899 } |
| 4900 | 4900 |
| 4901 | 4901 |
| 4902 void Code::set_has_function_cache(bool flag) { | 4902 void Code::set_has_function_cache(bool flag) { |
| 4903 ASSERT(kind() == STUB); | 4903 DCHECK(kind() == STUB); |
| 4904 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | 4904 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4905 int updated = HasFunctionCacheField::update(previous, flag); | 4905 int updated = HasFunctionCacheField::update(previous, flag); |
| 4906 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | 4906 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4907 } | 4907 } |
| 4908 | 4908 |
| 4909 | 4909 |
| 4910 bool Code::marked_for_deoptimization() { | 4910 bool Code::marked_for_deoptimization() { |
| 4911 ASSERT(kind() == OPTIMIZED_FUNCTION); | 4911 DCHECK(kind() == OPTIMIZED_FUNCTION); |
| 4912 return MarkedForDeoptimizationField::decode( | 4912 return MarkedForDeoptimizationField::decode( |
| 4913 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4913 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4914 } | 4914 } |
| 4915 | 4915 |
| 4916 | 4916 |
| 4917 void Code::set_marked_for_deoptimization(bool flag) { | 4917 void Code::set_marked_for_deoptimization(bool flag) { |
| 4918 ASSERT(kind() == OPTIMIZED_FUNCTION); | 4918 DCHECK(kind() == OPTIMIZED_FUNCTION); |
| 4919 ASSERT(!flag || AllowDeoptimization::IsAllowed(GetIsolate())); | 4919 DCHECK(!flag || AllowDeoptimization::IsAllowed(GetIsolate())); |
| 4920 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | 4920 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4921 int updated = MarkedForDeoptimizationField::update(previous, flag); | 4921 int updated = MarkedForDeoptimizationField::update(previous, flag); |
| 4922 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | 4922 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4923 } | 4923 } |
| 4924 | 4924 |
| 4925 | 4925 |
| 4926 bool Code::is_weak_stub() { | 4926 bool Code::is_weak_stub() { |
| 4927 return CanBeWeakStub() && WeakStubField::decode( | 4927 return CanBeWeakStub() && WeakStubField::decode( |
| 4928 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4928 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4929 } | 4929 } |
| 4930 | 4930 |
| 4931 | 4931 |
| 4932 void Code::mark_as_weak_stub() { | 4932 void Code::mark_as_weak_stub() { |
| 4933 ASSERT(CanBeWeakStub()); | 4933 DCHECK(CanBeWeakStub()); |
| 4934 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | 4934 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4935 int updated = WeakStubField::update(previous, true); | 4935 int updated = WeakStubField::update(previous, true); |
| 4936 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | 4936 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4937 } | 4937 } |
| 4938 | 4938 |
| 4939 | 4939 |
| 4940 bool Code::is_invalidated_weak_stub() { | 4940 bool Code::is_invalidated_weak_stub() { |
| 4941 return is_weak_stub() && InvalidatedWeakStubField::decode( | 4941 return is_weak_stub() && InvalidatedWeakStubField::decode( |
| 4942 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4942 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4943 } | 4943 } |
| 4944 | 4944 |
| 4945 | 4945 |
| 4946 void Code::mark_as_invalidated_weak_stub() { | 4946 void Code::mark_as_invalidated_weak_stub() { |
| 4947 ASSERT(is_inline_cache_stub()); | 4947 DCHECK(is_inline_cache_stub()); |
| 4948 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); | 4948 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4949 int updated = InvalidatedWeakStubField::update(previous, true); | 4949 int updated = InvalidatedWeakStubField::update(previous, true); |
| 4950 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); | 4950 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4951 } | 4951 } |
| 4952 | 4952 |
| 4953 | 4953 |
| 4954 bool Code::is_inline_cache_stub() { | 4954 bool Code::is_inline_cache_stub() { |
| 4955 Kind kind = this->kind(); | 4955 Kind kind = this->kind(); |
| 4956 switch (kind) { | 4956 switch (kind) { |
| 4957 #define CASE(name) case name: return true; | 4957 #define CASE(name) case name: return true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4971 return ic_state() == DEBUG_STUB; | 4971 return ic_state() == DEBUG_STUB; |
| 4972 } | 4972 } |
| 4973 | 4973 |
| 4974 | 4974 |
| 4975 ConstantPoolArray* Code::constant_pool() { | 4975 ConstantPoolArray* Code::constant_pool() { |
| 4976 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); | 4976 return ConstantPoolArray::cast(READ_FIELD(this, kConstantPoolOffset)); |
| 4977 } | 4977 } |
| 4978 | 4978 |
| 4979 | 4979 |
| 4980 void Code::set_constant_pool(Object* value) { | 4980 void Code::set_constant_pool(Object* value) { |
| 4981 ASSERT(value->IsConstantPoolArray()); | 4981 DCHECK(value->IsConstantPoolArray()); |
| 4982 WRITE_FIELD(this, kConstantPoolOffset, value); | 4982 WRITE_FIELD(this, kConstantPoolOffset, value); |
| 4983 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); | 4983 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); |
| 4984 } | 4984 } |
| 4985 | 4985 |
| 4986 | 4986 |
| 4987 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, | 4987 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, |
| 4988 ExtraICState extra_ic_state, StubType type, | 4988 ExtraICState extra_ic_state, StubType type, |
| 4989 CacheHolderFlag holder) { | 4989 CacheHolderFlag holder) { |
| 4990 // Compute the bit mask. | 4990 // Compute the bit mask. |
| 4991 unsigned int bits = KindField::encode(kind) | 4991 unsigned int bits = KindField::encode(kind) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5076 return FLAG_weak_embedded_objects_in_optimized_code; | 5076 return FLAG_weak_embedded_objects_in_optimized_code; |
| 5077 } | 5077 } |
| 5078 return false; | 5078 return false; |
| 5079 } | 5079 } |
| 5080 | 5080 |
| 5081 | 5081 |
| 5082 class Code::FindAndReplacePattern { | 5082 class Code::FindAndReplacePattern { |
| 5083 public: | 5083 public: |
| 5084 FindAndReplacePattern() : count_(0) { } | 5084 FindAndReplacePattern() : count_(0) { } |
| 5085 void Add(Handle<Map> map_to_find, Handle<Object> obj_to_replace) { | 5085 void Add(Handle<Map> map_to_find, Handle<Object> obj_to_replace) { |
| 5086 ASSERT(count_ < kMaxCount); | 5086 DCHECK(count_ < kMaxCount); |
| 5087 find_[count_] = map_to_find; | 5087 find_[count_] = map_to_find; |
| 5088 replace_[count_] = obj_to_replace; | 5088 replace_[count_] = obj_to_replace; |
| 5089 ++count_; | 5089 ++count_; |
| 5090 } | 5090 } |
| 5091 private: | 5091 private: |
| 5092 static const int kMaxCount = 4; | 5092 static const int kMaxCount = 4; |
| 5093 int count_; | 5093 int count_; |
| 5094 Handle<Map> find_[kMaxCount]; | 5094 Handle<Map> find_[kMaxCount]; |
| 5095 Handle<Object> replace_[kMaxCount]; | 5095 Handle<Object> replace_[kMaxCount]; |
| 5096 friend class Code; | 5096 friend class Code; |
| 5097 }; | 5097 }; |
| 5098 | 5098 |
| 5099 | 5099 |
| 5100 bool Code::IsWeakObjectInIC(Object* object) { | 5100 bool Code::IsWeakObjectInIC(Object* object) { |
| 5101 return object->IsMap() && Map::cast(object)->CanTransition() && | 5101 return object->IsMap() && Map::cast(object)->CanTransition() && |
| 5102 FLAG_collect_maps && | 5102 FLAG_collect_maps && |
| 5103 FLAG_weak_embedded_maps_in_ic; | 5103 FLAG_weak_embedded_maps_in_ic; |
| 5104 } | 5104 } |
| 5105 | 5105 |
| 5106 | 5106 |
| 5107 Object* Map::prototype() const { | 5107 Object* Map::prototype() const { |
| 5108 return READ_FIELD(this, kPrototypeOffset); | 5108 return READ_FIELD(this, kPrototypeOffset); |
| 5109 } | 5109 } |
| 5110 | 5110 |
| 5111 | 5111 |
| 5112 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 5112 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
| 5113 ASSERT(value->IsNull() || value->IsJSReceiver()); | 5113 DCHECK(value->IsNull() || value->IsJSReceiver()); |
| 5114 WRITE_FIELD(this, kPrototypeOffset, value); | 5114 WRITE_FIELD(this, kPrototypeOffset, value); |
| 5115 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); | 5115 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); |
| 5116 } | 5116 } |
| 5117 | 5117 |
| 5118 | 5118 |
| 5119 // If the descriptor is using the empty transition array, install a new empty | 5119 // If the descriptor is using the empty transition array, install a new empty |
| 5120 // transition array that will have place for an element transition. | 5120 // transition array that will have place for an element transition. |
| 5121 static void EnsureHasTransitionArray(Handle<Map> map) { | 5121 static void EnsureHasTransitionArray(Handle<Map> map) { |
| 5122 Handle<TransitionArray> transitions; | 5122 Handle<TransitionArray> transitions; |
| 5123 if (!map->HasTransitionArray()) { | 5123 if (!map->HasTransitionArray()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5151 | 5151 |
| 5152 | 5152 |
| 5153 uint32_t Map::bit_field3() { | 5153 uint32_t Map::bit_field3() { |
| 5154 return READ_UINT32_FIELD(this, kBitField3Offset); | 5154 return READ_UINT32_FIELD(this, kBitField3Offset); |
| 5155 } | 5155 } |
| 5156 | 5156 |
| 5157 | 5157 |
| 5158 void Map::AppendDescriptor(Descriptor* desc) { | 5158 void Map::AppendDescriptor(Descriptor* desc) { |
| 5159 DescriptorArray* descriptors = instance_descriptors(); | 5159 DescriptorArray* descriptors = instance_descriptors(); |
| 5160 int number_of_own_descriptors = NumberOfOwnDescriptors(); | 5160 int number_of_own_descriptors = NumberOfOwnDescriptors(); |
| 5161 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); | 5161 DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors); |
| 5162 descriptors->Append(desc); | 5162 descriptors->Append(desc); |
| 5163 SetNumberOfOwnDescriptors(number_of_own_descriptors + 1); | 5163 SetNumberOfOwnDescriptors(number_of_own_descriptors + 1); |
| 5164 } | 5164 } |
| 5165 | 5165 |
| 5166 | 5166 |
| 5167 Object* Map::GetBackPointer() { | 5167 Object* Map::GetBackPointer() { |
| 5168 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 5168 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
| 5169 if (object->IsDescriptorArray()) { | 5169 if (object->IsDescriptorArray()) { |
| 5170 return TransitionArray::cast(object)->back_pointer_storage(); | 5170 return TransitionArray::cast(object)->back_pointer_storage(); |
| 5171 } else { | 5171 } else { |
| 5172 ASSERT(object->IsMap() || object->IsUndefined()); | 5172 DCHECK(object->IsMap() || object->IsUndefined()); |
| 5173 return object; | 5173 return object; |
| 5174 } | 5174 } |
| 5175 } | 5175 } |
| 5176 | 5176 |
| 5177 | 5177 |
| 5178 bool Map::HasElementsTransition() { | 5178 bool Map::HasElementsTransition() { |
| 5179 return HasTransitionArray() && transitions()->HasElementsTransition(); | 5179 return HasTransitionArray() && transitions()->HasElementsTransition(); |
| 5180 } | 5180 } |
| 5181 | 5181 |
| 5182 | 5182 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5219 return transitions()->GetPrototypeTransitions(); | 5219 return transitions()->GetPrototypeTransitions(); |
| 5220 } | 5220 } |
| 5221 | 5221 |
| 5222 | 5222 |
| 5223 void Map::SetPrototypeTransitions( | 5223 void Map::SetPrototypeTransitions( |
| 5224 Handle<Map> map, Handle<FixedArray> proto_transitions) { | 5224 Handle<Map> map, Handle<FixedArray> proto_transitions) { |
| 5225 EnsureHasTransitionArray(map); | 5225 EnsureHasTransitionArray(map); |
| 5226 int old_number_of_transitions = map->NumberOfProtoTransitions(); | 5226 int old_number_of_transitions = map->NumberOfProtoTransitions(); |
| 5227 #ifdef DEBUG | 5227 #ifdef DEBUG |
| 5228 if (map->HasPrototypeTransitions()) { | 5228 if (map->HasPrototypeTransitions()) { |
| 5229 ASSERT(map->GetPrototypeTransitions() != *proto_transitions); | 5229 DCHECK(map->GetPrototypeTransitions() != *proto_transitions); |
| 5230 map->ZapPrototypeTransitions(); | 5230 map->ZapPrototypeTransitions(); |
| 5231 } | 5231 } |
| 5232 #endif | 5232 #endif |
| 5233 map->transitions()->SetPrototypeTransitions(*proto_transitions); | 5233 map->transitions()->SetPrototypeTransitions(*proto_transitions); |
| 5234 map->SetNumberOfProtoTransitions(old_number_of_transitions); | 5234 map->SetNumberOfProtoTransitions(old_number_of_transitions); |
| 5235 } | 5235 } |
| 5236 | 5236 |
| 5237 | 5237 |
| 5238 bool Map::HasPrototypeTransitions() { | 5238 bool Map::HasPrototypeTransitions() { |
| 5239 return HasTransitionArray() && transitions()->HasPrototypeTransitions(); | 5239 return HasTransitionArray() && transitions()->HasPrototypeTransitions(); |
| 5240 } | 5240 } |
| 5241 | 5241 |
| 5242 | 5242 |
| 5243 TransitionArray* Map::transitions() const { | 5243 TransitionArray* Map::transitions() const { |
| 5244 ASSERT(HasTransitionArray()); | 5244 DCHECK(HasTransitionArray()); |
| 5245 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 5245 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
| 5246 return TransitionArray::cast(object); | 5246 return TransitionArray::cast(object); |
| 5247 } | 5247 } |
| 5248 | 5248 |
| 5249 | 5249 |
| 5250 void Map::set_transitions(TransitionArray* transition_array, | 5250 void Map::set_transitions(TransitionArray* transition_array, |
| 5251 WriteBarrierMode mode) { | 5251 WriteBarrierMode mode) { |
| 5252 // Transition arrays are not shared. When one is replaced, it should not | 5252 // Transition arrays are not shared. When one is replaced, it should not |
| 5253 // keep referenced objects alive, so we zap it. | 5253 // keep referenced objects alive, so we zap it. |
| 5254 // When there is another reference to the array somewhere (e.g. a handle), | 5254 // When there is another reference to the array somewhere (e.g. a handle), |
| 5255 // not zapping turns from a waste of memory into a source of crashes. | 5255 // not zapping turns from a waste of memory into a source of crashes. |
| 5256 if (HasTransitionArray()) { | 5256 if (HasTransitionArray()) { |
| 5257 #ifdef DEBUG | 5257 #ifdef DEBUG |
| 5258 for (int i = 0; i < transitions()->number_of_transitions(); i++) { | 5258 for (int i = 0; i < transitions()->number_of_transitions(); i++) { |
| 5259 Map* target = transitions()->GetTarget(i); | 5259 Map* target = transitions()->GetTarget(i); |
| 5260 if (target->instance_descriptors() == instance_descriptors()) { | 5260 if (target->instance_descriptors() == instance_descriptors()) { |
| 5261 Name* key = transitions()->GetKey(i); | 5261 Name* key = transitions()->GetKey(i); |
| 5262 int new_target_index = transition_array->Search(key); | 5262 int new_target_index = transition_array->Search(key); |
| 5263 ASSERT(new_target_index != TransitionArray::kNotFound); | 5263 DCHECK(new_target_index != TransitionArray::kNotFound); |
| 5264 ASSERT(transition_array->GetTarget(new_target_index) == target); | 5264 DCHECK(transition_array->GetTarget(new_target_index) == target); |
| 5265 } | 5265 } |
| 5266 } | 5266 } |
| 5267 #endif | 5267 #endif |
| 5268 ASSERT(transitions() != transition_array); | 5268 DCHECK(transitions() != transition_array); |
| 5269 ZapTransitions(); | 5269 ZapTransitions(); |
| 5270 } | 5270 } |
| 5271 | 5271 |
| 5272 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); | 5272 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); |
| 5273 CONDITIONAL_WRITE_BARRIER( | 5273 CONDITIONAL_WRITE_BARRIER( |
| 5274 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); | 5274 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); |
| 5275 } | 5275 } |
| 5276 | 5276 |
| 5277 | 5277 |
| 5278 void Map::init_back_pointer(Object* undefined) { | 5278 void Map::init_back_pointer(Object* undefined) { |
| 5279 ASSERT(undefined->IsUndefined()); | 5279 DCHECK(undefined->IsUndefined()); |
| 5280 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, undefined); | 5280 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, undefined); |
| 5281 } | 5281 } |
| 5282 | 5282 |
| 5283 | 5283 |
| 5284 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) { | 5284 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) { |
| 5285 ASSERT(instance_type() >= FIRST_JS_RECEIVER_TYPE); | 5285 DCHECK(instance_type() >= FIRST_JS_RECEIVER_TYPE); |
| 5286 ASSERT((value->IsUndefined() && GetBackPointer()->IsMap()) || | 5286 DCHECK((value->IsUndefined() && GetBackPointer()->IsMap()) || |
| 5287 (value->IsMap() && GetBackPointer()->IsUndefined())); | 5287 (value->IsMap() && GetBackPointer()->IsUndefined())); |
| 5288 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 5288 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
| 5289 if (object->IsTransitionArray()) { | 5289 if (object->IsTransitionArray()) { |
| 5290 TransitionArray::cast(object)->set_back_pointer_storage(value); | 5290 TransitionArray::cast(object)->set_back_pointer_storage(value); |
| 5291 } else { | 5291 } else { |
| 5292 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, value); | 5292 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, value); |
| 5293 CONDITIONAL_WRITE_BARRIER( | 5293 CONDITIONAL_WRITE_BARRIER( |
| 5294 GetHeap(), this, kTransitionsOrBackPointerOffset, value, mode); | 5294 GetHeap(), this, kTransitionsOrBackPointerOffset, value, mode); |
| 5295 } | 5295 } |
| 5296 } | 5296 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5501 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) | 5501 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) |
| 5502 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 5502 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) |
| 5503 SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset) | 5503 SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset) |
| 5504 | 5504 |
| 5505 #else | 5505 #else |
| 5506 | 5506 |
| 5507 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ | 5507 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ |
| 5508 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ | 5508 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ |
| 5509 int holder::name() const { \ | 5509 int holder::name() const { \ |
| 5510 int value = READ_INT_FIELD(this, offset); \ | 5510 int value = READ_INT_FIELD(this, offset); \ |
| 5511 ASSERT(kHeapObjectTag == 1); \ | 5511 DCHECK(kHeapObjectTag == 1); \ |
| 5512 ASSERT((value & kHeapObjectTag) == 0); \ | 5512 DCHECK((value & kHeapObjectTag) == 0); \ |
| 5513 return value >> 1; \ | 5513 return value >> 1; \ |
| 5514 } \ | 5514 } \ |
| 5515 void holder::set_##name(int value) { \ | 5515 void holder::set_##name(int value) { \ |
| 5516 ASSERT(kHeapObjectTag == 1); \ | 5516 DCHECK(kHeapObjectTag == 1); \ |
| 5517 ASSERT((value & 0xC0000000) == 0xC0000000 || \ | 5517 DCHECK((value & 0xC0000000) == 0xC0000000 || \ |
| 5518 (value & 0xC0000000) == 0x0); \ | 5518 (value & 0xC0000000) == 0x0); \ |
| 5519 WRITE_INT_FIELD(this, \ | 5519 WRITE_INT_FIELD(this, \ |
| 5520 offset, \ | 5520 offset, \ |
| 5521 (value << 1) & ~kHeapObjectTag); \ | 5521 (value << 1) & ~kHeapObjectTag); \ |
| 5522 } | 5522 } |
| 5523 | 5523 |
| 5524 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \ | 5524 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \ |
| 5525 STATIC_ASSERT(holder::offset % kPointerSize == kIntSize); \ | 5525 STATIC_ASSERT(holder::offset % kPointerSize == kIntSize); \ |
| 5526 INT_ACCESSORS(holder, name, offset) | 5526 INT_ACCESSORS(holder, name, offset) |
| 5527 | 5527 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5582 | 5582 |
| 5583 | 5583 |
| 5584 StrictMode SharedFunctionInfo::strict_mode() { | 5584 StrictMode SharedFunctionInfo::strict_mode() { |
| 5585 return BooleanBit::get(compiler_hints(), kStrictModeFunction) | 5585 return BooleanBit::get(compiler_hints(), kStrictModeFunction) |
| 5586 ? STRICT : SLOPPY; | 5586 ? STRICT : SLOPPY; |
| 5587 } | 5587 } |
| 5588 | 5588 |
| 5589 | 5589 |
| 5590 void SharedFunctionInfo::set_strict_mode(StrictMode strict_mode) { | 5590 void SharedFunctionInfo::set_strict_mode(StrictMode strict_mode) { |
| 5591 // We only allow mode transitions from sloppy to strict. | 5591 // We only allow mode transitions from sloppy to strict. |
| 5592 ASSERT(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode); | 5592 DCHECK(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode); |
| 5593 int hints = compiler_hints(); | 5593 int hints = compiler_hints(); |
| 5594 hints = BooleanBit::set(hints, kStrictModeFunction, strict_mode == STRICT); | 5594 hints = BooleanBit::set(hints, kStrictModeFunction, strict_mode == STRICT); |
| 5595 set_compiler_hints(hints); | 5595 set_compiler_hints(hints); |
| 5596 } | 5596 } |
| 5597 | 5597 |
| 5598 | 5598 |
| 5599 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) | 5599 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) |
| 5600 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin, | 5600 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin, |
| 5601 kInlineBuiltin) | 5601 kInlineBuiltin) |
| 5602 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, | 5602 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5623 if (src_str->IsOneByteRepresentation()) { | 5623 if (src_str->IsOneByteRepresentation()) { |
| 5624 return ExternalAsciiString::cast(src)->resource() != NULL; | 5624 return ExternalAsciiString::cast(src)->resource() != NULL; |
| 5625 } else if (src_str->IsTwoByteRepresentation()) { | 5625 } else if (src_str->IsTwoByteRepresentation()) { |
| 5626 return ExternalTwoByteString::cast(src)->resource() != NULL; | 5626 return ExternalTwoByteString::cast(src)->resource() != NULL; |
| 5627 } | 5627 } |
| 5628 return true; | 5628 return true; |
| 5629 } | 5629 } |
| 5630 | 5630 |
| 5631 | 5631 |
| 5632 void SharedFunctionInfo::DontAdaptArguments() { | 5632 void SharedFunctionInfo::DontAdaptArguments() { |
| 5633 ASSERT(code()->kind() == Code::BUILTIN); | 5633 DCHECK(code()->kind() == Code::BUILTIN); |
| 5634 set_formal_parameter_count(kDontAdaptArgumentsSentinel); | 5634 set_formal_parameter_count(kDontAdaptArgumentsSentinel); |
| 5635 } | 5635 } |
| 5636 | 5636 |
| 5637 | 5637 |
| 5638 int SharedFunctionInfo::start_position() const { | 5638 int SharedFunctionInfo::start_position() const { |
| 5639 return start_position_and_type() >> kStartPositionShift; | 5639 return start_position_and_type() >> kStartPositionShift; |
| 5640 } | 5640 } |
| 5641 | 5641 |
| 5642 | 5642 |
| 5643 void SharedFunctionInfo::set_start_position(int start_position) { | 5643 void SharedFunctionInfo::set_start_position(int start_position) { |
| 5644 set_start_position_and_type((start_position << kStartPositionShift) | 5644 set_start_position_and_type((start_position << kStartPositionShift) |
| 5645 | (start_position_and_type() & ~kStartPositionMask)); | 5645 | (start_position_and_type() & ~kStartPositionMask)); |
| 5646 } | 5646 } |
| 5647 | 5647 |
| 5648 | 5648 |
| 5649 Code* SharedFunctionInfo::code() const { | 5649 Code* SharedFunctionInfo::code() const { |
| 5650 return Code::cast(READ_FIELD(this, kCodeOffset)); | 5650 return Code::cast(READ_FIELD(this, kCodeOffset)); |
| 5651 } | 5651 } |
| 5652 | 5652 |
| 5653 | 5653 |
| 5654 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { | 5654 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { |
| 5655 ASSERT(value->kind() != Code::OPTIMIZED_FUNCTION); | 5655 DCHECK(value->kind() != Code::OPTIMIZED_FUNCTION); |
| 5656 WRITE_FIELD(this, kCodeOffset, value); | 5656 WRITE_FIELD(this, kCodeOffset, value); |
| 5657 CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode); | 5657 CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode); |
| 5658 } | 5658 } |
| 5659 | 5659 |
| 5660 | 5660 |
| 5661 void SharedFunctionInfo::ReplaceCode(Code* value) { | 5661 void SharedFunctionInfo::ReplaceCode(Code* value) { |
| 5662 // If the GC metadata field is already used then the function was | 5662 // If the GC metadata field is already used then the function was |
| 5663 // enqueued as a code flushing candidate and we remove it now. | 5663 // enqueued as a code flushing candidate and we remove it now. |
| 5664 if (code()->gc_metadata() != NULL) { | 5664 if (code()->gc_metadata() != NULL) { |
| 5665 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); | 5665 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); |
| 5666 flusher->EvictCandidate(this); | 5666 flusher->EvictCandidate(this); |
| 5667 } | 5667 } |
| 5668 | 5668 |
| 5669 ASSERT(code()->gc_metadata() == NULL && value->gc_metadata() == NULL); | 5669 DCHECK(code()->gc_metadata() == NULL && value->gc_metadata() == NULL); |
| 5670 | 5670 |
| 5671 set_code(value); | 5671 set_code(value); |
| 5672 } | 5672 } |
| 5673 | 5673 |
| 5674 | 5674 |
| 5675 ScopeInfo* SharedFunctionInfo::scope_info() const { | 5675 ScopeInfo* SharedFunctionInfo::scope_info() const { |
| 5676 return reinterpret_cast<ScopeInfo*>(READ_FIELD(this, kScopeInfoOffset)); | 5676 return reinterpret_cast<ScopeInfo*>(READ_FIELD(this, kScopeInfoOffset)); |
| 5677 } | 5677 } |
| 5678 | 5678 |
| 5679 | 5679 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5693 GetIsolate()->builtins()->builtin(Builtins::kCompileUnoptimized); | 5693 GetIsolate()->builtins()->builtin(Builtins::kCompileUnoptimized); |
| 5694 } | 5694 } |
| 5695 | 5695 |
| 5696 | 5696 |
| 5697 bool SharedFunctionInfo::IsApiFunction() { | 5697 bool SharedFunctionInfo::IsApiFunction() { |
| 5698 return function_data()->IsFunctionTemplateInfo(); | 5698 return function_data()->IsFunctionTemplateInfo(); |
| 5699 } | 5699 } |
| 5700 | 5700 |
| 5701 | 5701 |
| 5702 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { | 5702 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { |
| 5703 ASSERT(IsApiFunction()); | 5703 DCHECK(IsApiFunction()); |
| 5704 return FunctionTemplateInfo::cast(function_data()); | 5704 return FunctionTemplateInfo::cast(function_data()); |
| 5705 } | 5705 } |
| 5706 | 5706 |
| 5707 | 5707 |
| 5708 bool SharedFunctionInfo::HasBuiltinFunctionId() { | 5708 bool SharedFunctionInfo::HasBuiltinFunctionId() { |
| 5709 return function_data()->IsSmi(); | 5709 return function_data()->IsSmi(); |
| 5710 } | 5710 } |
| 5711 | 5711 |
| 5712 | 5712 |
| 5713 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { | 5713 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { |
| 5714 ASSERT(HasBuiltinFunctionId()); | 5714 DCHECK(HasBuiltinFunctionId()); |
| 5715 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value()); | 5715 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value()); |
| 5716 } | 5716 } |
| 5717 | 5717 |
| 5718 | 5718 |
| 5719 int SharedFunctionInfo::ic_age() { | 5719 int SharedFunctionInfo::ic_age() { |
| 5720 return ICAgeBits::decode(counters()); | 5720 return ICAgeBits::decode(counters()); |
| 5721 } | 5721 } |
| 5722 | 5722 |
| 5723 | 5723 |
| 5724 void SharedFunctionInfo::set_ic_age(int ic_age) { | 5724 void SharedFunctionInfo::set_ic_age(int ic_age) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5794 | 5794 |
| 5795 bool JSFunction::IsBuiltin() { | 5795 bool JSFunction::IsBuiltin() { |
| 5796 return context()->global_object()->IsJSBuiltinsObject(); | 5796 return context()->global_object()->IsJSBuiltinsObject(); |
| 5797 } | 5797 } |
| 5798 | 5798 |
| 5799 | 5799 |
| 5800 bool JSFunction::IsFromNativeScript() { | 5800 bool JSFunction::IsFromNativeScript() { |
| 5801 Object* script = shared()->script(); | 5801 Object* script = shared()->script(); |
| 5802 bool native = script->IsScript() && | 5802 bool native = script->IsScript() && |
| 5803 Script::cast(script)->type()->value() == Script::TYPE_NATIVE; | 5803 Script::cast(script)->type()->value() == Script::TYPE_NATIVE; |
| 5804 ASSERT(!IsBuiltin() || native); // All builtins are also native. | 5804 DCHECK(!IsBuiltin() || native); // All builtins are also native. |
| 5805 return native; | 5805 return native; |
| 5806 } | 5806 } |
| 5807 | 5807 |
| 5808 | 5808 |
| 5809 bool JSFunction::IsFromExtensionScript() { | 5809 bool JSFunction::IsFromExtensionScript() { |
| 5810 Object* script = shared()->script(); | 5810 Object* script = shared()->script(); |
| 5811 return script->IsScript() && | 5811 return script->IsScript() && |
| 5812 Script::cast(script)->type()->value() == Script::TYPE_EXTENSION; | 5812 Script::cast(script)->type()->value() == Script::TYPE_EXTENSION; |
| 5813 } | 5813 } |
| 5814 | 5814 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5853 } | 5853 } |
| 5854 | 5854 |
| 5855 | 5855 |
| 5856 Code* JSFunction::code() { | 5856 Code* JSFunction::code() { |
| 5857 return Code::cast( | 5857 return Code::cast( |
| 5858 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); | 5858 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); |
| 5859 } | 5859 } |
| 5860 | 5860 |
| 5861 | 5861 |
| 5862 void JSFunction::set_code(Code* value) { | 5862 void JSFunction::set_code(Code* value) { |
| 5863 ASSERT(!GetHeap()->InNewSpace(value)); | 5863 DCHECK(!GetHeap()->InNewSpace(value)); |
| 5864 Address entry = value->entry(); | 5864 Address entry = value->entry(); |
| 5865 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 5865 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
| 5866 GetHeap()->incremental_marking()->RecordWriteOfCodeEntry( | 5866 GetHeap()->incremental_marking()->RecordWriteOfCodeEntry( |
| 5867 this, | 5867 this, |
| 5868 HeapObject::RawField(this, kCodeEntryOffset), | 5868 HeapObject::RawField(this, kCodeEntryOffset), |
| 5869 value); | 5869 value); |
| 5870 } | 5870 } |
| 5871 | 5871 |
| 5872 | 5872 |
| 5873 void JSFunction::set_code_no_write_barrier(Code* value) { | 5873 void JSFunction::set_code_no_write_barrier(Code* value) { |
| 5874 ASSERT(!GetHeap()->InNewSpace(value)); | 5874 DCHECK(!GetHeap()->InNewSpace(value)); |
| 5875 Address entry = value->entry(); | 5875 Address entry = value->entry(); |
| 5876 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 5876 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
| 5877 } | 5877 } |
| 5878 | 5878 |
| 5879 | 5879 |
| 5880 void JSFunction::ReplaceCode(Code* code) { | 5880 void JSFunction::ReplaceCode(Code* code) { |
| 5881 bool was_optimized = IsOptimized(); | 5881 bool was_optimized = IsOptimized(); |
| 5882 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 5882 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
| 5883 | 5883 |
| 5884 if (was_optimized && is_optimized) { | 5884 if (was_optimized && is_optimized) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5904 return Context::cast(READ_FIELD(this, kContextOffset)); | 5904 return Context::cast(READ_FIELD(this, kContextOffset)); |
| 5905 } | 5905 } |
| 5906 | 5906 |
| 5907 | 5907 |
| 5908 JSObject* JSFunction::global_proxy() { | 5908 JSObject* JSFunction::global_proxy() { |
| 5909 return context()->global_proxy(); | 5909 return context()->global_proxy(); |
| 5910 } | 5910 } |
| 5911 | 5911 |
| 5912 | 5912 |
| 5913 void JSFunction::set_context(Object* value) { | 5913 void JSFunction::set_context(Object* value) { |
| 5914 ASSERT(value->IsUndefined() || value->IsContext()); | 5914 DCHECK(value->IsUndefined() || value->IsContext()); |
| 5915 WRITE_FIELD(this, kContextOffset, value); | 5915 WRITE_FIELD(this, kContextOffset, value); |
| 5916 WRITE_BARRIER(GetHeap(), this, kContextOffset, value); | 5916 WRITE_BARRIER(GetHeap(), this, kContextOffset, value); |
| 5917 } | 5917 } |
| 5918 | 5918 |
| 5919 ACCESSORS(JSFunction, prototype_or_initial_map, Object, | 5919 ACCESSORS(JSFunction, prototype_or_initial_map, Object, |
| 5920 kPrototypeOrInitialMapOffset) | 5920 kPrototypeOrInitialMapOffset) |
| 5921 | 5921 |
| 5922 | 5922 |
| 5923 Map* JSFunction::initial_map() { | 5923 Map* JSFunction::initial_map() { |
| 5924 return Map::cast(prototype_or_initial_map()); | 5924 return Map::cast(prototype_or_initial_map()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5939 return has_initial_map() || !prototype_or_initial_map()->IsTheHole(); | 5939 return has_initial_map() || !prototype_or_initial_map()->IsTheHole(); |
| 5940 } | 5940 } |
| 5941 | 5941 |
| 5942 | 5942 |
| 5943 bool JSFunction::has_prototype() { | 5943 bool JSFunction::has_prototype() { |
| 5944 return map()->has_non_instance_prototype() || has_instance_prototype(); | 5944 return map()->has_non_instance_prototype() || has_instance_prototype(); |
| 5945 } | 5945 } |
| 5946 | 5946 |
| 5947 | 5947 |
| 5948 Object* JSFunction::instance_prototype() { | 5948 Object* JSFunction::instance_prototype() { |
| 5949 ASSERT(has_instance_prototype()); | 5949 DCHECK(has_instance_prototype()); |
| 5950 if (has_initial_map()) return initial_map()->prototype(); | 5950 if (has_initial_map()) return initial_map()->prototype(); |
| 5951 // When there is no initial map and the prototype is a JSObject, the | 5951 // When there is no initial map and the prototype is a JSObject, the |
| 5952 // initial map field is used for the prototype field. | 5952 // initial map field is used for the prototype field. |
| 5953 return prototype_or_initial_map(); | 5953 return prototype_or_initial_map(); |
| 5954 } | 5954 } |
| 5955 | 5955 |
| 5956 | 5956 |
| 5957 Object* JSFunction::prototype() { | 5957 Object* JSFunction::prototype() { |
| 5958 ASSERT(has_prototype()); | 5958 DCHECK(has_prototype()); |
| 5959 // If the function's prototype property has been set to a non-JSObject | 5959 // If the function's prototype property has been set to a non-JSObject |
| 5960 // value, that value is stored in the constructor field of the map. | 5960 // value, that value is stored in the constructor field of the map. |
| 5961 if (map()->has_non_instance_prototype()) return map()->constructor(); | 5961 if (map()->has_non_instance_prototype()) return map()->constructor(); |
| 5962 return instance_prototype(); | 5962 return instance_prototype(); |
| 5963 } | 5963 } |
| 5964 | 5964 |
| 5965 | 5965 |
| 5966 bool JSFunction::should_have_prototype() { | 5966 bool JSFunction::should_have_prototype() { |
| 5967 return map()->function_with_prototype(); | 5967 return map()->function_with_prototype(); |
| 5968 } | 5968 } |
| 5969 | 5969 |
| 5970 | 5970 |
| 5971 bool JSFunction::is_compiled() { | 5971 bool JSFunction::is_compiled() { |
| 5972 return code() != | 5972 return code() != |
| 5973 GetIsolate()->builtins()->builtin(Builtins::kCompileUnoptimized); | 5973 GetIsolate()->builtins()->builtin(Builtins::kCompileUnoptimized); |
| 5974 } | 5974 } |
| 5975 | 5975 |
| 5976 | 5976 |
| 5977 FixedArray* JSFunction::literals() { | 5977 FixedArray* JSFunction::literals() { |
| 5978 ASSERT(!shared()->bound()); | 5978 DCHECK(!shared()->bound()); |
| 5979 return literals_or_bindings(); | 5979 return literals_or_bindings(); |
| 5980 } | 5980 } |
| 5981 | 5981 |
| 5982 | 5982 |
| 5983 void JSFunction::set_literals(FixedArray* literals) { | 5983 void JSFunction::set_literals(FixedArray* literals) { |
| 5984 ASSERT(!shared()->bound()); | 5984 DCHECK(!shared()->bound()); |
| 5985 set_literals_or_bindings(literals); | 5985 set_literals_or_bindings(literals); |
| 5986 } | 5986 } |
| 5987 | 5987 |
| 5988 | 5988 |
| 5989 FixedArray* JSFunction::function_bindings() { | 5989 FixedArray* JSFunction::function_bindings() { |
| 5990 ASSERT(shared()->bound()); | 5990 DCHECK(shared()->bound()); |
| 5991 return literals_or_bindings(); | 5991 return literals_or_bindings(); |
| 5992 } | 5992 } |
| 5993 | 5993 |
| 5994 | 5994 |
| 5995 void JSFunction::set_function_bindings(FixedArray* bindings) { | 5995 void JSFunction::set_function_bindings(FixedArray* bindings) { |
| 5996 ASSERT(shared()->bound()); | 5996 DCHECK(shared()->bound()); |
| 5997 // Bound function literal may be initialized to the empty fixed array | 5997 // Bound function literal may be initialized to the empty fixed array |
| 5998 // before the bindings are set. | 5998 // before the bindings are set. |
| 5999 ASSERT(bindings == GetHeap()->empty_fixed_array() || | 5999 DCHECK(bindings == GetHeap()->empty_fixed_array() || |
| 6000 bindings->map() == GetHeap()->fixed_cow_array_map()); | 6000 bindings->map() == GetHeap()->fixed_cow_array_map()); |
| 6001 set_literals_or_bindings(bindings); | 6001 set_literals_or_bindings(bindings); |
| 6002 } | 6002 } |
| 6003 | 6003 |
| 6004 | 6004 |
| 6005 int JSFunction::NumberOfLiterals() { | 6005 int JSFunction::NumberOfLiterals() { |
| 6006 ASSERT(!shared()->bound()); | 6006 DCHECK(!shared()->bound()); |
| 6007 return literals()->length(); | 6007 return literals()->length(); |
| 6008 } | 6008 } |
| 6009 | 6009 |
| 6010 | 6010 |
| 6011 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { | 6011 Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { |
| 6012 ASSERT(id < kJSBuiltinsCount); // id is unsigned. | 6012 DCHECK(id < kJSBuiltinsCount); // id is unsigned. |
| 6013 return READ_FIELD(this, OffsetOfFunctionWithId(id)); | 6013 return READ_FIELD(this, OffsetOfFunctionWithId(id)); |
| 6014 } | 6014 } |
| 6015 | 6015 |
| 6016 | 6016 |
| 6017 void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id, | 6017 void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id, |
| 6018 Object* value) { | 6018 Object* value) { |
| 6019 ASSERT(id < kJSBuiltinsCount); // id is unsigned. | 6019 DCHECK(id < kJSBuiltinsCount); // id is unsigned. |
| 6020 WRITE_FIELD(this, OffsetOfFunctionWithId(id), value); | 6020 WRITE_FIELD(this, OffsetOfFunctionWithId(id), value); |
| 6021 WRITE_BARRIER(GetHeap(), this, OffsetOfFunctionWithId(id), value); | 6021 WRITE_BARRIER(GetHeap(), this, OffsetOfFunctionWithId(id), value); |
| 6022 } | 6022 } |
| 6023 | 6023 |
| 6024 | 6024 |
| 6025 Code* JSBuiltinsObject::javascript_builtin_code(Builtins::JavaScript id) { | 6025 Code* JSBuiltinsObject::javascript_builtin_code(Builtins::JavaScript id) { |
| 6026 ASSERT(id < kJSBuiltinsCount); // id is unsigned. | 6026 DCHECK(id < kJSBuiltinsCount); // id is unsigned. |
| 6027 return Code::cast(READ_FIELD(this, OffsetOfCodeWithId(id))); | 6027 return Code::cast(READ_FIELD(this, OffsetOfCodeWithId(id))); |
| 6028 } | 6028 } |
| 6029 | 6029 |
| 6030 | 6030 |
| 6031 void JSBuiltinsObject::set_javascript_builtin_code(Builtins::JavaScript id, | 6031 void JSBuiltinsObject::set_javascript_builtin_code(Builtins::JavaScript id, |
| 6032 Code* value) { | 6032 Code* value) { |
| 6033 ASSERT(id < kJSBuiltinsCount); // id is unsigned. | 6033 DCHECK(id < kJSBuiltinsCount); // id is unsigned. |
| 6034 WRITE_FIELD(this, OffsetOfCodeWithId(id), value); | 6034 WRITE_FIELD(this, OffsetOfCodeWithId(id), value); |
| 6035 ASSERT(!GetHeap()->InNewSpace(value)); | 6035 DCHECK(!GetHeap()->InNewSpace(value)); |
| 6036 } | 6036 } |
| 6037 | 6037 |
| 6038 | 6038 |
| 6039 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) | 6039 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) |
| 6040 ACCESSORS(JSProxy, hash, Object, kHashOffset) | 6040 ACCESSORS(JSProxy, hash, Object, kHashOffset) |
| 6041 ACCESSORS(JSFunctionProxy, call_trap, Object, kCallTrapOffset) | 6041 ACCESSORS(JSFunctionProxy, call_trap, Object, kCallTrapOffset) |
| 6042 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset) | 6042 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset) |
| 6043 | 6043 |
| 6044 | 6044 |
| 6045 void JSProxy::InitializeBody(int object_size, Object* value) { | 6045 void JSProxy::InitializeBody(int object_size, Object* value) { |
| 6046 ASSERT(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); | 6046 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); |
| 6047 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 6047 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
| 6048 WRITE_FIELD(this, offset, value); | 6048 WRITE_FIELD(this, offset, value); |
| 6049 } | 6049 } |
| 6050 } | 6050 } |
| 6051 | 6051 |
| 6052 | 6052 |
| 6053 ACCESSORS(JSCollection, table, Object, kTableOffset) | 6053 ACCESSORS(JSCollection, table, Object, kTableOffset) |
| 6054 | 6054 |
| 6055 | 6055 |
| 6056 #define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset) \ | 6056 #define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset) \ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 6087 | 6087 |
| 6088 | 6088 |
| 6089 ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset) | 6089 ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset) |
| 6090 ACCESSORS(JSGeneratorObject, context, Context, kContextOffset) | 6090 ACCESSORS(JSGeneratorObject, context, Context, kContextOffset) |
| 6091 ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset) | 6091 ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset) |
| 6092 SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset) | 6092 SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset) |
| 6093 ACCESSORS(JSGeneratorObject, operand_stack, FixedArray, kOperandStackOffset) | 6093 ACCESSORS(JSGeneratorObject, operand_stack, FixedArray, kOperandStackOffset) |
| 6094 SMI_ACCESSORS(JSGeneratorObject, stack_handler_index, kStackHandlerIndexOffset) | 6094 SMI_ACCESSORS(JSGeneratorObject, stack_handler_index, kStackHandlerIndexOffset) |
| 6095 | 6095 |
| 6096 bool JSGeneratorObject::is_suspended() { | 6096 bool JSGeneratorObject::is_suspended() { |
| 6097 ASSERT_LT(kGeneratorExecuting, kGeneratorClosed); | 6097 DCHECK_LT(kGeneratorExecuting, kGeneratorClosed); |
| 6098 ASSERT_EQ(kGeneratorClosed, 0); | 6098 DCHECK_EQ(kGeneratorClosed, 0); |
| 6099 return continuation() > 0; | 6099 return continuation() > 0; |
| 6100 } | 6100 } |
| 6101 | 6101 |
| 6102 bool JSGeneratorObject::is_closed() { | 6102 bool JSGeneratorObject::is_closed() { |
| 6103 return continuation() == kGeneratorClosed; | 6103 return continuation() == kGeneratorClosed; |
| 6104 } | 6104 } |
| 6105 | 6105 |
| 6106 bool JSGeneratorObject::is_executing() { | 6106 bool JSGeneratorObject::is_executing() { |
| 6107 return continuation() == kGeneratorExecuting; | 6107 return continuation() == kGeneratorExecuting; |
| 6108 } | 6108 } |
| 6109 | 6109 |
| 6110 ACCESSORS(JSModule, context, Object, kContextOffset) | 6110 ACCESSORS(JSModule, context, Object, kContextOffset) |
| 6111 ACCESSORS(JSModule, scope_info, ScopeInfo, kScopeInfoOffset) | 6111 ACCESSORS(JSModule, scope_info, ScopeInfo, kScopeInfoOffset) |
| 6112 | 6112 |
| 6113 | 6113 |
| 6114 ACCESSORS(JSValue, value, Object, kValueOffset) | 6114 ACCESSORS(JSValue, value, Object, kValueOffset) |
| 6115 | 6115 |
| 6116 | 6116 |
| 6117 HeapNumber* HeapNumber::cast(Object* object) { | 6117 HeapNumber* HeapNumber::cast(Object* object) { |
| 6118 SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); | 6118 SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
| 6119 return reinterpret_cast<HeapNumber*>(object); | 6119 return reinterpret_cast<HeapNumber*>(object); |
| 6120 } | 6120 } |
| 6121 | 6121 |
| 6122 | 6122 |
| 6123 const HeapNumber* HeapNumber::cast(const Object* object) { | 6123 const HeapNumber* HeapNumber::cast(const Object* object) { |
| 6124 SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); | 6124 SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
| 6125 return reinterpret_cast<const HeapNumber*>(object); | 6125 return reinterpret_cast<const HeapNumber*>(object); |
| 6126 } | 6126 } |
| 6127 | 6127 |
| 6128 | 6128 |
| 6129 ACCESSORS(JSDate, value, Object, kValueOffset) | 6129 ACCESSORS(JSDate, value, Object, kValueOffset) |
| 6130 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) | 6130 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) |
| 6131 ACCESSORS(JSDate, year, Object, kYearOffset) | 6131 ACCESSORS(JSDate, year, Object, kYearOffset) |
| 6132 ACCESSORS(JSDate, month, Object, kMonthOffset) | 6132 ACCESSORS(JSDate, month, Object, kMonthOffset) |
| 6133 ACCESSORS(JSDate, day, Object, kDayOffset) | 6133 ACCESSORS(JSDate, day, Object, kDayOffset) |
| 6134 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) | 6134 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6160 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 6160 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); |
| 6161 WRITE_FIELD(this, kConstantPoolOffset, NULL); | 6161 WRITE_FIELD(this, kConstantPoolOffset, NULL); |
| 6162 // Do not wipe out major/minor keys on a code stub or IC | 6162 // Do not wipe out major/minor keys on a code stub or IC |
| 6163 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 6163 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { |
| 6164 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 6164 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); |
| 6165 } | 6165 } |
| 6166 } | 6166 } |
| 6167 | 6167 |
| 6168 | 6168 |
| 6169 Object* Code::type_feedback_info() { | 6169 Object* Code::type_feedback_info() { |
| 6170 ASSERT(kind() == FUNCTION); | 6170 DCHECK(kind() == FUNCTION); |
| 6171 return raw_type_feedback_info(); | 6171 return raw_type_feedback_info(); |
| 6172 } | 6172 } |
| 6173 | 6173 |
| 6174 | 6174 |
| 6175 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { | 6175 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { |
| 6176 ASSERT(kind() == FUNCTION); | 6176 DCHECK(kind() == FUNCTION); |
| 6177 set_raw_type_feedback_info(value, mode); | 6177 set_raw_type_feedback_info(value, mode); |
| 6178 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, | 6178 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, |
| 6179 value, mode); | 6179 value, mode); |
| 6180 } | 6180 } |
| 6181 | 6181 |
| 6182 | 6182 |
| 6183 uint32_t Code::stub_key() { | 6183 uint32_t Code::stub_key() { |
| 6184 ASSERT(IsCodeStubOrIC()); | 6184 DCHECK(IsCodeStubOrIC()); |
| 6185 Smi* smi_key = Smi::cast(raw_type_feedback_info()); | 6185 Smi* smi_key = Smi::cast(raw_type_feedback_info()); |
| 6186 return static_cast<uint32_t>(smi_key->value()); | 6186 return static_cast<uint32_t>(smi_key->value()); |
| 6187 } | 6187 } |
| 6188 | 6188 |
| 6189 | 6189 |
| 6190 void Code::set_stub_key(uint32_t key) { | 6190 void Code::set_stub_key(uint32_t key) { |
| 6191 ASSERT(IsCodeStubOrIC()); | 6191 DCHECK(IsCodeStubOrIC()); |
| 6192 set_raw_type_feedback_info(Smi::FromInt(key)); | 6192 set_raw_type_feedback_info(Smi::FromInt(key)); |
| 6193 } | 6193 } |
| 6194 | 6194 |
| 6195 | 6195 |
| 6196 ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset) | 6196 ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset) |
| 6197 INT_ACCESSORS(Code, ic_age, kICAgeOffset) | 6197 INT_ACCESSORS(Code, ic_age, kICAgeOffset) |
| 6198 | 6198 |
| 6199 | 6199 |
| 6200 byte* Code::instruction_start() { | 6200 byte* Code::instruction_start() { |
| 6201 return FIELD_ADDR(this, kHeaderSize); | 6201 return FIELD_ADDR(this, kHeaderSize); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6304 case IRREGEXP: | 6304 case IRREGEXP: |
| 6305 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); | 6305 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); |
| 6306 default: | 6306 default: |
| 6307 UNREACHABLE(); | 6307 UNREACHABLE(); |
| 6308 return -1; | 6308 return -1; |
| 6309 } | 6309 } |
| 6310 } | 6310 } |
| 6311 | 6311 |
| 6312 | 6312 |
| 6313 JSRegExp::Flags JSRegExp::GetFlags() { | 6313 JSRegExp::Flags JSRegExp::GetFlags() { |
| 6314 ASSERT(this->data()->IsFixedArray()); | 6314 DCHECK(this->data()->IsFixedArray()); |
| 6315 Object* data = this->data(); | 6315 Object* data = this->data(); |
| 6316 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex)); | 6316 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex)); |
| 6317 return Flags(smi->value()); | 6317 return Flags(smi->value()); |
| 6318 } | 6318 } |
| 6319 | 6319 |
| 6320 | 6320 |
| 6321 String* JSRegExp::Pattern() { | 6321 String* JSRegExp::Pattern() { |
| 6322 ASSERT(this->data()->IsFixedArray()); | 6322 DCHECK(this->data()->IsFixedArray()); |
| 6323 Object* data = this->data(); | 6323 Object* data = this->data(); |
| 6324 String* pattern= String::cast(FixedArray::cast(data)->get(kSourceIndex)); | 6324 String* pattern= String::cast(FixedArray::cast(data)->get(kSourceIndex)); |
| 6325 return pattern; | 6325 return pattern; |
| 6326 } | 6326 } |
| 6327 | 6327 |
| 6328 | 6328 |
| 6329 Object* JSRegExp::DataAt(int index) { | 6329 Object* JSRegExp::DataAt(int index) { |
| 6330 ASSERT(TypeTag() != NOT_COMPILED); | 6330 DCHECK(TypeTag() != NOT_COMPILED); |
| 6331 return FixedArray::cast(data())->get(index); | 6331 return FixedArray::cast(data())->get(index); |
| 6332 } | 6332 } |
| 6333 | 6333 |
| 6334 | 6334 |
| 6335 void JSRegExp::SetDataAt(int index, Object* value) { | 6335 void JSRegExp::SetDataAt(int index, Object* value) { |
| 6336 ASSERT(TypeTag() != NOT_COMPILED); | 6336 DCHECK(TypeTag() != NOT_COMPILED); |
| 6337 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | 6337 DCHECK(index >= kDataIndex); // Only implementation data can be set this way. |
| 6338 FixedArray::cast(data())->set(index, value); | 6338 FixedArray::cast(data())->set(index, value); |
| 6339 } | 6339 } |
| 6340 | 6340 |
| 6341 | 6341 |
| 6342 ElementsKind JSObject::GetElementsKind() { | 6342 ElementsKind JSObject::GetElementsKind() { |
| 6343 ElementsKind kind = map()->elements_kind(); | 6343 ElementsKind kind = map()->elements_kind(); |
| 6344 #if DEBUG | 6344 #if DEBUG |
| 6345 FixedArrayBase* fixed_array = | 6345 FixedArrayBase* fixed_array = |
| 6346 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); | 6346 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); |
| 6347 | 6347 |
| 6348 // If a GC was caused while constructing this object, the elements | 6348 // If a GC was caused while constructing this object, the elements |
| 6349 // pointer may point to a one pointer filler map. | 6349 // pointer may point to a one pointer filler map. |
| 6350 if (ElementsAreSafeToExamine()) { | 6350 if (ElementsAreSafeToExamine()) { |
| 6351 Map* map = fixed_array->map(); | 6351 Map* map = fixed_array->map(); |
| 6352 ASSERT((IsFastSmiOrObjectElementsKind(kind) && | 6352 DCHECK((IsFastSmiOrObjectElementsKind(kind) && |
| 6353 (map == GetHeap()->fixed_array_map() || | 6353 (map == GetHeap()->fixed_array_map() || |
| 6354 map == GetHeap()->fixed_cow_array_map())) || | 6354 map == GetHeap()->fixed_cow_array_map())) || |
| 6355 (IsFastDoubleElementsKind(kind) && | 6355 (IsFastDoubleElementsKind(kind) && |
| 6356 (fixed_array->IsFixedDoubleArray() || | 6356 (fixed_array->IsFixedDoubleArray() || |
| 6357 fixed_array == GetHeap()->empty_fixed_array())) || | 6357 fixed_array == GetHeap()->empty_fixed_array())) || |
| 6358 (kind == DICTIONARY_ELEMENTS && | 6358 (kind == DICTIONARY_ELEMENTS && |
| 6359 fixed_array->IsFixedArray() && | 6359 fixed_array->IsFixedArray() && |
| 6360 fixed_array->IsDictionary()) || | 6360 fixed_array->IsDictionary()) || |
| 6361 (kind > DICTIONARY_ELEMENTS)); | 6361 (kind > DICTIONARY_ELEMENTS)); |
| 6362 ASSERT((kind != SLOPPY_ARGUMENTS_ELEMENTS) || | 6362 DCHECK((kind != SLOPPY_ARGUMENTS_ELEMENTS) || |
| 6363 (elements()->IsFixedArray() && elements()->length() >= 2)); | 6363 (elements()->IsFixedArray() && elements()->length() >= 2)); |
| 6364 } | 6364 } |
| 6365 #endif | 6365 #endif |
| 6366 return kind; | 6366 return kind; |
| 6367 } | 6367 } |
| 6368 | 6368 |
| 6369 | 6369 |
| 6370 ElementsAccessor* JSObject::GetElementsAccessor() { | 6370 ElementsAccessor* JSObject::GetElementsAccessor() { |
| 6371 return ElementsAccessor::ForKind(GetElementsKind()); | 6371 return ElementsAccessor::ForKind(GetElementsKind()); |
| 6372 } | 6372 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6407 } | 6407 } |
| 6408 | 6408 |
| 6409 | 6409 |
| 6410 bool JSObject::HasSloppyArgumentsElements() { | 6410 bool JSObject::HasSloppyArgumentsElements() { |
| 6411 return GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS; | 6411 return GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS; |
| 6412 } | 6412 } |
| 6413 | 6413 |
| 6414 | 6414 |
| 6415 bool JSObject::HasExternalArrayElements() { | 6415 bool JSObject::HasExternalArrayElements() { |
| 6416 HeapObject* array = elements(); | 6416 HeapObject* array = elements(); |
| 6417 ASSERT(array != NULL); | 6417 DCHECK(array != NULL); |
| 6418 return array->IsExternalArray(); | 6418 return array->IsExternalArray(); |
| 6419 } | 6419 } |
| 6420 | 6420 |
| 6421 | 6421 |
| 6422 #define EXTERNAL_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ | 6422 #define EXTERNAL_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ |
| 6423 bool JSObject::HasExternal##Type##Elements() { \ | 6423 bool JSObject::HasExternal##Type##Elements() { \ |
| 6424 HeapObject* array = elements(); \ | 6424 HeapObject* array = elements(); \ |
| 6425 ASSERT(array != NULL); \ | 6425 DCHECK(array != NULL); \ |
| 6426 if (!array->IsHeapObject()) \ | 6426 if (!array->IsHeapObject()) \ |
| 6427 return false; \ | 6427 return false; \ |
| 6428 return array->map()->instance_type() == EXTERNAL_##TYPE##_ARRAY_TYPE; \ | 6428 return array->map()->instance_type() == EXTERNAL_##TYPE##_ARRAY_TYPE; \ |
| 6429 } | 6429 } |
| 6430 | 6430 |
| 6431 TYPED_ARRAYS(EXTERNAL_ELEMENTS_CHECK) | 6431 TYPED_ARRAYS(EXTERNAL_ELEMENTS_CHECK) |
| 6432 | 6432 |
| 6433 #undef EXTERNAL_ELEMENTS_CHECK | 6433 #undef EXTERNAL_ELEMENTS_CHECK |
| 6434 | 6434 |
| 6435 | 6435 |
| 6436 bool JSObject::HasFixedTypedArrayElements() { | 6436 bool JSObject::HasFixedTypedArrayElements() { |
| 6437 HeapObject* array = elements(); | 6437 HeapObject* array = elements(); |
| 6438 ASSERT(array != NULL); | 6438 DCHECK(array != NULL); |
| 6439 return array->IsFixedTypedArrayBase(); | 6439 return array->IsFixedTypedArrayBase(); |
| 6440 } | 6440 } |
| 6441 | 6441 |
| 6442 | 6442 |
| 6443 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ | 6443 #define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ |
| 6444 bool JSObject::HasFixed##Type##Elements() { \ | 6444 bool JSObject::HasFixed##Type##Elements() { \ |
| 6445 HeapObject* array = elements(); \ | 6445 HeapObject* array = elements(); \ |
| 6446 ASSERT(array != NULL); \ | 6446 DCHECK(array != NULL); \ |
| 6447 if (!array->IsHeapObject()) \ | 6447 if (!array->IsHeapObject()) \ |
| 6448 return false; \ | 6448 return false; \ |
| 6449 return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \ | 6449 return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \ |
| 6450 } | 6450 } |
| 6451 | 6451 |
| 6452 TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK) | 6452 TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK) |
| 6453 | 6453 |
| 6454 #undef FIXED_TYPED_ELEMENTS_CHECK | 6454 #undef FIXED_TYPED_ELEMENTS_CHECK |
| 6455 | 6455 |
| 6456 | 6456 |
| 6457 bool JSObject::HasNamedInterceptor() { | 6457 bool JSObject::HasNamedInterceptor() { |
| 6458 return map()->has_named_interceptor(); | 6458 return map()->has_named_interceptor(); |
| 6459 } | 6459 } |
| 6460 | 6460 |
| 6461 | 6461 |
| 6462 bool JSObject::HasIndexedInterceptor() { | 6462 bool JSObject::HasIndexedInterceptor() { |
| 6463 return map()->has_indexed_interceptor(); | 6463 return map()->has_indexed_interceptor(); |
| 6464 } | 6464 } |
| 6465 | 6465 |
| 6466 | 6466 |
| 6467 NameDictionary* JSObject::property_dictionary() { | 6467 NameDictionary* JSObject::property_dictionary() { |
| 6468 ASSERT(!HasFastProperties()); | 6468 DCHECK(!HasFastProperties()); |
| 6469 return NameDictionary::cast(properties()); | 6469 return NameDictionary::cast(properties()); |
| 6470 } | 6470 } |
| 6471 | 6471 |
| 6472 | 6472 |
| 6473 SeededNumberDictionary* JSObject::element_dictionary() { | 6473 SeededNumberDictionary* JSObject::element_dictionary() { |
| 6474 ASSERT(HasDictionaryElements()); | 6474 DCHECK(HasDictionaryElements()); |
| 6475 return SeededNumberDictionary::cast(elements()); | 6475 return SeededNumberDictionary::cast(elements()); |
| 6476 } | 6476 } |
| 6477 | 6477 |
| 6478 | 6478 |
| 6479 bool Name::IsHashFieldComputed(uint32_t field) { | 6479 bool Name::IsHashFieldComputed(uint32_t field) { |
| 6480 return (field & kHashNotComputedMask) == 0; | 6480 return (field & kHashNotComputedMask) == 0; |
| 6481 } | 6481 } |
| 6482 | 6482 |
| 6483 | 6483 |
| 6484 bool Name::HasHashCode() { | 6484 bool Name::HasHashCode() { |
| 6485 return IsHashFieldComputed(hash_field()); | 6485 return IsHashFieldComputed(hash_field()); |
| 6486 } | 6486 } |
| 6487 | 6487 |
| 6488 | 6488 |
| 6489 uint32_t Name::Hash() { | 6489 uint32_t Name::Hash() { |
| 6490 // Fast case: has hash code already been computed? | 6490 // Fast case: has hash code already been computed? |
| 6491 uint32_t field = hash_field(); | 6491 uint32_t field = hash_field(); |
| 6492 if (IsHashFieldComputed(field)) return field >> kHashShift; | 6492 if (IsHashFieldComputed(field)) return field >> kHashShift; |
| 6493 // Slow case: compute hash code and set it. Has to be a string. | 6493 // Slow case: compute hash code and set it. Has to be a string. |
| 6494 return String::cast(this)->ComputeAndSetHash(); | 6494 return String::cast(this)->ComputeAndSetHash(); |
| 6495 } | 6495 } |
| 6496 | 6496 |
| 6497 | 6497 |
| 6498 StringHasher::StringHasher(int length, uint32_t seed) | 6498 StringHasher::StringHasher(int length, uint32_t seed) |
| 6499 : length_(length), | 6499 : length_(length), |
| 6500 raw_running_hash_(seed), | 6500 raw_running_hash_(seed), |
| 6501 array_index_(0), | 6501 array_index_(0), |
| 6502 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), | 6502 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), |
| 6503 is_first_char_(true) { | 6503 is_first_char_(true) { |
| 6504 ASSERT(FLAG_randomize_hashes || raw_running_hash_ == 0); | 6504 DCHECK(FLAG_randomize_hashes || raw_running_hash_ == 0); |
| 6505 } | 6505 } |
| 6506 | 6506 |
| 6507 | 6507 |
| 6508 bool StringHasher::has_trivial_hash() { | 6508 bool StringHasher::has_trivial_hash() { |
| 6509 return length_ > String::kMaxHashCalcLength; | 6509 return length_ > String::kMaxHashCalcLength; |
| 6510 } | 6510 } |
| 6511 | 6511 |
| 6512 | 6512 |
| 6513 uint32_t StringHasher::AddCharacterCore(uint32_t running_hash, uint16_t c) { | 6513 uint32_t StringHasher::AddCharacterCore(uint32_t running_hash, uint16_t c) { |
| 6514 running_hash += c; | 6514 running_hash += c; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6530 | 6530 |
| 6531 | 6531 |
| 6532 void StringHasher::AddCharacter(uint16_t c) { | 6532 void StringHasher::AddCharacter(uint16_t c) { |
| 6533 // Use the Jenkins one-at-a-time hash function to update the hash | 6533 // Use the Jenkins one-at-a-time hash function to update the hash |
| 6534 // for the given character. | 6534 // for the given character. |
| 6535 raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); | 6535 raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); |
| 6536 } | 6536 } |
| 6537 | 6537 |
| 6538 | 6538 |
| 6539 bool StringHasher::UpdateIndex(uint16_t c) { | 6539 bool StringHasher::UpdateIndex(uint16_t c) { |
| 6540 ASSERT(is_array_index_); | 6540 DCHECK(is_array_index_); |
| 6541 if (c < '0' || c > '9') { | 6541 if (c < '0' || c > '9') { |
| 6542 is_array_index_ = false; | 6542 is_array_index_ = false; |
| 6543 return false; | 6543 return false; |
| 6544 } | 6544 } |
| 6545 int d = c - '0'; | 6545 int d = c - '0'; |
| 6546 if (is_first_char_) { | 6546 if (is_first_char_) { |
| 6547 is_first_char_ = false; | 6547 is_first_char_ = false; |
| 6548 if (c == '0' && length_ > 1) { | 6548 if (c == '0' && length_ > 1) { |
| 6549 is_array_index_ = false; | 6549 is_array_index_ = false; |
| 6550 return false; | 6550 return false; |
| 6551 } | 6551 } |
| 6552 } | 6552 } |
| 6553 if (array_index_ > 429496729U - ((d + 2) >> 3)) { | 6553 if (array_index_ > 429496729U - ((d + 2) >> 3)) { |
| 6554 is_array_index_ = false; | 6554 is_array_index_ = false; |
| 6555 return false; | 6555 return false; |
| 6556 } | 6556 } |
| 6557 array_index_ = array_index_ * 10 + d; | 6557 array_index_ = array_index_ * 10 + d; |
| 6558 return true; | 6558 return true; |
| 6559 } | 6559 } |
| 6560 | 6560 |
| 6561 | 6561 |
| 6562 template<typename Char> | 6562 template<typename Char> |
| 6563 inline void StringHasher::AddCharacters(const Char* chars, int length) { | 6563 inline void StringHasher::AddCharacters(const Char* chars, int length) { |
| 6564 ASSERT(sizeof(Char) == 1 || sizeof(Char) == 2); | 6564 DCHECK(sizeof(Char) == 1 || sizeof(Char) == 2); |
| 6565 int i = 0; | 6565 int i = 0; |
| 6566 if (is_array_index_) { | 6566 if (is_array_index_) { |
| 6567 for (; i < length; i++) { | 6567 for (; i < length; i++) { |
| 6568 AddCharacter(chars[i]); | 6568 AddCharacter(chars[i]); |
| 6569 if (!UpdateIndex(chars[i])) { | 6569 if (!UpdateIndex(chars[i])) { |
| 6570 i++; | 6570 i++; |
| 6571 break; | 6571 break; |
| 6572 } | 6572 } |
| 6573 } | 6573 } |
| 6574 } | 6574 } |
| 6575 for (; i < length; i++) { | 6575 for (; i < length; i++) { |
| 6576 ASSERT(!is_array_index_); | 6576 DCHECK(!is_array_index_); |
| 6577 AddCharacter(chars[i]); | 6577 AddCharacter(chars[i]); |
| 6578 } | 6578 } |
| 6579 } | 6579 } |
| 6580 | 6580 |
| 6581 | 6581 |
| 6582 template <typename schar> | 6582 template <typename schar> |
| 6583 uint32_t StringHasher::HashSequentialString(const schar* chars, | 6583 uint32_t StringHasher::HashSequentialString(const schar* chars, |
| 6584 int length, | 6584 int length, |
| 6585 uint32_t seed) { | 6585 uint32_t seed) { |
| 6586 StringHasher hasher(length, seed); | 6586 StringHasher hasher(length, seed); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6626 bool String::AsArrayIndex(uint32_t* index) { | 6626 bool String::AsArrayIndex(uint32_t* index) { |
| 6627 uint32_t field = hash_field(); | 6627 uint32_t field = hash_field(); |
| 6628 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { | 6628 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { |
| 6629 return false; | 6629 return false; |
| 6630 } | 6630 } |
| 6631 return SlowAsArrayIndex(index); | 6631 return SlowAsArrayIndex(index); |
| 6632 } | 6632 } |
| 6633 | 6633 |
| 6634 | 6634 |
| 6635 void String::SetForwardedInternalizedString(String* canonical) { | 6635 void String::SetForwardedInternalizedString(String* canonical) { |
| 6636 ASSERT(IsInternalizedString()); | 6636 DCHECK(IsInternalizedString()); |
| 6637 ASSERT(HasHashCode()); | 6637 DCHECK(HasHashCode()); |
| 6638 if (canonical == this) return; // No need to forward. | 6638 if (canonical == this) return; // No need to forward. |
| 6639 ASSERT(SlowEquals(canonical)); | 6639 DCHECK(SlowEquals(canonical)); |
| 6640 ASSERT(canonical->IsInternalizedString()); | 6640 DCHECK(canonical->IsInternalizedString()); |
| 6641 ASSERT(canonical->HasHashCode()); | 6641 DCHECK(canonical->HasHashCode()); |
| 6642 WRITE_FIELD(this, kHashFieldOffset, canonical); | 6642 WRITE_FIELD(this, kHashFieldOffset, canonical); |
| 6643 // Setting the hash field to a tagged value sets the LSB, causing the hash | 6643 // Setting the hash field to a tagged value sets the LSB, causing the hash |
| 6644 // code to be interpreted as uninitialized. We use this fact to recognize | 6644 // code to be interpreted as uninitialized. We use this fact to recognize |
| 6645 // that we have a forwarded string. | 6645 // that we have a forwarded string. |
| 6646 ASSERT(!HasHashCode()); | 6646 DCHECK(!HasHashCode()); |
| 6647 } | 6647 } |
| 6648 | 6648 |
| 6649 | 6649 |
| 6650 String* String::GetForwardedInternalizedString() { | 6650 String* String::GetForwardedInternalizedString() { |
| 6651 ASSERT(IsInternalizedString()); | 6651 DCHECK(IsInternalizedString()); |
| 6652 if (HasHashCode()) return this; | 6652 if (HasHashCode()) return this; |
| 6653 String* canonical = String::cast(READ_FIELD(this, kHashFieldOffset)); | 6653 String* canonical = String::cast(READ_FIELD(this, kHashFieldOffset)); |
| 6654 ASSERT(canonical->IsInternalizedString()); | 6654 DCHECK(canonical->IsInternalizedString()); |
| 6655 ASSERT(SlowEquals(canonical)); | 6655 DCHECK(SlowEquals(canonical)); |
| 6656 ASSERT(canonical->HasHashCode()); | 6656 DCHECK(canonical->HasHashCode()); |
| 6657 return canonical; | 6657 return canonical; |
| 6658 } | 6658 } |
| 6659 | 6659 |
| 6660 | 6660 |
| 6661 Object* JSReceiver::GetConstructor() { | 6661 Object* JSReceiver::GetConstructor() { |
| 6662 return map()->constructor(); | 6662 return map()->constructor(); |
| 6663 } | 6663 } |
| 6664 | 6664 |
| 6665 | 6665 |
| 6666 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object, | 6666 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6820 Handle<Object> value) { | 6820 Handle<Object> value) { |
| 6821 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); | 6821 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
| 6822 } | 6822 } |
| 6823 | 6823 |
| 6824 | 6824 |
| 6825 template<typename Derived, typename Shape, typename Key> | 6825 template<typename Derived, typename Shape, typename Key> |
| 6826 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, | 6826 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
| 6827 Handle<Object> key, | 6827 Handle<Object> key, |
| 6828 Handle<Object> value, | 6828 Handle<Object> value, |
| 6829 PropertyDetails details) { | 6829 PropertyDetails details) { |
| 6830 ASSERT(!key->IsName() || | 6830 DCHECK(!key->IsName() || |
| 6831 details.IsDeleted() || | 6831 details.IsDeleted() || |
| 6832 details.dictionary_index() > 0); | 6832 details.dictionary_index() > 0); |
| 6833 int index = DerivedHashTable::EntryToIndex(entry); | 6833 int index = DerivedHashTable::EntryToIndex(entry); |
| 6834 DisallowHeapAllocation no_gc; | 6834 DisallowHeapAllocation no_gc; |
| 6835 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 6835 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
| 6836 FixedArray::set(index, *key, mode); | 6836 FixedArray::set(index, *key, mode); |
| 6837 FixedArray::set(index+1, *value, mode); | 6837 FixedArray::set(index+1, *value, mode); |
| 6838 FixedArray::set(index+2, details.AsSmi()); | 6838 FixedArray::set(index+2, details.AsSmi()); |
| 6839 } | 6839 } |
| 6840 | 6840 |
| 6841 | 6841 |
| 6842 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 6842 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
| 6843 ASSERT(other->IsNumber()); | 6843 DCHECK(other->IsNumber()); |
| 6844 return key == static_cast<uint32_t>(other->Number()); | 6844 return key == static_cast<uint32_t>(other->Number()); |
| 6845 } | 6845 } |
| 6846 | 6846 |
| 6847 | 6847 |
| 6848 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) { | 6848 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) { |
| 6849 return ComputeIntegerHash(key, 0); | 6849 return ComputeIntegerHash(key, 0); |
| 6850 } | 6850 } |
| 6851 | 6851 |
| 6852 | 6852 |
| 6853 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, | 6853 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, |
| 6854 Object* other) { | 6854 Object* other) { |
| 6855 ASSERT(other->IsNumber()); | 6855 DCHECK(other->IsNumber()); |
| 6856 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); | 6856 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); |
| 6857 } | 6857 } |
| 6858 | 6858 |
| 6859 | 6859 |
| 6860 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | 6860 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { |
| 6861 return ComputeIntegerHash(key, seed); | 6861 return ComputeIntegerHash(key, seed); |
| 6862 } | 6862 } |
| 6863 | 6863 |
| 6864 | 6864 |
| 6865 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, | 6865 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, |
| 6866 uint32_t seed, | 6866 uint32_t seed, |
| 6867 Object* other) { | 6867 Object* other) { |
| 6868 ASSERT(other->IsNumber()); | 6868 DCHECK(other->IsNumber()); |
| 6869 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | 6869 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); |
| 6870 } | 6870 } |
| 6871 | 6871 |
| 6872 | 6872 |
| 6873 Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) { | 6873 Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) { |
| 6874 return isolate->factory()->NewNumberFromUint(key); | 6874 return isolate->factory()->NewNumberFromUint(key); |
| 6875 } | 6875 } |
| 6876 | 6876 |
| 6877 | 6877 |
| 6878 bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) { | 6878 bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) { |
| 6879 // We know that all entries in a hash table had their hash keys created. | 6879 // We know that all entries in a hash table had their hash keys created. |
| 6880 // Use that knowledge to have fast failure. | 6880 // Use that knowledge to have fast failure. |
| 6881 if (key->Hash() != Name::cast(other)->Hash()) return false; | 6881 if (key->Hash() != Name::cast(other)->Hash()) return false; |
| 6882 return key->Equals(Name::cast(other)); | 6882 return key->Equals(Name::cast(other)); |
| 6883 } | 6883 } |
| 6884 | 6884 |
| 6885 | 6885 |
| 6886 uint32_t NameDictionaryShape::Hash(Handle<Name> key) { | 6886 uint32_t NameDictionaryShape::Hash(Handle<Name> key) { |
| 6887 return key->Hash(); | 6887 return key->Hash(); |
| 6888 } | 6888 } |
| 6889 | 6889 |
| 6890 | 6890 |
| 6891 uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) { | 6891 uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) { |
| 6892 return Name::cast(other)->Hash(); | 6892 return Name::cast(other)->Hash(); |
| 6893 } | 6893 } |
| 6894 | 6894 |
| 6895 | 6895 |
| 6896 Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, | 6896 Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, |
| 6897 Handle<Name> key) { | 6897 Handle<Name> key) { |
| 6898 ASSERT(key->IsUniqueName()); | 6898 DCHECK(key->IsUniqueName()); |
| 6899 return key; | 6899 return key; |
| 6900 } | 6900 } |
| 6901 | 6901 |
| 6902 | 6902 |
| 6903 void NameDictionary::DoGenerateNewEnumerationIndices( | 6903 void NameDictionary::DoGenerateNewEnumerationIndices( |
| 6904 Handle<NameDictionary> dictionary) { | 6904 Handle<NameDictionary> dictionary) { |
| 6905 DerivedDictionary::GenerateNewEnumerationIndices(dictionary); | 6905 DerivedDictionary::GenerateNewEnumerationIndices(dictionary); |
| 6906 } | 6906 } |
| 6907 | 6907 |
| 6908 | 6908 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6960 Handle<Object> key) { | 6960 Handle<Object> key) { |
| 6961 return key; | 6961 return key; |
| 6962 } | 6962 } |
| 6963 | 6963 |
| 6964 | 6964 |
| 6965 void Map::ClearCodeCache(Heap* heap) { | 6965 void Map::ClearCodeCache(Heap* heap) { |
| 6966 // No write barrier is needed since empty_fixed_array is not in new space. | 6966 // No write barrier is needed since empty_fixed_array is not in new space. |
| 6967 // Please note this function is used during marking: | 6967 // Please note this function is used during marking: |
| 6968 // - MarkCompactCollector::MarkUnmarkedObject | 6968 // - MarkCompactCollector::MarkUnmarkedObject |
| 6969 // - IncrementalMarking::Step | 6969 // - IncrementalMarking::Step |
| 6970 ASSERT(!heap->InNewSpace(heap->empty_fixed_array())); | 6970 DCHECK(!heap->InNewSpace(heap->empty_fixed_array())); |
| 6971 WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array()); | 6971 WRITE_FIELD(this, kCodeCacheOffset, heap->empty_fixed_array()); |
| 6972 } | 6972 } |
| 6973 | 6973 |
| 6974 | 6974 |
| 6975 void JSArray::EnsureSize(Handle<JSArray> array, int required_size) { | 6975 void JSArray::EnsureSize(Handle<JSArray> array, int required_size) { |
| 6976 ASSERT(array->HasFastSmiOrObjectElements()); | 6976 DCHECK(array->HasFastSmiOrObjectElements()); |
| 6977 Handle<FixedArray> elts = handle(FixedArray::cast(array->elements())); | 6977 Handle<FixedArray> elts = handle(FixedArray::cast(array->elements())); |
| 6978 const int kArraySizeThatFitsComfortablyInNewSpace = 128; | 6978 const int kArraySizeThatFitsComfortablyInNewSpace = 128; |
| 6979 if (elts->length() < required_size) { | 6979 if (elts->length() < required_size) { |
| 6980 // Doubling in size would be overkill, but leave some slack to avoid | 6980 // Doubling in size would be overkill, but leave some slack to avoid |
| 6981 // constantly growing. | 6981 // constantly growing. |
| 6982 Expand(array, required_size + (required_size >> 3)); | 6982 Expand(array, required_size + (required_size >> 3)); |
| 6983 // It's a performance benefit to keep a frequently used array in new-space. | 6983 // It's a performance benefit to keep a frequently used array in new-space. |
| 6984 } else if (!array->GetHeap()->new_space()->Contains(*elts) && | 6984 } else if (!array->GetHeap()->new_space()->Contains(*elts) && |
| 6985 required_size < kArraySizeThatFitsComfortablyInNewSpace) { | 6985 required_size < kArraySizeThatFitsComfortablyInNewSpace) { |
| 6986 // Expand will allocate a new backing store in new space even if the size | 6986 // Expand will allocate a new backing store in new space even if the size |
| 6987 // we asked for isn't larger than what we had before. | 6987 // we asked for isn't larger than what we had before. |
| 6988 Expand(array, required_size); | 6988 Expand(array, required_size); |
| 6989 } | 6989 } |
| 6990 } | 6990 } |
| 6991 | 6991 |
| 6992 | 6992 |
| 6993 void JSArray::set_length(Smi* length) { | 6993 void JSArray::set_length(Smi* length) { |
| 6994 // Don't need a write barrier for a Smi. | 6994 // Don't need a write barrier for a Smi. |
| 6995 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER); | 6995 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER); |
| 6996 } | 6996 } |
| 6997 | 6997 |
| 6998 | 6998 |
| 6999 bool JSArray::AllowsSetElementsLength() { | 6999 bool JSArray::AllowsSetElementsLength() { |
| 7000 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); | 7000 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); |
| 7001 ASSERT(result == !HasExternalArrayElements()); | 7001 DCHECK(result == !HasExternalArrayElements()); |
| 7002 return result; | 7002 return result; |
| 7003 } | 7003 } |
| 7004 | 7004 |
| 7005 | 7005 |
| 7006 void JSArray::SetContent(Handle<JSArray> array, | 7006 void JSArray::SetContent(Handle<JSArray> array, |
| 7007 Handle<FixedArrayBase> storage) { | 7007 Handle<FixedArrayBase> storage) { |
| 7008 EnsureCanContainElements(array, storage, storage->length(), | 7008 EnsureCanContainElements(array, storage, storage->length(), |
| 7009 ALLOW_COPIED_DOUBLE_ELEMENTS); | 7009 ALLOW_COPIED_DOUBLE_ELEMENTS); |
| 7010 | 7010 |
| 7011 ASSERT((storage->map() == array->GetHeap()->fixed_double_array_map() && | 7011 DCHECK((storage->map() == array->GetHeap()->fixed_double_array_map() && |
| 7012 IsFastDoubleElementsKind(array->GetElementsKind())) || | 7012 IsFastDoubleElementsKind(array->GetElementsKind())) || |
| 7013 ((storage->map() != array->GetHeap()->fixed_double_array_map()) && | 7013 ((storage->map() != array->GetHeap()->fixed_double_array_map()) && |
| 7014 (IsFastObjectElementsKind(array->GetElementsKind()) || | 7014 (IsFastObjectElementsKind(array->GetElementsKind()) || |
| 7015 (IsFastSmiElementsKind(array->GetElementsKind()) && | 7015 (IsFastSmiElementsKind(array->GetElementsKind()) && |
| 7016 Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles())))); | 7016 Handle<FixedArray>::cast(storage)->ContainsOnlySmisOrHoles())))); |
| 7017 array->set_elements(*storage); | 7017 array->set_elements(*storage); |
| 7018 array->set_length(Smi::FromInt(storage->length())); | 7018 array->set_length(Smi::FromInt(storage->length())); |
| 7019 } | 7019 } |
| 7020 | 7020 |
| 7021 | 7021 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7122 | 7122 |
| 7123 | 7123 |
| 7124 Relocatable::Relocatable(Isolate* isolate) { | 7124 Relocatable::Relocatable(Isolate* isolate) { |
| 7125 isolate_ = isolate; | 7125 isolate_ = isolate; |
| 7126 prev_ = isolate->relocatable_top(); | 7126 prev_ = isolate->relocatable_top(); |
| 7127 isolate->set_relocatable_top(this); | 7127 isolate->set_relocatable_top(this); |
| 7128 } | 7128 } |
| 7129 | 7129 |
| 7130 | 7130 |
| 7131 Relocatable::~Relocatable() { | 7131 Relocatable::~Relocatable() { |
| 7132 ASSERT_EQ(isolate_->relocatable_top(), this); | 7132 DCHECK_EQ(isolate_->relocatable_top(), this); |
| 7133 isolate_->set_relocatable_top(prev_); | 7133 isolate_->set_relocatable_top(prev_); |
| 7134 } | 7134 } |
| 7135 | 7135 |
| 7136 | 7136 |
| 7137 int JSObject::BodyDescriptor::SizeOf(Map* map, HeapObject* object) { | 7137 int JSObject::BodyDescriptor::SizeOf(Map* map, HeapObject* object) { |
| 7138 return map->instance_size(); | 7138 return map->instance_size(); |
| 7139 } | 7139 } |
| 7140 | 7140 |
| 7141 | 7141 |
| 7142 void Foreign::ForeignIterateBody(ObjectVisitor* v) { | 7142 void Foreign::ForeignIterateBody(ObjectVisitor* v) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7198 v->VisitPointers(HeapObject::RawField(obj, start_offset), | 7198 v->VisitPointers(HeapObject::RawField(obj, start_offset), |
| 7199 HeapObject::RawField(obj, object_size)); | 7199 HeapObject::RawField(obj, object_size)); |
| 7200 } | 7200 } |
| 7201 | 7201 |
| 7202 | 7202 |
| 7203 template<class Derived, class TableType> | 7203 template<class Derived, class TableType> |
| 7204 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { | 7204 Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { |
| 7205 TableType* table(TableType::cast(this->table())); | 7205 TableType* table(TableType::cast(this->table())); |
| 7206 int index = Smi::cast(this->index())->value(); | 7206 int index = Smi::cast(this->index())->value(); |
| 7207 Object* key = table->KeyAt(index); | 7207 Object* key = table->KeyAt(index); |
| 7208 ASSERT(!key->IsTheHole()); | 7208 DCHECK(!key->IsTheHole()); |
| 7209 return key; | 7209 return key; |
| 7210 } | 7210 } |
| 7211 | 7211 |
| 7212 | 7212 |
| 7213 void JSSetIterator::PopulateValueArray(FixedArray* array) { | 7213 void JSSetIterator::PopulateValueArray(FixedArray* array) { |
| 7214 array->set(0, CurrentKey()); | 7214 array->set(0, CurrentKey()); |
| 7215 } | 7215 } |
| 7216 | 7216 |
| 7217 | 7217 |
| 7218 void JSMapIterator::PopulateValueArray(FixedArray* array) { | 7218 void JSMapIterator::PopulateValueArray(FixedArray* array) { |
| 7219 array->set(0, CurrentKey()); | 7219 array->set(0, CurrentKey()); |
| 7220 array->set(1, CurrentValue()); | 7220 array->set(1, CurrentValue()); |
| 7221 } | 7221 } |
| 7222 | 7222 |
| 7223 | 7223 |
| 7224 Object* JSMapIterator::CurrentValue() { | 7224 Object* JSMapIterator::CurrentValue() { |
| 7225 OrderedHashMap* table(OrderedHashMap::cast(this->table())); | 7225 OrderedHashMap* table(OrderedHashMap::cast(this->table())); |
| 7226 int index = Smi::cast(this->index())->value(); | 7226 int index = Smi::cast(this->index())->value(); |
| 7227 Object* value = table->ValueAt(index); | 7227 Object* value = table->ValueAt(index); |
| 7228 ASSERT(!value->IsTheHole()); | 7228 DCHECK(!value->IsTheHole()); |
| 7229 return value; | 7229 return value; |
| 7230 } | 7230 } |
| 7231 | 7231 |
| 7232 | 7232 |
| 7233 #undef TYPE_CHECKER | 7233 #undef TYPE_CHECKER |
| 7234 #undef CAST_ACCESSOR | 7234 #undef CAST_ACCESSOR |
| 7235 #undef INT_ACCESSORS | 7235 #undef INT_ACCESSORS |
| 7236 #undef ACCESSORS | 7236 #undef ACCESSORS |
| 7237 #undef ACCESSORS_TO_SMI | 7237 #undef ACCESSORS_TO_SMI |
| 7238 #undef SMI_ACCESSORS | 7238 #undef SMI_ACCESSORS |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7259 #undef READ_SHORT_FIELD | 7259 #undef READ_SHORT_FIELD |
| 7260 #undef WRITE_SHORT_FIELD | 7260 #undef WRITE_SHORT_FIELD |
| 7261 #undef READ_BYTE_FIELD | 7261 #undef READ_BYTE_FIELD |
| 7262 #undef WRITE_BYTE_FIELD | 7262 #undef WRITE_BYTE_FIELD |
| 7263 #undef NOBARRIER_READ_BYTE_FIELD | 7263 #undef NOBARRIER_READ_BYTE_FIELD |
| 7264 #undef NOBARRIER_WRITE_BYTE_FIELD | 7264 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7265 | 7265 |
| 7266 } } // namespace v8::internal | 7266 } } // namespace v8::internal |
| 7267 | 7267 |
| 7268 #endif // V8_OBJECTS_INL_H_ | 7268 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |