Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4441 } | 4441 } |
| 4442 if (pt->IsNull()) return ABSENT; | 4442 if (pt->IsNull()) return ABSENT; |
| 4443 return JSObject::cast(pt)->GetElementAttributeWithReceiver( | 4443 return JSObject::cast(pt)->GetElementAttributeWithReceiver( |
| 4444 receiver, index, true); | 4444 receiver, index, true); |
| 4445 } | 4445 } |
| 4446 | 4446 |
| 4447 | 4447 |
| 4448 Handle<Map> NormalizedMapCache::Get(Handle<NormalizedMapCache> cache, | 4448 Handle<Map> NormalizedMapCache::Get(Handle<NormalizedMapCache> cache, |
| 4449 Handle<JSObject> obj, | 4449 Handle<JSObject> obj, |
| 4450 PropertyNormalizationMode mode) { | 4450 PropertyNormalizationMode mode) { |
| 4451 Map* fast = obj->map(); | 4451 Map* fast = obj->map(); |
|
rafaelw
2013/10/22 02:30:54
I'm assuming the cache-hit path is using raw point
Michael Starzinger
2013/10/22 16:29:50
Yes, you are right, this is tricky. I think it get
rafaelw
2013/10/22 18:59:59
Done.
| |
| 4452 int index = fast->Hash() % kEntries; | 4452 int index = fast->Hash() % kEntries; |
| 4453 Object* result = cache->get(index); | 4453 Object* result = cache->get(index); |
| 4454 if (result->IsMap() && | 4454 if (result->IsMap() && |
| 4455 Map::cast(result)->EquivalentToForNormalization(fast, mode)) { | 4455 Map::cast(result)->EquivalentToForNormalization(fast, mode)) { |
| 4456 #ifdef VERIFY_HEAP | 4456 #ifdef VERIFY_HEAP |
| 4457 if (FLAG_verify_heap) { | 4457 if (FLAG_verify_heap) { |
| 4458 Map::cast(result)->SharedMapVerify(); | 4458 Map::cast(result)->SharedMapVerify(); |
| 4459 } | 4459 } |
| 4460 #endif | 4460 #endif |
| 4461 #ifdef DEBUG | 4461 #ifdef DEBUG |
| 4462 if (FLAG_enable_slow_asserts) { | 4462 if (FLAG_enable_slow_asserts) { |
| 4463 // The cached map should match newly created normalized map bit-by-bit, | 4463 // The cached map should match newly created normalized map bit-by-bit, |
| 4464 // except for the code cache, which can contain some ics which can be | 4464 // except for the code cache, which can contain some ics which can be |
| 4465 // applied to the shared map. | 4465 // applied to the shared map. |
| 4466 Object* fresh; | 4466 Handle<Map> fresh = Map::CopyNormalized(fast, SHARED_NORMALIZED_MAP); |
|
Michael Starzinger
2013/10/22 16:29:50
This shouldn't compile in debug mode, as "fast" is
rafaelw
2013/10/22 18:59:59
DOH! Done.
On 2013/10/22 16:29:50, Michael Starzi
| |
| 4467 MaybeObject* maybe_fresh = | 4467 |
| 4468 fast->CopyNormalized(mode, SHARED_NORMALIZED_MAP); | 4468 ASSERT(memcmp(fresh->address(), |
| 4469 if (maybe_fresh->ToObject(&fresh)) { | 4469 Map::cast(result)->address(), |
| 4470 ASSERT(memcmp(Map::cast(fresh)->address(), | 4470 Map::kCodeCacheOffset) == 0); |
| 4471 Map::cast(result)->address(), | 4471 STATIC_ASSERT(Map::kDependentCodeOffset == |
| 4472 Map::kCodeCacheOffset) == 0); | 4472 Map::kCodeCacheOffset + kPointerSize); |
| 4473 STATIC_ASSERT(Map::kDependentCodeOffset == | 4473 int offset = Map::kDependentCodeOffset + kPointerSize; |
| 4474 Map::kCodeCacheOffset + kPointerSize); | 4474 ASSERT(memcmp(fresh->address() + offset, |
| 4475 int offset = Map::kDependentCodeOffset + kPointerSize; | 4475 Map::cast(result)->address() + offset, |
| 4476 ASSERT(memcmp(Map::cast(fresh)->address() + offset, | 4476 Map::kSize - offset) == 0); |
| 4477 Map::cast(result)->address() + offset, | |
| 4478 Map::kSize - offset) == 0); | |
| 4479 } | |
| 4480 } | 4477 } |
| 4481 #endif | 4478 #endif |
| 4482 return handle(Map::cast(result)); | 4479 return handle(Map::cast(result)); |
|
Michael Starzinger
2013/10/22 16:29:50
At this point "result" might be stale.
rafaelw
2013/10/22 18:59:59
Right. Got it.
On 2013/10/22 16:29:50, Michael St
| |
| 4483 } | 4480 } |
| 4484 | 4481 |
| 4485 Isolate* isolate = cache->GetIsolate(); | 4482 Isolate* isolate = cache->GetIsolate(); |
| 4486 Handle<Map> map = Map::CopyNormalized(handle(fast), mode, | 4483 Handle<Map> map = Map::CopyNormalized(handle(fast), mode, |
| 4487 SHARED_NORMALIZED_MAP); | 4484 SHARED_NORMALIZED_MAP); |
| 4488 ASSERT(map->is_dictionary_map()); | 4485 ASSERT(map->is_dictionary_map()); |
| 4489 cache->set(index, *map); | 4486 cache->set(index, *map); |
| 4490 isolate->counters()->normalized_maps()->Increment(); | 4487 isolate->counters()->normalized_maps()->Increment(); |
| 4491 | 4488 |
| 4492 return map; | 4489 return map; |
| (...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6617 } | 6614 } |
| 6618 } | 6615 } |
| 6619 } | 6616 } |
| 6620 return GetHeap()->undefined_value(); | 6617 return GetHeap()->undefined_value(); |
| 6621 } else { | 6618 } else { |
| 6622 return property_dictionary()->SlowReverseLookup(value); | 6619 return property_dictionary()->SlowReverseLookup(value); |
| 6623 } | 6620 } |
| 6624 } | 6621 } |
| 6625 | 6622 |
| 6626 | 6623 |
| 6624 Handle<Map> Map::RawCopy(Handle<Map> map, | |
| 6625 int instance_size) { | |
| 6626 CALL_HEAP_FUNCTION(map->GetIsolate(), | |
| 6627 map->RawCopy(instance_size), | |
| 6628 Map); | |
| 6629 } | |
| 6630 | |
| 6631 | |
| 6627 MaybeObject* Map::RawCopy(int instance_size) { | 6632 MaybeObject* Map::RawCopy(int instance_size) { |
| 6628 Map* result; | 6633 Map* result; |
| 6629 MaybeObject* maybe_result = | 6634 MaybeObject* maybe_result = |
| 6630 GetHeap()->AllocateMap(instance_type(), instance_size); | 6635 GetHeap()->AllocateMap(instance_type(), instance_size); |
| 6631 if (!maybe_result->To(&result)) return maybe_result; | 6636 if (!maybe_result->To(&result)) return maybe_result; |
| 6632 | 6637 |
| 6633 result->set_prototype(prototype()); | 6638 result->set_prototype(prototype()); |
| 6634 result->set_constructor(constructor()); | 6639 result->set_constructor(constructor()); |
| 6635 result->set_bit_field(bit_field()); | 6640 result->set_bit_field(bit_field()); |
| 6636 result->set_bit_field2(bit_field2()); | 6641 result->set_bit_field2(bit_field2()); |
| 6637 int new_bit_field3 = bit_field3(); | 6642 int new_bit_field3 = bit_field3(); |
| 6638 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); | 6643 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); |
| 6639 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); | 6644 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); |
| 6640 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache); | 6645 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache); |
| 6641 new_bit_field3 = Deprecated::update(new_bit_field3, false); | 6646 new_bit_field3 = Deprecated::update(new_bit_field3, false); |
| 6642 new_bit_field3 = IsUnstable::update(new_bit_field3, false); | 6647 new_bit_field3 = IsUnstable::update(new_bit_field3, false); |
| 6643 result->set_bit_field3(new_bit_field3); | 6648 result->set_bit_field3(new_bit_field3); |
| 6644 return result; | 6649 return result; |
| 6645 } | 6650 } |
| 6646 | 6651 |
| 6647 | 6652 |
| 6648 Handle<Map> Map::CopyNormalized(Handle<Map> map, | 6653 Handle<Map> Map::CopyNormalized(Handle<Map> map, |
| 6649 PropertyNormalizationMode mode, | 6654 PropertyNormalizationMode mode, |
| 6650 NormalizedMapSharingMode sharing) { | 6655 NormalizedMapSharingMode sharing) { |
| 6651 CALL_HEAP_FUNCTION(map->GetIsolate(), | 6656 int new_instance_size = map->instance_size(); |
| 6652 map->CopyNormalized(mode, sharing), | |
| 6653 Map); | |
| 6654 } | |
| 6655 | |
| 6656 | |
| 6657 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, | |
| 6658 NormalizedMapSharingMode sharing) { | |
| 6659 int new_instance_size = instance_size(); | |
| 6660 if (mode == CLEAR_INOBJECT_PROPERTIES) { | 6657 if (mode == CLEAR_INOBJECT_PROPERTIES) { |
| 6661 new_instance_size -= inobject_properties() * kPointerSize; | 6658 new_instance_size -= map->inobject_properties() * kPointerSize; |
| 6662 } | 6659 } |
| 6663 | 6660 |
| 6664 Map* result; | 6661 Handle<Map> result = Map::RawCopy(map, new_instance_size); |
| 6665 MaybeObject* maybe_result = RawCopy(new_instance_size); | |
| 6666 if (!maybe_result->To(&result)) return maybe_result; | |
| 6667 | 6662 |
| 6668 if (mode != CLEAR_INOBJECT_PROPERTIES) { | 6663 if (mode != CLEAR_INOBJECT_PROPERTIES) { |
| 6669 result->set_inobject_properties(inobject_properties()); | 6664 result->set_inobject_properties(map->inobject_properties()); |
| 6670 } | 6665 } |
| 6671 | 6666 |
| 6672 result->set_is_shared(sharing == SHARED_NORMALIZED_MAP); | 6667 result->set_is_shared(sharing == SHARED_NORMALIZED_MAP); |
| 6673 result->set_dictionary_map(true); | 6668 result->set_dictionary_map(true); |
| 6674 result->set_migration_target(false); | 6669 result->set_migration_target(false); |
| 6675 | 6670 |
| 6676 #ifdef VERIFY_HEAP | 6671 #ifdef VERIFY_HEAP |
| 6677 if (FLAG_verify_heap && result->is_shared()) { | 6672 if (FLAG_verify_heap && result->is_shared()) { |
| 6678 result->SharedMapVerify(); | 6673 result->SharedMapVerify(); |
| 6679 } | 6674 } |
| (...skipping 9689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16369 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16364 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16370 static const char* error_messages_[] = { | 16365 static const char* error_messages_[] = { |
| 16371 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16366 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16372 }; | 16367 }; |
| 16373 #undef ERROR_MESSAGES_TEXTS | 16368 #undef ERROR_MESSAGES_TEXTS |
| 16374 return error_messages_[reason]; | 16369 return error_messages_[reason]; |
| 16375 } | 16370 } |
| 16376 | 16371 |
| 16377 | 16372 |
| 16378 } } // namespace v8::internal | 16373 } } // namespace v8::internal |
| OLD | NEW |