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 14225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14236 } | 14236 } |
14237 | 14237 |
14238 | 14238 |
14239 PropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { | 14239 PropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { |
14240 ASSERT(!HasFastProperties()); | 14240 ASSERT(!HasFastProperties()); |
14241 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 14241 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
14242 return PropertyCell::cast(value); | 14242 return PropertyCell::cast(value); |
14243 } | 14243 } |
14244 | 14244 |
14245 | 14245 |
| 14246 // TODO(mstarzinger): Temporary wrapper until handlified. |
| 14247 static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict, |
| 14248 Handle<Name> name, |
| 14249 Handle<Object> value, |
| 14250 PropertyDetails details) { |
| 14251 CALL_HEAP_FUNCTION(dict->GetIsolate(), |
| 14252 dict->Add(*name, *value, details), |
| 14253 NameDictionary); |
| 14254 } |
| 14255 |
| 14256 |
14246 Handle<PropertyCell> GlobalObject::EnsurePropertyCell( | 14257 Handle<PropertyCell> GlobalObject::EnsurePropertyCell( |
14247 Handle<GlobalObject> global, | 14258 Handle<GlobalObject> global, |
14248 Handle<Name> name) { | 14259 Handle<Name> name) { |
14249 Isolate* isolate = global->GetIsolate(); | 14260 ASSERT(!global->HasFastProperties()); |
14250 CALL_HEAP_FUNCTION(isolate, | 14261 int entry = global->property_dictionary()->FindEntry(*name); |
14251 global->EnsurePropertyCell(*name), | |
14252 PropertyCell); | |
14253 } | |
14254 | |
14255 | |
14256 MaybeObject* GlobalObject::EnsurePropertyCell(Name* name) { | |
14257 ASSERT(!HasFastProperties()); | |
14258 int entry = property_dictionary()->FindEntry(name); | |
14259 if (entry == NameDictionary::kNotFound) { | 14262 if (entry == NameDictionary::kNotFound) { |
14260 Heap* heap = GetHeap(); | 14263 Isolate* isolate = global->GetIsolate(); |
14261 Object* cell; | 14264 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell( |
14262 { MaybeObject* maybe_cell = | 14265 isolate->factory()->the_hole_value()); |
14263 heap->AllocatePropertyCell(heap->the_hole_value()); | |
14264 if (!maybe_cell->ToObject(&cell)) return maybe_cell; | |
14265 } | |
14266 PropertyDetails details(NONE, NORMAL, 0); | 14266 PropertyDetails details(NONE, NORMAL, 0); |
14267 details = details.AsDeleted(); | 14267 details = details.AsDeleted(); |
14268 Object* dictionary; | 14268 Handle<NameDictionary> dictionary = NameDictionaryAdd( |
14269 { MaybeObject* maybe_dictionary = | 14269 handle(global->property_dictionary()), name, cell, details); |
14270 property_dictionary()->Add(name, cell, details); | 14270 global->set_properties(*dictionary); |
14271 if (!maybe_dictionary->ToObject(&dictionary)) return maybe_dictionary; | |
14272 } | |
14273 set_properties(NameDictionary::cast(dictionary)); | |
14274 return cell; | 14271 return cell; |
14275 } else { | 14272 } else { |
14276 Object* value = property_dictionary()->ValueAt(entry); | 14273 Object* value = global->property_dictionary()->ValueAt(entry); |
14277 ASSERT(value->IsPropertyCell()); | 14274 ASSERT(value->IsPropertyCell()); |
14278 return value; | 14275 return handle(PropertyCell::cast(value)); |
14279 } | 14276 } |
14280 } | 14277 } |
14281 | 14278 |
14282 | 14279 |
14283 MaybeObject* StringTable::LookupString(String* string, Object** s) { | 14280 MaybeObject* StringTable::LookupString(String* string, Object** s) { |
14284 InternalizedStringKey key(string); | 14281 InternalizedStringKey key(string); |
14285 return LookupKey(&key, s); | 14282 return LookupKey(&key, s); |
14286 } | 14283 } |
14287 | 14284 |
14288 | 14285 |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15821 | 15818 |
15822 void PropertyCell::AddDependentCode(Handle<Code> code) { | 15819 void PropertyCell::AddDependentCode(Handle<Code> code) { |
15823 Handle<DependentCode> codes = DependentCode::Insert( | 15820 Handle<DependentCode> codes = DependentCode::Insert( |
15824 Handle<DependentCode>(dependent_code()), | 15821 Handle<DependentCode>(dependent_code()), |
15825 DependentCode::kPropertyCellChangedGroup, code); | 15822 DependentCode::kPropertyCellChangedGroup, code); |
15826 if (*codes != dependent_code()) set_dependent_code(*codes); | 15823 if (*codes != dependent_code()) set_dependent_code(*codes); |
15827 } | 15824 } |
15828 | 15825 |
15829 | 15826 |
15830 } } // namespace v8::internal | 15827 } } // namespace v8::internal |
OLD | NEW |