| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 MaybeObject* Object::ToObject(Context* native_context) { | 76 MaybeObject* Object::ToObject(Context* native_context) { |
| 77 if (IsNumber()) { | 77 if (IsNumber()) { |
| 78 return CreateJSValue(native_context->number_function(), this); | 78 return CreateJSValue(native_context->number_function(), this); |
| 79 } else if (IsBoolean()) { | 79 } else if (IsBoolean()) { |
| 80 return CreateJSValue(native_context->boolean_function(), this); | 80 return CreateJSValue(native_context->boolean_function(), this); |
| 81 } else if (IsString()) { | 81 } else if (IsString()) { |
| 82 return CreateJSValue(native_context->string_function(), this); | 82 return CreateJSValue(native_context->string_function(), this); |
| 83 } else if (IsSymbol()) { | |
| 84 return CreateJSValue(native_context->symbol_function(), this); | |
| 85 } | 83 } |
| 86 ASSERT(IsJSObject()); | 84 ASSERT(IsJSObject()); |
| 87 return this; | 85 return this; |
| 88 } | 86 } |
| 89 | 87 |
| 90 | 88 |
| 91 MaybeObject* Object::ToObject(Isolate* isolate) { | 89 MaybeObject* Object::ToObject(Isolate* isolate) { |
| 92 if (IsJSReceiver()) { | 90 if (IsJSReceiver()) { |
| 93 return this; | 91 return this; |
| 94 } else if (IsNumber()) { | 92 } else if (IsNumber()) { |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 case NONEXISTENT: | 680 case NONEXISTENT: |
| 683 UNREACHABLE(); | 681 UNREACHABLE(); |
| 684 } | 682 } |
| 685 } | 683 } |
| 686 | 684 |
| 687 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 685 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 688 return ABSENT; | 686 return ABSENT; |
| 689 } | 687 } |
| 690 | 688 |
| 691 | 689 |
| 692 Object* JSObject::GetNormalizedProperty(const LookupResult* result) { | 690 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
| 693 ASSERT(!HasFastProperties()); | 691 ASSERT(!HasFastProperties()); |
| 694 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 692 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 695 if (IsGlobalObject()) { | 693 if (IsGlobalObject()) { |
| 696 value = PropertyCell::cast(value)->value(); | 694 value = PropertyCell::cast(value)->value(); |
| 697 } | 695 } |
| 698 ASSERT(!value->IsPropertyCell() && !value->IsCell()); | 696 ASSERT(!value->IsPropertyCell() && !value->IsCell()); |
| 699 return value; | 697 return value; |
| 700 } | 698 } |
| 701 | 699 |
| 702 | 700 |
| 703 void JSObject::SetNormalizedProperty(Handle<JSObject> object, | 701 void JSObject::SetNormalizedProperty(Handle<JSObject> object, |
| 704 const LookupResult* result, | 702 LookupResult* result, |
| 705 Handle<Object> value) { | 703 Handle<Object> value) { |
| 706 ASSERT(!object->HasFastProperties()); | 704 ASSERT(!object->HasFastProperties()); |
| 707 NameDictionary* property_dictionary = object->property_dictionary(); | 705 NameDictionary* property_dictionary = object->property_dictionary(); |
| 708 if (object->IsGlobalObject()) { | 706 if (object->IsGlobalObject()) { |
| 709 Handle<PropertyCell> cell(PropertyCell::cast( | 707 Handle<PropertyCell> cell(PropertyCell::cast( |
| 710 property_dictionary->ValueAt(result->GetDictionaryEntry()))); | 708 property_dictionary->ValueAt(result->GetDictionaryEntry()))); |
| 711 PropertyCell::SetValueInferType(cell, value); | 709 PropertyCell::SetValueInferType(cell, value); |
| 712 } else { | 710 } else { |
| 713 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value); | 711 property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value); |
| 714 } | 712 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 727 | 725 |
| 728 | 726 |
| 729 void JSObject::SetNormalizedProperty(Handle<JSObject> object, | 727 void JSObject::SetNormalizedProperty(Handle<JSObject> object, |
| 730 Handle<Name> name, | 728 Handle<Name> name, |
| 731 Handle<Object> value, | 729 Handle<Object> value, |
| 732 PropertyDetails details) { | 730 PropertyDetails details) { |
| 733 ASSERT(!object->HasFastProperties()); | 731 ASSERT(!object->HasFastProperties()); |
| 734 Handle<NameDictionary> property_dictionary(object->property_dictionary()); | 732 Handle<NameDictionary> property_dictionary(object->property_dictionary()); |
| 735 | 733 |
| 736 if (!name->IsUniqueName()) { | 734 if (!name->IsUniqueName()) { |
| 737 name = object->GetIsolate()->factory()->InternalizeString( | 735 name = object->GetIsolate()->factory()->InternalizedStringFromString( |
| 738 Handle<String>::cast(name)); | 736 Handle<String>::cast(name)); |
| 739 } | 737 } |
| 740 | 738 |
| 741 int entry = property_dictionary->FindEntry(*name); | 739 int entry = property_dictionary->FindEntry(*name); |
| 742 if (entry == NameDictionary::kNotFound) { | 740 if (entry == NameDictionary::kNotFound) { |
| 743 Handle<Object> store_value = value; | 741 Handle<Object> store_value = value; |
| 744 if (object->IsGlobalObject()) { | 742 if (object->IsGlobalObject()) { |
| 745 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); | 743 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); |
| 746 } | 744 } |
| 747 | 745 |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 StrictModeFlag strict_mode, | 2145 StrictModeFlag strict_mode, |
| 2148 JSReceiver::StoreFromKeyed store_mode, | 2146 JSReceiver::StoreFromKeyed store_mode, |
| 2149 ExtensibilityCheck extensibility_check, | 2147 ExtensibilityCheck extensibility_check, |
| 2150 ValueType value_type, | 2148 ValueType value_type, |
| 2151 StoreMode mode, | 2149 StoreMode mode, |
| 2152 TransitionFlag transition_flag) { | 2150 TransitionFlag transition_flag) { |
| 2153 ASSERT(!object->IsJSGlobalProxy()); | 2151 ASSERT(!object->IsJSGlobalProxy()); |
| 2154 Isolate* isolate = object->GetIsolate(); | 2152 Isolate* isolate = object->GetIsolate(); |
| 2155 | 2153 |
| 2156 if (!name->IsUniqueName()) { | 2154 if (!name->IsUniqueName()) { |
| 2157 name = isolate->factory()->InternalizeString( | 2155 name = isolate->factory()->InternalizedStringFromString( |
| 2158 Handle<String>::cast(name)); | 2156 Handle<String>::cast(name)); |
| 2159 } | 2157 } |
| 2160 | 2158 |
| 2161 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && | 2159 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && |
| 2162 !object->map()->is_extensible()) { | 2160 !object->map()->is_extensible()) { |
| 2163 if (strict_mode == kNonStrictMode) { | 2161 if (strict_mode == kNonStrictMode) { |
| 2164 return value; | 2162 return value; |
| 2165 } else { | 2163 } else { |
| 2166 Handle<Object> args[1] = { name }; | 2164 Handle<Object> args[1] = { name }; |
| 2167 Handle<Object> error = isolate->factory()->NewTypeError( | 2165 Handle<Object> error = isolate->factory()->NewTypeError( |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 int nof_callbacks = callbacks->length(); | 3128 int nof_callbacks = callbacks->length(); |
| 3131 | 3129 |
| 3132 Isolate* isolate = array->GetIsolate(); | 3130 Isolate* isolate = array->GetIsolate(); |
| 3133 // Ensure the keys are unique names before writing them into the | 3131 // Ensure the keys are unique names before writing them into the |
| 3134 // instance descriptor. Since it may cause a GC, it has to be done before we | 3132 // instance descriptor. Since it may cause a GC, it has to be done before we |
| 3135 // temporarily put the heap in an invalid state while appending descriptors. | 3133 // temporarily put the heap in an invalid state while appending descriptors. |
| 3136 for (int i = 0; i < nof_callbacks; ++i) { | 3134 for (int i = 0; i < nof_callbacks; ++i) { |
| 3137 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i))); | 3135 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i))); |
| 3138 if (entry->name()->IsUniqueName()) continue; | 3136 if (entry->name()->IsUniqueName()) continue; |
| 3139 Handle<String> key = | 3137 Handle<String> key = |
| 3140 isolate->factory()->InternalizeString( | 3138 isolate->factory()->InternalizedStringFromString( |
| 3141 Handle<String>(String::cast(entry->name()))); | 3139 Handle<String>(String::cast(entry->name()))); |
| 3142 entry->set_name(*key); | 3140 entry->set_name(*key); |
| 3143 } | 3141 } |
| 3144 | 3142 |
| 3145 // Fill in new callback descriptors. Process the callbacks from | 3143 // Fill in new callback descriptors. Process the callbacks from |
| 3146 // back to front so that the last callback with a given name takes | 3144 // back to front so that the last callback with a given name takes |
| 3147 // precedence over previously added callbacks with that name. | 3145 // precedence over previously added callbacks with that name. |
| 3148 for (int i = nof_callbacks - 1; i >= 0; i--) { | 3146 for (int i = nof_callbacks - 1; i >= 0; i--) { |
| 3149 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i)); | 3147 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i)); |
| 3150 Name* key = Name::cast(entry->name()); | 3148 Name* key = Name::cast(entry->name()); |
| (...skipping 4353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7504 Object* new_cache; | 7502 Object* new_cache; |
| 7505 { MaybeObject* maybe_new_cache = cache->Put(name, code); | 7503 { MaybeObject* maybe_new_cache = cache->Put(name, code); |
| 7506 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; | 7504 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; |
| 7507 } | 7505 } |
| 7508 set_normal_type_cache(new_cache); | 7506 set_normal_type_cache(new_cache); |
| 7509 return this; | 7507 return this; |
| 7510 } | 7508 } |
| 7511 | 7509 |
| 7512 | 7510 |
| 7513 Object* CodeCache::Lookup(Name* name, Code::Flags flags) { | 7511 Object* CodeCache::Lookup(Name* name, Code::Flags flags) { |
| 7514 Object* result = LookupDefaultCache(name, Code::RemoveTypeFromFlags(flags)); | 7512 flags = Code::RemoveTypeFromFlags(flags); |
| 7515 if (result->IsCode()) { | 7513 Object* result = LookupDefaultCache(name, flags); |
| 7516 if (Code::cast(result)->flags() == flags) return result; | 7514 if (result->IsCode()) return result; |
| 7517 return GetHeap()->undefined_value(); | |
| 7518 } | |
| 7519 return LookupNormalTypeCache(name, flags); | 7515 return LookupNormalTypeCache(name, flags); |
| 7520 } | 7516 } |
| 7521 | 7517 |
| 7522 | 7518 |
| 7523 Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) { | 7519 Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) { |
| 7524 FixedArray* cache = default_cache(); | 7520 FixedArray* cache = default_cache(); |
| 7525 int length = cache->length(); | 7521 int length = cache->length(); |
| 7526 for (int i = 0; i < length; i += kCodeCacheEntrySize) { | 7522 for (int i = 0; i < length; i += kCodeCacheEntrySize) { |
| 7527 Object* key = cache->get(i + kCodeCacheEntryNameOffset); | 7523 Object* key = cache->get(i + kCodeCacheEntryNameOffset); |
| 7528 // Skip deleted elements. | 7524 // Skip deleted elements. |
| (...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10628 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); | 10624 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); |
| 10629 if (target->is_inline_cache_stub()) { | 10625 if (target->is_inline_cache_stub()) { |
| 10630 if (kind == NULL || *kind == target->kind()) { | 10626 if (kind == NULL || *kind == target->kind()) { |
| 10631 IC::Clear(this->GetIsolate(), info->pc()); | 10627 IC::Clear(this->GetIsolate(), info->pc()); |
| 10632 } | 10628 } |
| 10633 } | 10629 } |
| 10634 } | 10630 } |
| 10635 } | 10631 } |
| 10636 | 10632 |
| 10637 | 10633 |
| 10638 void Code::ClearTypeFeedbackInfo(Heap* heap) { | 10634 void Code::ClearTypeFeedbackCells(Heap* heap) { |
| 10639 if (kind() != FUNCTION) return; | 10635 if (kind() != FUNCTION) return; |
| 10640 Object* raw_info = type_feedback_info(); | 10636 Object* raw_info = type_feedback_info(); |
| 10641 if (raw_info->IsTypeFeedbackInfo()) { | 10637 if (raw_info->IsTypeFeedbackInfo()) { |
| 10642 FixedArray* feedback_vector = | 10638 TypeFeedbackCells* type_feedback_cells = |
| 10643 TypeFeedbackInfo::cast(raw_info)->feedback_vector(); | 10639 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells(); |
| 10644 for (int i = 0; i < feedback_vector->length(); i++) { | 10640 for (int i = 0; i < type_feedback_cells->CellCount(); i++) { |
| 10645 Object* obj = feedback_vector->get(i); | 10641 Cell* cell = type_feedback_cells->GetCell(i); |
| 10646 if (!obj->IsAllocationSite()) { | 10642 // Don't clear AllocationSites |
| 10647 // TODO(mvstanton): Can't I avoid a write barrier for this sentinel? | 10643 Object* value = cell->value(); |
| 10648 feedback_vector->set(i, | 10644 if (value == NULL || !value->IsAllocationSite()) { |
| 10649 TypeFeedbackInfo::RawUninitializedSentinel(heap)); | 10645 cell->set_value(TypeFeedbackCells::RawUninitializedSentinel(heap)); |
| 10650 } | 10646 } |
| 10651 } | 10647 } |
| 10652 } | 10648 } |
| 10653 } | 10649 } |
| 10654 | 10650 |
| 10655 | 10651 |
| 10656 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) { | 10652 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) { |
| 10657 DisallowHeapAllocation no_gc; | 10653 DisallowHeapAllocation no_gc; |
| 10658 ASSERT(kind() == FUNCTION); | 10654 ASSERT(kind() == FUNCTION); |
| 10659 BackEdgeTable back_edges(this, &no_gc); | 10655 BackEdgeTable back_edges(this, &no_gc); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11088 | 11084 |
| 11089 | 11085 |
| 11090 void Code::Disassemble(const char* name, FILE* out) { | 11086 void Code::Disassemble(const char* name, FILE* out) { |
| 11091 PrintF(out, "kind = %s\n", Kind2String(kind())); | 11087 PrintF(out, "kind = %s\n", Kind2String(kind())); |
| 11092 if (has_major_key()) { | 11088 if (has_major_key()) { |
| 11093 PrintF(out, "major_key = %s\n", | 11089 PrintF(out, "major_key = %s\n", |
| 11094 CodeStub::MajorName(CodeStub::GetMajorKey(this), true)); | 11090 CodeStub::MajorName(CodeStub::GetMajorKey(this), true)); |
| 11095 } | 11091 } |
| 11096 if (is_inline_cache_stub()) { | 11092 if (is_inline_cache_stub()) { |
| 11097 PrintF(out, "ic_state = %s\n", ICState2String(ic_state())); | 11093 PrintF(out, "ic_state = %s\n", ICState2String(ic_state())); |
| 11098 PrintExtraICState(out, kind(), extra_ic_state()); | 11094 PrintExtraICState(out, kind(), needs_extended_extra_ic_state(kind()) ? |
| 11095 extended_extra_ic_state() : extra_ic_state()); |
| 11099 if (ic_state() == MONOMORPHIC) { | 11096 if (ic_state() == MONOMORPHIC) { |
| 11100 PrintF(out, "type = %s\n", StubType2String(type())); | 11097 PrintF(out, "type = %s\n", StubType2String(type())); |
| 11101 } | 11098 } |
| 11102 if (is_compare_ic_stub()) { | 11099 if (is_compare_ic_stub()) { |
| 11103 ASSERT(major_key() == CodeStub::CompareIC); | 11100 ASSERT(major_key() == CodeStub::CompareIC); |
| 11104 CompareIC::State left_state, right_state, handler_state; | 11101 CompareIC::State left_state, right_state, handler_state; |
| 11105 Token::Value op; | 11102 Token::Value op; |
| 11106 ICCompareStub::DecodeMinorKey(stub_info(), &left_state, &right_state, | 11103 ICCompareStub::DecodeMinorKey(stub_info(), &left_state, &right_state, |
| 11107 &handler_state, &op); | 11104 &handler_state, &op); |
| 11108 PrintF(out, "compare_state = %s*%s -> %s\n", | 11105 PrintF(out, "compare_state = %s*%s -> %s\n", |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11264 GetElementsKind(), new_elements); | 11261 GetElementsKind(), new_elements); |
| 11265 } | 11262 } |
| 11266 | 11263 |
| 11267 if (IsJSArray()) { | 11264 if (IsJSArray()) { |
| 11268 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 11265 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
| 11269 } | 11266 } |
| 11270 return new_elements; | 11267 return new_elements; |
| 11271 } | 11268 } |
| 11272 | 11269 |
| 11273 | 11270 |
| 11271 bool Code::IsWeakEmbeddedObject(Kind kind, Object* object) { |
| 11272 if (kind != Code::OPTIMIZED_FUNCTION) return false; |
| 11273 |
| 11274 if (object->IsMap()) { |
| 11275 return Map::cast(object)->CanTransition() && |
| 11276 FLAG_collect_maps && |
| 11277 FLAG_weak_embedded_maps_in_optimized_code; |
| 11278 } |
| 11279 |
| 11280 if (object->IsJSObject() || |
| 11281 (object->IsCell() && Cell::cast(object)->value()->IsJSObject())) { |
| 11282 return FLAG_weak_embedded_objects_in_optimized_code; |
| 11283 } |
| 11284 |
| 11285 return false; |
| 11286 } |
| 11287 |
| 11288 |
| 11274 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object, | 11289 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object, |
| 11275 int capacity, | 11290 int capacity, |
| 11276 int length) { | 11291 int length) { |
| 11277 CALL_HEAP_FUNCTION_VOID( | 11292 CALL_HEAP_FUNCTION_VOID( |
| 11278 object->GetIsolate(), | 11293 object->GetIsolate(), |
| 11279 object->SetFastDoubleElementsCapacityAndLength(capacity, length)); | 11294 object->SetFastDoubleElementsCapacityAndLength(capacity, length)); |
| 11280 } | 11295 } |
| 11281 | 11296 |
| 11282 | 11297 |
| 11283 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( | 11298 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11742 DisallowHeapAllocation no_allocation_scope; | 11757 DisallowHeapAllocation no_allocation_scope; |
| 11743 DependentCode::GroupStartIndexes starts(this); | 11758 DependentCode::GroupStartIndexes starts(this); |
| 11744 int start = starts.at(group); | 11759 int start = starts.at(group); |
| 11745 int end = starts.at(group + 1); | 11760 int end = starts.at(group + 1); |
| 11746 int code_entries = starts.number_of_entries(); | 11761 int code_entries = starts.number_of_entries(); |
| 11747 if (start == end) return false; | 11762 if (start == end) return false; |
| 11748 | 11763 |
| 11749 // Mark all the code that needs to be deoptimized. | 11764 // Mark all the code that needs to be deoptimized. |
| 11750 bool marked = false; | 11765 bool marked = false; |
| 11751 for (int i = start; i < end; i++) { | 11766 for (int i = start; i < end; i++) { |
| 11752 if (is_code_at(i)) { | 11767 Object* object = object_at(i); |
| 11753 Code* code = code_at(i); | 11768 // TODO(hpayer): This is a temporary hack. Foreign objects move after |
| 11769 // new space evacuation. Since pretenuring may mark these objects as aborted |
| 11770 // we have to follow the forwarding pointer in that case. |
| 11771 MapWord map_word = HeapObject::cast(object)->map_word(); |
| 11772 if (map_word.IsForwardingAddress()) { |
| 11773 object = map_word.ToForwardingAddress(); |
| 11774 } |
| 11775 if (object->IsCode()) { |
| 11776 Code* code = Code::cast(object); |
| 11754 if (!code->marked_for_deoptimization()) { | 11777 if (!code->marked_for_deoptimization()) { |
| 11755 code->set_marked_for_deoptimization(true); | 11778 code->set_marked_for_deoptimization(true); |
| 11756 marked = true; | 11779 marked = true; |
| 11757 } | 11780 } |
| 11758 } else { | 11781 } else { |
| 11759 CompilationInfo* info = compilation_info_at(i); | 11782 CompilationInfo* info = reinterpret_cast<CompilationInfo*>( |
| 11783 Foreign::cast(object)->foreign_address()); |
| 11760 info->AbortDueToDependencyChange(); | 11784 info->AbortDueToDependencyChange(); |
| 11761 } | 11785 } |
| 11762 } | 11786 } |
| 11763 // Compact the array by moving all subsequent groups to fill in the new holes. | 11787 // Compact the array by moving all subsequent groups to fill in the new holes. |
| 11764 for (int src = end, dst = start; src < code_entries; src++, dst++) { | 11788 for (int src = end, dst = start; src < code_entries; src++, dst++) { |
| 11765 copy(src, dst); | 11789 copy(src, dst); |
| 11766 } | 11790 } |
| 11767 // Now the holes are at the end of the array, zap them for heap-verifier. | 11791 // Now the holes are at the end of the array, zap them for heap-verifier. |
| 11768 int removed = end - start; | 11792 int removed = end - start; |
| 11769 for (int i = code_entries - removed; i < code_entries; i++) { | 11793 for (int i = code_entries - removed; i < code_entries; i++) { |
| (...skipping 3715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15485 | 15509 |
| 15486 | 15510 |
| 15487 | 15511 |
| 15488 template<typename Shape, typename Key> | 15512 template<typename Shape, typename Key> |
| 15489 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( | 15513 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( |
| 15490 PropertyAttributes filter) { | 15514 PropertyAttributes filter) { |
| 15491 int capacity = HashTable<Shape, Key>::Capacity(); | 15515 int capacity = HashTable<Shape, Key>::Capacity(); |
| 15492 int result = 0; | 15516 int result = 0; |
| 15493 for (int i = 0; i < capacity; i++) { | 15517 for (int i = 0; i < capacity; i++) { |
| 15494 Object* k = HashTable<Shape, Key>::KeyAt(i); | 15518 Object* k = HashTable<Shape, Key>::KeyAt(i); |
| 15495 if (HashTable<Shape, Key>::IsKey(k) && !FilterKey(k, filter)) { | 15519 if (HashTable<Shape, Key>::IsKey(k) && |
| 15520 !FilterKey(k, filter)) { |
| 15496 PropertyDetails details = DetailsAt(i); | 15521 PropertyDetails details = DetailsAt(i); |
| 15497 if (details.IsDeleted()) continue; | 15522 if (details.IsDeleted()) continue; |
| 15498 PropertyAttributes attr = details.attributes(); | 15523 PropertyAttributes attr = details.attributes(); |
| 15499 if ((attr & filter) == 0) result++; | 15524 if ((attr & filter) == 0) result++; |
| 15500 } | 15525 } |
| 15501 } | 15526 } |
| 15502 return result; | 15527 return result; |
| 15503 } | 15528 } |
| 15504 | 15529 |
| 15505 | 15530 |
| 15506 template<typename Shape, typename Key> | 15531 template<typename Shape, typename Key> |
| 15507 int Dictionary<Shape, Key>::NumberOfEnumElements() { | 15532 int Dictionary<Shape, Key>::NumberOfEnumElements() { |
| 15508 return NumberOfElementsFilterAttributes( | 15533 return NumberOfElementsFilterAttributes( |
| 15509 static_cast<PropertyAttributes>(DONT_ENUM)); | 15534 static_cast<PropertyAttributes>(DONT_ENUM)); |
| 15510 } | 15535 } |
| 15511 | 15536 |
| 15512 | 15537 |
| 15513 template<typename Shape, typename Key> | 15538 template<typename Shape, typename Key> |
| 15514 void Dictionary<Shape, Key>::CopyKeysTo( | 15539 void Dictionary<Shape, Key>::CopyKeysTo( |
| 15515 FixedArray* storage, | 15540 FixedArray* storage, |
| 15516 PropertyAttributes filter, | 15541 PropertyAttributes filter, |
| 15517 typename Dictionary<Shape, Key>::SortMode sort_mode) { | 15542 typename Dictionary<Shape, Key>::SortMode sort_mode) { |
| 15518 ASSERT(storage->length() >= NumberOfElementsFilterAttributes(filter)); | 15543 ASSERT(storage->length() >= NumberOfEnumElements()); |
| 15519 int capacity = HashTable<Shape, Key>::Capacity(); | 15544 int capacity = HashTable<Shape, Key>::Capacity(); |
| 15520 int index = 0; | 15545 int index = 0; |
| 15521 for (int i = 0; i < capacity; i++) { | 15546 for (int i = 0; i < capacity; i++) { |
| 15522 Object* k = HashTable<Shape, Key>::KeyAt(i); | 15547 Object* k = HashTable<Shape, Key>::KeyAt(i); |
| 15523 if (HashTable<Shape, Key>::IsKey(k) && !FilterKey(k, filter)) { | 15548 if (HashTable<Shape, Key>::IsKey(k)) { |
| 15524 PropertyDetails details = DetailsAt(i); | 15549 PropertyDetails details = DetailsAt(i); |
| 15525 if (details.IsDeleted()) continue; | 15550 if (details.IsDeleted()) continue; |
| 15526 PropertyAttributes attr = details.attributes(); | 15551 PropertyAttributes attr = details.attributes(); |
| 15527 if ((attr & filter) == 0) storage->set(index++, k); | 15552 if ((attr & filter) == 0) storage->set(index++, k); |
| 15528 } | 15553 } |
| 15529 } | 15554 } |
| 15530 if (sort_mode == Dictionary<Shape, Key>::SORTED) { | 15555 if (sort_mode == Dictionary<Shape, Key>::SORTED) { |
| 15531 storage->SortPairs(storage, index); | 15556 storage->SortPairs(storage, index); |
| 15532 } | 15557 } |
| 15533 ASSERT(storage->length() >= index); | 15558 ASSERT(storage->length() >= index); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15575 return storage; | 15600 return storage; |
| 15576 } | 15601 } |
| 15577 | 15602 |
| 15578 | 15603 |
| 15579 template<typename Shape, typename Key> | 15604 template<typename Shape, typename Key> |
| 15580 void Dictionary<Shape, Key>::CopyKeysTo( | 15605 void Dictionary<Shape, Key>::CopyKeysTo( |
| 15581 FixedArray* storage, | 15606 FixedArray* storage, |
| 15582 int index, | 15607 int index, |
| 15583 PropertyAttributes filter, | 15608 PropertyAttributes filter, |
| 15584 typename Dictionary<Shape, Key>::SortMode sort_mode) { | 15609 typename Dictionary<Shape, Key>::SortMode sort_mode) { |
| 15585 ASSERT(storage->length() >= NumberOfElementsFilterAttributes(filter)); | 15610 ASSERT(storage->length() >= NumberOfElementsFilterAttributes( |
| 15611 static_cast<PropertyAttributes>(NONE))); |
| 15586 int capacity = HashTable<Shape, Key>::Capacity(); | 15612 int capacity = HashTable<Shape, Key>::Capacity(); |
| 15587 for (int i = 0; i < capacity; i++) { | 15613 for (int i = 0; i < capacity; i++) { |
| 15588 Object* k = HashTable<Shape, Key>::KeyAt(i); | 15614 Object* k = HashTable<Shape, Key>::KeyAt(i); |
| 15589 if (HashTable<Shape, Key>::IsKey(k) && !FilterKey(k, filter)) { | 15615 if (HashTable<Shape, Key>::IsKey(k)) { |
| 15590 PropertyDetails details = DetailsAt(i); | 15616 PropertyDetails details = DetailsAt(i); |
| 15591 if (details.IsDeleted()) continue; | 15617 if (details.IsDeleted()) continue; |
| 15592 PropertyAttributes attr = details.attributes(); | 15618 PropertyAttributes attr = details.attributes(); |
| 15593 if ((attr & filter) == 0) storage->set(index++, k); | 15619 if ((attr & filter) == 0) storage->set(index++, k); |
| 15594 } | 15620 } |
| 15595 } | 15621 } |
| 15596 if (sort_mode == Dictionary<Shape, Key>::SORTED) { | 15622 if (sort_mode == Dictionary<Shape, Key>::SORTED) { |
| 15597 storage->SortPairs(storage, index); | 15623 storage->SortPairs(storage, index); |
| 15598 } | 15624 } |
| 15599 ASSERT(storage->length() >= index); | 15625 ASSERT(storage->length() >= index); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15701 if (IsKey(k)) { | 15727 if (IsKey(k)) { |
| 15702 Object* value = ValueAt(i); | 15728 Object* value = ValueAt(i); |
| 15703 Name* key; | 15729 Name* key; |
| 15704 if (k->IsSymbol()) { | 15730 if (k->IsSymbol()) { |
| 15705 key = Symbol::cast(k); | 15731 key = Symbol::cast(k); |
| 15706 } else { | 15732 } else { |
| 15707 // Ensure the key is a unique name before writing into the | 15733 // Ensure the key is a unique name before writing into the |
| 15708 // instance descriptor. | 15734 // instance descriptor. |
| 15709 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k)); | 15735 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k)); |
| 15710 if (!maybe_key->To(&key)) return maybe_key; | 15736 if (!maybe_key->To(&key)) return maybe_key; |
| 15711 if (key->Equals(heap->empty_string())) return this; | |
| 15712 } | 15737 } |
| 15713 | 15738 |
| 15714 PropertyDetails details = DetailsAt(i); | 15739 PropertyDetails details = DetailsAt(i); |
| 15715 int enumeration_index = details.dictionary_index(); | 15740 int enumeration_index = details.dictionary_index(); |
| 15716 PropertyType type = details.type(); | 15741 PropertyType type = details.type(); |
| 15717 | 15742 |
| 15718 if (value->IsJSFunction()) { | 15743 if (value->IsJSFunction()) { |
| 15719 ConstantDescriptor d(key, value, details.attributes()); | 15744 ConstantDescriptor d(key, value, details.attributes()); |
| 15720 descriptors->Set(enumeration_index - 1, &d, witness); | 15745 descriptors->Set(enumeration_index - 1, &d, witness); |
| 15721 } else if (type == NORMAL) { | 15746 } else if (type == NORMAL) { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16481 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16506 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16482 static const char* error_messages_[] = { | 16507 static const char* error_messages_[] = { |
| 16483 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16508 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16484 }; | 16509 }; |
| 16485 #undef ERROR_MESSAGES_TEXTS | 16510 #undef ERROR_MESSAGES_TEXTS |
| 16486 return error_messages_[reason]; | 16511 return error_messages_[reason]; |
| 16487 } | 16512 } |
| 16488 | 16513 |
| 16489 | 16514 |
| 16490 } } // namespace v8::internal | 16515 } } // namespace v8::internal |
| OLD | NEW |