| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return Failure::InternalError(); | 106 return Failure::InternalError(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 Object* Object::ToBoolean() { | 110 Object* Object::ToBoolean() { |
| 111 if (IsTrue()) return this; | 111 if (IsTrue()) return this; |
| 112 if (IsFalse()) return this; | 112 if (IsFalse()) return this; |
| 113 if (IsSmi()) { | 113 if (IsSmi()) { |
| 114 return Isolate::Current()->heap()->ToBoolean(Smi::cast(this)->value() != 0); | 114 return Isolate::Current()->heap()->ToBoolean(Smi::cast(this)->value() != 0); |
| 115 } | 115 } |
| 116 if (IsUndefined() || IsNull()) { | 116 HeapObject* heap_object = HeapObject::cast(this); |
| 117 return HeapObject::cast(this)->GetHeap()->false_value(); | 117 if (heap_object->IsUndefined() || heap_object->IsNull()) { |
| 118 return heap_object->GetHeap()->false_value(); |
| 118 } | 119 } |
| 119 // Undetectable object is false | 120 // Undetectable object is false |
| 120 if (IsUndetectableObject()) { | 121 if (heap_object->IsUndetectableObject()) { |
| 121 return HeapObject::cast(this)->GetHeap()->false_value(); | 122 return heap_object->GetHeap()->false_value(); |
| 122 } | 123 } |
| 123 if (IsString()) { | 124 if (heap_object->IsString()) { |
| 124 return HeapObject::cast(this)->GetHeap()->ToBoolean( | 125 return heap_object->GetHeap()->ToBoolean( |
| 125 String::cast(this)->length() != 0); | 126 String::cast(this)->length() != 0); |
| 126 } | 127 } |
| 127 if (IsHeapNumber()) { | 128 if (heap_object->IsHeapNumber()) { |
| 128 return HeapNumber::cast(this)->HeapNumberToBoolean(); | 129 return HeapNumber::cast(this)->HeapNumberToBoolean(); |
| 129 } | 130 } |
| 130 return Isolate::Current()->heap()->true_value(); | 131 return heap_object->GetHeap()->true_value(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 | 134 |
| 134 void Object::Lookup(String* name, LookupResult* result) { | 135 void Object::Lookup(String* name, LookupResult* result) { |
| 135 if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result); | |
| 136 Object* holder = NULL; | 136 Object* holder = NULL; |
| 137 if (IsString()) { | 137 if (IsSmi()) { |
| 138 Heap* heap = HeapObject::cast(this)->GetHeap(); | |
| 139 Context* global_context = heap->isolate()->context()->global_context(); | |
| 140 holder = global_context->string_function()->instance_prototype(); | |
| 141 } else if (IsNumber()) { | |
| 142 Heap* heap = Isolate::Current()->heap(); | 138 Heap* heap = Isolate::Current()->heap(); |
| 143 Context* global_context = heap->isolate()->context()->global_context(); | 139 Context* global_context = heap->isolate()->context()->global_context(); |
| 144 holder = global_context->number_function()->instance_prototype(); | 140 holder = global_context->number_function()->instance_prototype(); |
| 145 } else if (IsBoolean()) { | 141 } else { |
| 146 Heap* heap = HeapObject::cast(this)->GetHeap(); | 142 HeapObject* heap_object = HeapObject::cast(this); |
| 147 Context* global_context = heap->isolate()->context()->global_context(); | 143 if (heap_object->IsJSObject()) { |
| 148 holder = global_context->boolean_function()->instance_prototype(); | 144 return JSObject::cast(this)->Lookup(name, result); |
| 145 } |
| 146 Heap* heap = heap_object->GetHeap(); |
| 147 if (heap_object->IsString()) { |
| 148 Context* global_context = heap->isolate()->context()->global_context(); |
| 149 holder = global_context->string_function()->instance_prototype(); |
| 150 } else if (heap_object->IsHeapNumber()) { |
| 151 Context* global_context = heap->isolate()->context()->global_context(); |
| 152 holder = global_context->number_function()->instance_prototype(); |
| 153 } else if (heap_object->IsBoolean()) { |
| 154 Context* global_context = heap->isolate()->context()->global_context(); |
| 155 holder = global_context->boolean_function()->instance_prototype(); |
| 156 } |
| 149 } | 157 } |
| 150 ASSERT(holder != NULL); // Cannot handle null or undefined. | 158 ASSERT(holder != NULL); // Cannot handle null or undefined. |
| 151 JSObject::cast(holder)->Lookup(name, result); | 159 JSObject::cast(holder)->Lookup(name, result); |
| 152 } | 160 } |
| 153 | 161 |
| 154 | 162 |
| 155 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, | 163 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, |
| 156 String* name, | 164 String* name, |
| 157 PropertyAttributes* attributes) { | 165 PropertyAttributes* attributes) { |
| 158 LookupResult result; | 166 LookupResult result; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return *result; | 248 return *result; |
| 241 } | 249 } |
| 242 | 250 |
| 243 | 251 |
| 244 // Only deal with CALLBACKS and INTERCEPTOR | 252 // Only deal with CALLBACKS and INTERCEPTOR |
| 245 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( | 253 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( |
| 246 Object* receiver, | 254 Object* receiver, |
| 247 LookupResult* result, | 255 LookupResult* result, |
| 248 String* name, | 256 String* name, |
| 249 PropertyAttributes* attributes) { | 257 PropertyAttributes* attributes) { |
| 250 Heap* heap = name->GetHeap(); | |
| 251 if (result->IsProperty()) { | 258 if (result->IsProperty()) { |
| 252 switch (result->type()) { | 259 switch (result->type()) { |
| 253 case CALLBACKS: { | 260 case CALLBACKS: { |
| 254 // Only allow API accessors. | 261 // Only allow API accessors. |
| 255 Object* obj = result->GetCallbackObject(); | 262 Object* obj = result->GetCallbackObject(); |
| 256 if (obj->IsAccessorInfo()) { | 263 if (obj->IsAccessorInfo()) { |
| 257 AccessorInfo* info = AccessorInfo::cast(obj); | 264 AccessorInfo* info = AccessorInfo::cast(obj); |
| 258 if (info->all_can_read()) { | 265 if (info->all_can_read()) { |
| 259 *attributes = result->GetAttributes(); | 266 *attributes = result->GetAttributes(); |
| 260 return GetPropertyWithCallback(receiver, | 267 return GetPropertyWithCallback(receiver, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 299 } |
| 293 break; | 300 break; |
| 294 } | 301 } |
| 295 default: | 302 default: |
| 296 UNREACHABLE(); | 303 UNREACHABLE(); |
| 297 } | 304 } |
| 298 } | 305 } |
| 299 | 306 |
| 300 // No accessible property found. | 307 // No accessible property found. |
| 301 *attributes = ABSENT; | 308 *attributes = ABSENT; |
| 309 Heap* heap = name->GetHeap(); |
| 302 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET); | 310 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET); |
| 303 return heap->undefined_value(); | 311 return heap->undefined_value(); |
| 304 } | 312 } |
| 305 | 313 |
| 306 | 314 |
| 307 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( | 315 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| 308 Object* receiver, | 316 Object* receiver, |
| 309 LookupResult* result, | 317 LookupResult* result, |
| 310 String* name, | 318 String* name, |
| 311 bool continue_search) { | 319 bool continue_search) { |
| 312 Heap* heap = name->GetHeap(); | |
| 313 if (result->IsProperty()) { | 320 if (result->IsProperty()) { |
| 314 switch (result->type()) { | 321 switch (result->type()) { |
| 315 case CALLBACKS: { | 322 case CALLBACKS: { |
| 316 // Only allow API accessors. | 323 // Only allow API accessors. |
| 317 Object* obj = result->GetCallbackObject(); | 324 Object* obj = result->GetCallbackObject(); |
| 318 if (obj->IsAccessorInfo()) { | 325 if (obj->IsAccessorInfo()) { |
| 319 AccessorInfo* info = AccessorInfo::cast(obj); | 326 AccessorInfo* info = AccessorInfo::cast(obj); |
| 320 if (info->all_can_read()) { | 327 if (info->all_can_read()) { |
| 321 return result->GetAttributes(); | 328 return result->GetAttributes(); |
| 322 } | 329 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 continue_search); | 363 continue_search); |
| 357 } | 364 } |
| 358 break; | 365 break; |
| 359 } | 366 } |
| 360 | 367 |
| 361 default: | 368 default: |
| 362 UNREACHABLE(); | 369 UNREACHABLE(); |
| 363 } | 370 } |
| 364 } | 371 } |
| 365 | 372 |
| 366 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 373 GetHeap()->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 367 return ABSENT; | 374 return ABSENT; |
| 368 } | 375 } |
| 369 | 376 |
| 370 | 377 |
| 371 Object* JSObject::GetNormalizedProperty(LookupResult* result) { | 378 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
| 372 ASSERT(!HasFastProperties()); | 379 ASSERT(!HasFastProperties()); |
| 373 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 380 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 374 if (IsGlobalObject()) { | 381 if (IsGlobalObject()) { |
| 375 value = JSGlobalPropertyCell::cast(value)->value(); | 382 value = JSGlobalPropertyCell::cast(value)->value(); |
| 376 } | 383 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 390 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); | 397 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); |
| 391 } | 398 } |
| 392 return value; | 399 return value; |
| 393 } | 400 } |
| 394 | 401 |
| 395 | 402 |
| 396 MaybeObject* JSObject::SetNormalizedProperty(String* name, | 403 MaybeObject* JSObject::SetNormalizedProperty(String* name, |
| 397 Object* value, | 404 Object* value, |
| 398 PropertyDetails details) { | 405 PropertyDetails details) { |
| 399 ASSERT(!HasFastProperties()); | 406 ASSERT(!HasFastProperties()); |
| 400 Heap* heap = name->GetHeap(); | |
| 401 int entry = property_dictionary()->FindEntry(name); | 407 int entry = property_dictionary()->FindEntry(name); |
| 402 if (entry == StringDictionary::kNotFound) { | 408 if (entry == StringDictionary::kNotFound) { |
| 403 Object* store_value = value; | 409 Object* store_value = value; |
| 404 if (IsGlobalObject()) { | 410 if (IsGlobalObject()) { |
| 411 Heap* heap = name->GetHeap(); |
| 405 MaybeObject* maybe_store_value = | 412 MaybeObject* maybe_store_value = |
| 406 heap->AllocateJSGlobalPropertyCell(value); | 413 heap->AllocateJSGlobalPropertyCell(value); |
| 407 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 414 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
| 408 } | 415 } |
| 409 Object* dict; | 416 Object* dict; |
| 410 { MaybeObject* maybe_dict = | 417 { MaybeObject* maybe_dict = |
| 411 property_dictionary()->Add(name, store_value, details); | 418 property_dictionary()->Add(name, store_value, details); |
| 412 if (!maybe_dict->ToObject(&dict)) return maybe_dict; | 419 if (!maybe_dict->ToObject(&dict)) return maybe_dict; |
| 413 } | 420 } |
| 414 set_properties(StringDictionary::cast(dict)); | 421 set_properties(StringDictionary::cast(dict)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 426 property_dictionary()->DetailsAtPut(entry, details); | 433 property_dictionary()->DetailsAtPut(entry, details); |
| 427 } else { | 434 } else { |
| 428 property_dictionary()->SetEntry(entry, name, value, details); | 435 property_dictionary()->SetEntry(entry, name, value, details); |
| 429 } | 436 } |
| 430 return value; | 437 return value; |
| 431 } | 438 } |
| 432 | 439 |
| 433 | 440 |
| 434 MaybeObject* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) { | 441 MaybeObject* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) { |
| 435 ASSERT(!HasFastProperties()); | 442 ASSERT(!HasFastProperties()); |
| 436 Heap* heap = GetHeap(); | |
| 437 StringDictionary* dictionary = property_dictionary(); | 443 StringDictionary* dictionary = property_dictionary(); |
| 438 int entry = dictionary->FindEntry(name); | 444 int entry = dictionary->FindEntry(name); |
| 439 if (entry != StringDictionary::kNotFound) { | 445 if (entry != StringDictionary::kNotFound) { |
| 440 // If we have a global object set the cell to the hole. | 446 // If we have a global object set the cell to the hole. |
| 441 if (IsGlobalObject()) { | 447 if (IsGlobalObject()) { |
| 442 PropertyDetails details = dictionary->DetailsAt(entry); | 448 PropertyDetails details = dictionary->DetailsAt(entry); |
| 443 if (details.IsDontDelete()) { | 449 if (details.IsDontDelete()) { |
| 444 if (mode != FORCE_DELETION) return heap->false_value(); | 450 if (mode != FORCE_DELETION) return GetHeap()->false_value(); |
| 445 // When forced to delete global properties, we have to make a | 451 // When forced to delete global properties, we have to make a |
| 446 // map change to invalidate any ICs that think they can load | 452 // map change to invalidate any ICs that think they can load |
| 447 // from the DontDelete cell without checking if it contains | 453 // from the DontDelete cell without checking if it contains |
| 448 // the hole value. | 454 // the hole value. |
| 449 Object* new_map; | 455 Object* new_map; |
| 450 { MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); | 456 { MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); |
| 451 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 457 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
| 452 } | 458 } |
| 453 set_map(Map::cast(new_map)); | 459 set_map(Map::cast(new_map)); |
| 454 } | 460 } |
| 455 JSGlobalPropertyCell* cell = | 461 JSGlobalPropertyCell* cell = |
| 456 JSGlobalPropertyCell::cast(dictionary->ValueAt(entry)); | 462 JSGlobalPropertyCell::cast(dictionary->ValueAt(entry)); |
| 457 cell->set_value(heap->the_hole_value()); | 463 cell->set_value(cell->heap()->the_hole_value()); |
| 458 dictionary->DetailsAtPut(entry, details.AsDeleted()); | 464 dictionary->DetailsAtPut(entry, details.AsDeleted()); |
| 459 } else { | 465 } else { |
| 460 return dictionary->DeleteProperty(entry, mode); | 466 return dictionary->DeleteProperty(entry, mode); |
| 461 } | 467 } |
| 462 } | 468 } |
| 463 return heap->true_value(); | 469 return GetHeap()->true_value(); |
| 464 } | 470 } |
| 465 | 471 |
| 466 | 472 |
| 467 bool JSObject::IsDirty() { | 473 bool JSObject::IsDirty() { |
| 468 Object* cons_obj = map()->constructor(); | 474 Object* cons_obj = map()->constructor(); |
| 469 if (!cons_obj->IsJSFunction()) | 475 if (!cons_obj->IsJSFunction()) |
| 470 return true; | 476 return true; |
| 471 JSFunction* fun = JSFunction::cast(cons_obj); | 477 JSFunction* fun = JSFunction::cast(cons_obj); |
| 472 if (!fun->shared()->IsApiFunction()) | 478 if (!fun->shared()->IsApiFunction()) |
| 473 return true; | 479 return true; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 return holder->GetPropertyWithInterceptor(recvr, name, attributes); | 549 return holder->GetPropertyWithInterceptor(recvr, name, attributes); |
| 544 } | 550 } |
| 545 default: | 551 default: |
| 546 UNREACHABLE(); | 552 UNREACHABLE(); |
| 547 return NULL; | 553 return NULL; |
| 548 } | 554 } |
| 549 } | 555 } |
| 550 | 556 |
| 551 | 557 |
| 552 MaybeObject* Object::GetElementWithReceiver(Object* receiver, uint32_t index) { | 558 MaybeObject* Object::GetElementWithReceiver(Object* receiver, uint32_t index) { |
| 553 if (IsJSObject()) { | 559 Object* holder = NULL; |
| 554 return JSObject::cast(this)->GetElementWithReceiver(receiver, index); | 560 if (IsSmi()) { |
| 555 } | 561 Context* global_context = Isolate::Current()->context()->global_context(); |
| 562 holder = global_context->number_function()->instance_prototype(); |
| 563 } else { |
| 564 HeapObject* heap_object = HeapObject::cast(this); |
| 556 | 565 |
| 557 Object* holder = NULL; | 566 if (heap_object->IsJSObject()) { |
| 558 Context* global_context = Isolate::Current()->context()->global_context(); | 567 return JSObject::cast(this)->GetElementWithReceiver(receiver, index); |
| 559 if (IsString()) { | 568 } |
| 560 holder = global_context->string_function()->instance_prototype(); | 569 Heap* heap = heap_object->GetHeap(); |
| 561 } else if (IsNumber()) { | 570 Isolate* isolate = heap->isolate(); |
| 562 holder = global_context->number_function()->instance_prototype(); | 571 |
| 563 } else if (IsBoolean()) { | 572 Context* global_context = isolate->context()->global_context(); |
| 564 holder = global_context->boolean_function()->instance_prototype(); | 573 if (heap_object->IsString()) { |
| 565 } else { | 574 holder = global_context->string_function()->instance_prototype(); |
| 566 // Undefined and null have no indexed properties. | 575 } else if (heap_object->IsHeapNumber()) { |
| 567 ASSERT(IsUndefined() || IsNull()); | 576 holder = global_context->number_function()->instance_prototype(); |
| 568 return HEAP->undefined_value(); | 577 } else if (heap_object->IsBoolean()) { |
| 578 holder = global_context->boolean_function()->instance_prototype(); |
| 579 } else { |
| 580 // Undefined and null have no indexed properties. |
| 581 ASSERT(heap_object->IsUndefined() || heap_object->IsNull()); |
| 582 return heap->undefined_value(); |
| 583 } |
| 569 } | 584 } |
| 570 | 585 |
| 571 return JSObject::cast(holder)->GetElementWithReceiver(receiver, index); | 586 return JSObject::cast(holder)->GetElementWithReceiver(receiver, index); |
| 572 } | 587 } |
| 573 | 588 |
| 574 | 589 |
| 575 Object* Object::GetPrototype() { | 590 Object* Object::GetPrototype() { |
| 591 if (IsSmi()) { |
| 592 Heap* heap = Isolate::Current()->heap(); |
| 593 Context* context = heap->isolate()->context()->global_context(); |
| 594 return context->number_function()->instance_prototype(); |
| 595 } |
| 596 |
| 597 HeapObject* heap_object = HeapObject::cast(this); |
| 598 |
| 576 // The object is either a number, a string, a boolean, or a real JS object. | 599 // The object is either a number, a string, a boolean, or a real JS object. |
| 577 if (IsJSObject()) return JSObject::cast(this)->map()->prototype(); | 600 if (heap_object->IsJSObject()) { |
| 578 Heap* heap = Isolate::Current()->heap(); | 601 return JSObject::cast(this)->map()->prototype(); |
| 602 } |
| 603 Heap* heap = heap_object->GetHeap(); |
| 579 Context* context = heap->isolate()->context()->global_context(); | 604 Context* context = heap->isolate()->context()->global_context(); |
| 580 | 605 |
| 581 if (IsNumber()) return context->number_function()->instance_prototype(); | 606 if (heap_object->IsHeapNumber()) { |
| 582 if (IsString()) return context->string_function()->instance_prototype(); | 607 return context->number_function()->instance_prototype(); |
| 583 if (IsBoolean()) { | 608 } |
| 609 if (heap_object->IsString()) { |
| 610 return context->string_function()->instance_prototype(); |
| 611 } |
| 612 if (heap_object->IsBoolean()) { |
| 584 return context->boolean_function()->instance_prototype(); | 613 return context->boolean_function()->instance_prototype(); |
| 585 } else { | 614 } else { |
| 586 return heap->null_value(); | 615 return heap->null_value(); |
| 587 } | 616 } |
| 588 } | 617 } |
| 589 | 618 |
| 590 | 619 |
| 591 void Object::ShortPrint(FILE* out) { | 620 void Object::ShortPrint(FILE* out) { |
| 592 HeapStringAllocator allocator; | 621 HeapStringAllocator allocator; |
| 593 StringStream accumulator(&allocator); | 622 StringStream accumulator(&allocator); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 } | 930 } |
| 902 } | 931 } |
| 903 if (!printed) { | 932 if (!printed) { |
| 904 accumulator->Add("<JS Function>"); | 933 accumulator->Add("<JS Function>"); |
| 905 } | 934 } |
| 906 break; | 935 break; |
| 907 } | 936 } |
| 908 // All other JSObjects are rather similar to each other (JSObject, | 937 // All other JSObjects are rather similar to each other (JSObject, |
| 909 // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue). | 938 // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue). |
| 910 default: { | 939 default: { |
| 911 Heap* heap = GetHeap(); | 940 Map* map_of_this = map(); |
| 912 Object* constructor = map()->constructor(); | 941 Heap* heap = map_of_this->heap(); |
| 942 Object* constructor = map_of_this->constructor(); |
| 913 bool printed = false; | 943 bool printed = false; |
| 914 if (constructor->IsHeapObject() && | 944 if (constructor->IsHeapObject() && |
| 915 !heap->Contains(HeapObject::cast(constructor))) { | 945 !heap->Contains(HeapObject::cast(constructor))) { |
| 916 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); | 946 accumulator->Add("!!!INVALID CONSTRUCTOR!!!"); |
| 917 } else { | 947 } else { |
| 918 bool global_object = IsJSGlobalProxy(); | 948 bool global_object = IsJSGlobalProxy(); |
| 919 if (constructor->IsJSFunction()) { | 949 if (constructor->IsJSFunction()) { |
| 920 if (!heap->Contains(JSFunction::cast(constructor)->shared())) { | 950 if (!heap->Contains(JSFunction::cast(constructor)->shared())) { |
| 921 accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!"); | 951 accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!"); |
| 922 } else { | 952 } else { |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 new_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors)); | 1373 new_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors)); |
| 1344 set_map(new_map); | 1374 set_map(new_map); |
| 1345 return FastPropertyAtPut(index, value); | 1375 return FastPropertyAtPut(index, value); |
| 1346 } | 1376 } |
| 1347 | 1377 |
| 1348 | 1378 |
| 1349 MaybeObject* JSObject::AddConstantFunctionProperty( | 1379 MaybeObject* JSObject::AddConstantFunctionProperty( |
| 1350 String* name, | 1380 String* name, |
| 1351 JSFunction* function, | 1381 JSFunction* function, |
| 1352 PropertyAttributes attributes) { | 1382 PropertyAttributes attributes) { |
| 1353 Heap* heap = GetHeap(); | 1383 ASSERT(!GetHeap()->InNewSpace(function)); |
| 1354 ASSERT(!heap->InNewSpace(function)); | |
| 1355 | 1384 |
| 1356 // Allocate new instance descriptors with (name, function) added | 1385 // Allocate new instance descriptors with (name, function) added |
| 1357 ConstantFunctionDescriptor d(name, function, attributes); | 1386 ConstantFunctionDescriptor d(name, function, attributes); |
| 1358 Object* new_descriptors; | 1387 Object* new_descriptors; |
| 1359 { MaybeObject* maybe_new_descriptors = | 1388 { MaybeObject* maybe_new_descriptors = |
| 1360 map()->instance_descriptors()->CopyInsert(&d, REMOVE_TRANSITIONS); | 1389 map()->instance_descriptors()->CopyInsert(&d, REMOVE_TRANSITIONS); |
| 1361 if (!maybe_new_descriptors->ToObject(&new_descriptors)) { | 1390 if (!maybe_new_descriptors->ToObject(&new_descriptors)) { |
| 1362 return maybe_new_descriptors; | 1391 return maybe_new_descriptors; |
| 1363 } | 1392 } |
| 1364 } | 1393 } |
| 1365 | 1394 |
| 1366 // Allocate a new map for the object. | 1395 // Allocate a new map for the object. |
| 1367 Object* new_map; | 1396 Object* new_map; |
| 1368 { MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); | 1397 { MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); |
| 1369 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1398 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
| 1370 } | 1399 } |
| 1371 | 1400 |
| 1372 DescriptorArray* descriptors = DescriptorArray::cast(new_descriptors); | 1401 DescriptorArray* descriptors = DescriptorArray::cast(new_descriptors); |
| 1373 Map::cast(new_map)->set_instance_descriptors(descriptors); | 1402 Map::cast(new_map)->set_instance_descriptors(descriptors); |
| 1374 Map* old_map = map(); | 1403 Map* old_map = map(); |
| 1375 set_map(Map::cast(new_map)); | 1404 set_map(Map::cast(new_map)); |
| 1376 | 1405 |
| 1377 // If the old map is the global object map (from new Object()), | 1406 // If the old map is the global object map (from new Object()), |
| 1378 // then transitions are not added to it, so we are done. | 1407 // then transitions are not added to it, so we are done. |
| 1408 Heap* heap = old_map->heap(); |
| 1379 if (old_map == heap->isolate()->context()->global_context()-> | 1409 if (old_map == heap->isolate()->context()->global_context()-> |
| 1380 object_function()->map()) { | 1410 object_function()->map()) { |
| 1381 return function; | 1411 return function; |
| 1382 } | 1412 } |
| 1383 | 1413 |
| 1384 // Do not add CONSTANT_TRANSITIONS to global objects | 1414 // Do not add CONSTANT_TRANSITIONS to global objects |
| 1385 if (IsGlobalObject()) { | 1415 if (IsGlobalObject()) { |
| 1386 return function; | 1416 return function; |
| 1387 } | 1417 } |
| 1388 | 1418 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1405 | 1435 |
| 1406 return function; | 1436 return function; |
| 1407 } | 1437 } |
| 1408 | 1438 |
| 1409 | 1439 |
| 1410 // Add property in slow mode | 1440 // Add property in slow mode |
| 1411 MaybeObject* JSObject::AddSlowProperty(String* name, | 1441 MaybeObject* JSObject::AddSlowProperty(String* name, |
| 1412 Object* value, | 1442 Object* value, |
| 1413 PropertyAttributes attributes) { | 1443 PropertyAttributes attributes) { |
| 1414 ASSERT(!HasFastProperties()); | 1444 ASSERT(!HasFastProperties()); |
| 1415 Heap* heap = GetHeap(); | |
| 1416 StringDictionary* dict = property_dictionary(); | 1445 StringDictionary* dict = property_dictionary(); |
| 1417 Object* store_value = value; | 1446 Object* store_value = value; |
| 1418 if (IsGlobalObject()) { | 1447 if (IsGlobalObject()) { |
| 1419 // In case name is an orphaned property reuse the cell. | 1448 // In case name is an orphaned property reuse the cell. |
| 1420 int entry = dict->FindEntry(name); | 1449 int entry = dict->FindEntry(name); |
| 1421 if (entry != StringDictionary::kNotFound) { | 1450 if (entry != StringDictionary::kNotFound) { |
| 1422 store_value = dict->ValueAt(entry); | 1451 store_value = dict->ValueAt(entry); |
| 1423 JSGlobalPropertyCell::cast(store_value)->set_value(value); | 1452 JSGlobalPropertyCell::cast(store_value)->set_value(value); |
| 1424 // Assign an enumeration index to the property and update | 1453 // Assign an enumeration index to the property and update |
| 1425 // SetNextEnumerationIndex. | 1454 // SetNextEnumerationIndex. |
| 1426 int index = dict->NextEnumerationIndex(); | 1455 int index = dict->NextEnumerationIndex(); |
| 1427 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); | 1456 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); |
| 1428 dict->SetNextEnumerationIndex(index + 1); | 1457 dict->SetNextEnumerationIndex(index + 1); |
| 1429 dict->SetEntry(entry, name, store_value, details); | 1458 dict->SetEntry(entry, name, store_value, details); |
| 1430 return value; | 1459 return value; |
| 1431 } | 1460 } |
| 1461 Heap* heap = GetHeap(); |
| 1432 { MaybeObject* maybe_store_value = | 1462 { MaybeObject* maybe_store_value = |
| 1433 heap->AllocateJSGlobalPropertyCell(value); | 1463 heap->AllocateJSGlobalPropertyCell(value); |
| 1434 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 1464 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
| 1435 } | 1465 } |
| 1436 JSGlobalPropertyCell::cast(store_value)->set_value(value); | 1466 JSGlobalPropertyCell::cast(store_value)->set_value(value); |
| 1437 } | 1467 } |
| 1438 PropertyDetails details = PropertyDetails(attributes, NORMAL); | 1468 PropertyDetails details = PropertyDetails(attributes, NORMAL); |
| 1439 Object* result; | 1469 Object* result; |
| 1440 { MaybeObject* maybe_result = dict->Add(name, store_value, details); | 1470 { MaybeObject* maybe_result = dict->Add(name, store_value, details); |
| 1441 if (!maybe_result->ToObject(&result)) return maybe_result; | 1471 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1442 } | 1472 } |
| 1443 if (dict != result) set_properties(StringDictionary::cast(result)); | 1473 if (dict != result) set_properties(StringDictionary::cast(result)); |
| 1444 return value; | 1474 return value; |
| 1445 } | 1475 } |
| 1446 | 1476 |
| 1447 | 1477 |
| 1448 MaybeObject* JSObject::AddProperty(String* name, | 1478 MaybeObject* JSObject::AddProperty(String* name, |
| 1449 Object* value, | 1479 Object* value, |
| 1450 PropertyAttributes attributes, | 1480 PropertyAttributes attributes, |
| 1451 StrictModeFlag strict_mode) { | 1481 StrictModeFlag strict_mode) { |
| 1452 ASSERT(!IsJSGlobalProxy()); | 1482 ASSERT(!IsJSGlobalProxy()); |
| 1453 Heap* heap = GetHeap(); | 1483 Map* map_of_this = map(); |
| 1454 if (!map()->is_extensible()) { | 1484 Heap* heap = map_of_this->heap(); |
| 1485 if (!map_of_this->is_extensible()) { |
| 1455 if (strict_mode == kNonStrictMode) { | 1486 if (strict_mode == kNonStrictMode) { |
| 1456 return heap->undefined_value(); | 1487 return heap->undefined_value(); |
| 1457 } else { | 1488 } else { |
| 1458 Handle<Object> args[1] = {Handle<String>(name)}; | 1489 Handle<Object> args[1] = {Handle<String>(name)}; |
| 1459 return heap->isolate()->Throw( | 1490 return heap->isolate()->Throw( |
| 1460 *FACTORY->NewTypeError("object_not_extensible", | 1491 *FACTORY->NewTypeError("object_not_extensible", |
| 1461 HandleVector(args, 1))); | 1492 HandleVector(args, 1))); |
| 1462 } | 1493 } |
| 1463 } | 1494 } |
| 1464 if (HasFastProperties()) { | 1495 if (HasFastProperties()) { |
| 1465 // Ensure the descriptor array does not get too big. | 1496 // Ensure the descriptor array does not get too big. |
| 1466 if (map()->instance_descriptors()->number_of_descriptors() < | 1497 if (map_of_this->instance_descriptors()->number_of_descriptors() < |
| 1467 DescriptorArray::kMaxNumberOfDescriptors) { | 1498 DescriptorArray::kMaxNumberOfDescriptors) { |
| 1468 if (value->IsJSFunction() && !heap->InNewSpace(value)) { | 1499 if (value->IsJSFunction() && !heap->InNewSpace(value)) { |
| 1469 return AddConstantFunctionProperty(name, | 1500 return AddConstantFunctionProperty(name, |
| 1470 JSFunction::cast(value), | 1501 JSFunction::cast(value), |
| 1471 attributes); | 1502 attributes); |
| 1472 } else { | 1503 } else { |
| 1473 return AddFastProperty(name, value, attributes); | 1504 return AddFastProperty(name, value, attributes); |
| 1474 } | 1505 } |
| 1475 } else { | 1506 } else { |
| 1476 // Normalize the object to prevent very large instance descriptors. | 1507 // Normalize the object to prevent very large instance descriptors. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 { MaybeObject* maybe_result = | 1561 { MaybeObject* maybe_result = |
| 1531 ConvertDescriptorToField(name, new_value, attributes); | 1562 ConvertDescriptorToField(name, new_value, attributes); |
| 1532 if (!maybe_result->ToObject(&result)) return maybe_result; | 1563 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1533 } | 1564 } |
| 1534 // If we get to this point we have succeeded - do not return failure | 1565 // If we get to this point we have succeeded - do not return failure |
| 1535 // after this point. Later stuff is optional. | 1566 // after this point. Later stuff is optional. |
| 1536 if (!HasFastProperties()) { | 1567 if (!HasFastProperties()) { |
| 1537 return result; | 1568 return result; |
| 1538 } | 1569 } |
| 1539 // Do not add transitions to the map of "new Object()". | 1570 // Do not add transitions to the map of "new Object()". |
| 1540 if (map() == GetHeap()->isolate()->context()->global_context()-> | 1571 if (map() == old_map->heap()->isolate()->context()->global_context()-> |
| 1541 object_function()->map()) { | 1572 object_function()->map()) { |
| 1542 return result; | 1573 return result; |
| 1543 } | 1574 } |
| 1544 | 1575 |
| 1545 MapTransitionDescriptor transition(name, | 1576 MapTransitionDescriptor transition(name, |
| 1546 map(), | 1577 map(), |
| 1547 attributes); | 1578 attributes); |
| 1548 Object* new_descriptors; | 1579 Object* new_descriptors; |
| 1549 { MaybeObject* maybe_new_descriptors = old_map->instance_descriptors()-> | 1580 { MaybeObject* maybe_new_descriptors = old_map->instance_descriptors()-> |
| 1550 CopyInsert(&transition, KEEP_TRANSITIONS); | 1581 CopyInsert(&transition, KEEP_TRANSITIONS); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 if (number != DescriptorArray::kNotFound) { | 1860 if (number != DescriptorArray::kNotFound) { |
| 1830 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1861 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
| 1831 } else { | 1862 } else { |
| 1832 result->NotFound(); | 1863 result->NotFound(); |
| 1833 } | 1864 } |
| 1834 } | 1865 } |
| 1835 | 1866 |
| 1836 | 1867 |
| 1837 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, | 1868 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, |
| 1838 bool safe_to_add_transition) { | 1869 bool safe_to_add_transition) { |
| 1870 Heap* current_heap = heap(); |
| 1839 DescriptorArray* descriptors = instance_descriptors(); | 1871 DescriptorArray* descriptors = instance_descriptors(); |
| 1840 String* external_array_sentinel_name = GetIsolate()->heap()->empty_symbol(); | 1872 String* external_array_sentinel_name = current_heap->empty_symbol(); |
| 1841 | 1873 |
| 1842 if (safe_to_add_transition) { | 1874 if (safe_to_add_transition) { |
| 1843 // It's only safe to manipulate the descriptor array if it would be | 1875 // It's only safe to manipulate the descriptor array if it would be |
| 1844 // safe to add a transition. | 1876 // safe to add a transition. |
| 1845 | 1877 |
| 1846 ASSERT(!is_shared()); // no transitions can be added to shared maps. | 1878 ASSERT(!is_shared()); // no transitions can be added to shared maps. |
| 1847 // Check if the external array transition already exists. | 1879 // Check if the external array transition already exists. |
| 1848 DescriptorLookupCache* cache = heap()->isolate()->descriptor_lookup_cache(); | 1880 DescriptorLookupCache* cache = |
| 1881 current_heap->isolate()->descriptor_lookup_cache(); |
| 1849 int index = cache->Lookup(descriptors, external_array_sentinel_name); | 1882 int index = cache->Lookup(descriptors, external_array_sentinel_name); |
| 1850 if (index == DescriptorLookupCache::kAbsent) { | 1883 if (index == DescriptorLookupCache::kAbsent) { |
| 1851 index = descriptors->Search(external_array_sentinel_name); | 1884 index = descriptors->Search(external_array_sentinel_name); |
| 1852 cache->Update(descriptors, | 1885 cache->Update(descriptors, |
| 1853 external_array_sentinel_name, | 1886 external_array_sentinel_name, |
| 1854 index); | 1887 index); |
| 1855 } | 1888 } |
| 1856 | 1889 |
| 1857 // If the transition already exists, check the type. If there is a match, | 1890 // If the transition already exists, check the type. If there is a match, |
| 1858 // return it. | 1891 // return it. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 } | 2005 } |
| 1973 result->NotFound(); | 2006 result->NotFound(); |
| 1974 } | 2007 } |
| 1975 | 2008 |
| 1976 | 2009 |
| 1977 // We only need to deal with CALLBACKS and INTERCEPTORS | 2010 // We only need to deal with CALLBACKS and INTERCEPTORS |
| 1978 MaybeObject* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result, | 2011 MaybeObject* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result, |
| 1979 String* name, | 2012 String* name, |
| 1980 Object* value, | 2013 Object* value, |
| 1981 bool check_prototype) { | 2014 bool check_prototype) { |
| 1982 Heap* heap = GetHeap(); | |
| 1983 if (check_prototype && !result->IsProperty()) { | 2015 if (check_prototype && !result->IsProperty()) { |
| 1984 LookupCallbackSetterInPrototypes(name, result); | 2016 LookupCallbackSetterInPrototypes(name, result); |
| 1985 } | 2017 } |
| 1986 | 2018 |
| 1987 if (result->IsProperty()) { | 2019 if (result->IsProperty()) { |
| 1988 if (!result->IsReadOnly()) { | 2020 if (!result->IsReadOnly()) { |
| 1989 switch (result->type()) { | 2021 switch (result->type()) { |
| 1990 case CALLBACKS: { | 2022 case CALLBACKS: { |
| 1991 Object* obj = result->GetCallbackObject(); | 2023 Object* obj = result->GetCallbackObject(); |
| 1992 if (obj->IsAccessorInfo()) { | 2024 if (obj->IsAccessorInfo()) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2013 } | 2045 } |
| 2014 default: { | 2046 default: { |
| 2015 break; | 2047 break; |
| 2016 } | 2048 } |
| 2017 } | 2049 } |
| 2018 } | 2050 } |
| 2019 } | 2051 } |
| 2020 | 2052 |
| 2021 HandleScope scope; | 2053 HandleScope scope; |
| 2022 Handle<Object> value_handle(value); | 2054 Handle<Object> value_handle(value); |
| 2055 Heap* heap = GetHeap(); |
| 2023 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET); | 2056 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET); |
| 2024 return *value_handle; | 2057 return *value_handle; |
| 2025 } | 2058 } |
| 2026 | 2059 |
| 2027 | 2060 |
| 2028 MaybeObject* JSObject::SetProperty(LookupResult* result, | 2061 MaybeObject* JSObject::SetProperty(LookupResult* result, |
| 2029 String* name, | 2062 String* name, |
| 2030 Object* value, | 2063 Object* value, |
| 2031 PropertyAttributes attributes, | 2064 PropertyAttributes attributes, |
| 2032 StrictModeFlag strict_mode) { | 2065 StrictModeFlag strict_mode) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 // Set a real local property, even if it is READ_ONLY. If the property is not | 2183 // Set a real local property, even if it is READ_ONLY. If the property is not |
| 2151 // present, add it with attributes NONE. This code is an exact clone of | 2184 // present, add it with attributes NONE. This code is an exact clone of |
| 2152 // SetProperty, with the check for IsReadOnly and the check for a | 2185 // SetProperty, with the check for IsReadOnly and the check for a |
| 2153 // callback setter removed. The two lines looking up the LookupResult | 2186 // callback setter removed. The two lines looking up the LookupResult |
| 2154 // result are also added. If one of the functions is changed, the other | 2187 // result are also added. If one of the functions is changed, the other |
| 2155 // should be. | 2188 // should be. |
| 2156 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( | 2189 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( |
| 2157 String* name, | 2190 String* name, |
| 2158 Object* value, | 2191 Object* value, |
| 2159 PropertyAttributes attributes) { | 2192 PropertyAttributes attributes) { |
| 2160 Heap* heap = GetHeap(); | |
| 2161 | 2193 |
| 2162 // Make sure that the top context does not change when doing callbacks or | 2194 // Make sure that the top context does not change when doing callbacks or |
| 2163 // interceptor calls. | 2195 // interceptor calls. |
| 2164 AssertNoContextChange ncc; | 2196 AssertNoContextChange ncc; |
| 2165 LookupResult result; | 2197 LookupResult result; |
| 2166 LocalLookup(name, &result); | 2198 LocalLookup(name, &result); |
| 2167 // Check access rights if needed. | 2199 // Check access rights if needed. |
| 2168 if (IsAccessCheckNeeded() | 2200 if (IsAccessCheckNeeded()) { |
| 2169 && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) { | 2201 Heap* heap = GetHeap(); |
| 2170 return SetPropertyWithFailedAccessCheck(&result, name, value, false); | 2202 if (!heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) { |
| 2203 return SetPropertyWithFailedAccessCheck(&result, name, value, false); |
| 2204 } |
| 2171 } | 2205 } |
| 2172 | 2206 |
| 2173 if (IsJSGlobalProxy()) { | 2207 if (IsJSGlobalProxy()) { |
| 2174 Object* proto = GetPrototype(); | 2208 Object* proto = GetPrototype(); |
| 2175 if (proto->IsNull()) return value; | 2209 if (proto->IsNull()) return value; |
| 2176 ASSERT(proto->IsJSGlobalObject()); | 2210 ASSERT(proto->IsJSGlobalObject()); |
| 2177 return JSObject::cast(proto)->SetLocalPropertyIgnoreAttributes( | 2211 return JSObject::cast(proto)->SetLocalPropertyIgnoreAttributes( |
| 2178 name, | 2212 name, |
| 2179 value, | 2213 value, |
| 2180 attributes); | 2214 attributes); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 LookupResult result; | 2345 LookupResult result; |
| 2312 Lookup(key, &result); | 2346 Lookup(key, &result); |
| 2313 return GetPropertyAttribute(receiver, &result, key, true); | 2347 return GetPropertyAttribute(receiver, &result, key, true); |
| 2314 } | 2348 } |
| 2315 | 2349 |
| 2316 | 2350 |
| 2317 PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver, | 2351 PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver, |
| 2318 LookupResult* result, | 2352 LookupResult* result, |
| 2319 String* name, | 2353 String* name, |
| 2320 bool continue_search) { | 2354 bool continue_search) { |
| 2321 Heap* heap = GetHeap(); | |
| 2322 // Check access rights if needed. | 2355 // Check access rights if needed. |
| 2323 if (IsAccessCheckNeeded() && | 2356 if (IsAccessCheckNeeded()) { |
| 2324 !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { | 2357 Heap* heap = GetHeap(); |
| 2325 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 2358 if (!heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { |
| 2326 result, | 2359 return GetPropertyAttributeWithFailedAccessCheck(receiver, |
| 2327 name, | 2360 result, |
| 2328 continue_search); | 2361 name, |
| 2362 continue_search); |
| 2363 } |
| 2329 } | 2364 } |
| 2330 if (result->IsProperty()) { | 2365 if (result->IsProperty()) { |
| 2331 switch (result->type()) { | 2366 switch (result->type()) { |
| 2332 case NORMAL: // fall through | 2367 case NORMAL: // fall through |
| 2333 case FIELD: | 2368 case FIELD: |
| 2334 case CONSTANT_FUNCTION: | 2369 case CONSTANT_FUNCTION: |
| 2335 case CALLBACKS: | 2370 case CALLBACKS: |
| 2336 return result->GetAttributes(); | 2371 return result->GetAttributes(); |
| 2337 case INTERCEPTOR: | 2372 case INTERCEPTOR: |
| 2338 return result->holder()-> | 2373 return result->holder()-> |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 | 2493 |
| 2459 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, | 2494 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, |
| 2460 int expected_additional_properties) { | 2495 int expected_additional_properties) { |
| 2461 if (!HasFastProperties()) return this; | 2496 if (!HasFastProperties()) return this; |
| 2462 | 2497 |
| 2463 // The global object is always normalized. | 2498 // The global object is always normalized. |
| 2464 ASSERT(!IsGlobalObject()); | 2499 ASSERT(!IsGlobalObject()); |
| 2465 // JSGlobalProxy must never be normalized | 2500 // JSGlobalProxy must never be normalized |
| 2466 ASSERT(!IsJSGlobalProxy()); | 2501 ASSERT(!IsJSGlobalProxy()); |
| 2467 | 2502 |
| 2468 Heap* heap = GetHeap(); | 2503 Map* map_of_this = map(); |
| 2469 | 2504 |
| 2470 // Allocate new content. | 2505 // Allocate new content. |
| 2471 int property_count = map()->NumberOfDescribedProperties(); | 2506 int property_count = map_of_this->NumberOfDescribedProperties(); |
| 2472 if (expected_additional_properties > 0) { | 2507 if (expected_additional_properties > 0) { |
| 2473 property_count += expected_additional_properties; | 2508 property_count += expected_additional_properties; |
| 2474 } else { | 2509 } else { |
| 2475 property_count += 2; // Make space for two more properties. | 2510 property_count += 2; // Make space for two more properties. |
| 2476 } | 2511 } |
| 2477 Object* obj; | 2512 Object* obj; |
| 2478 { MaybeObject* maybe_obj = | 2513 { MaybeObject* maybe_obj = |
| 2479 StringDictionary::Allocate(property_count); | 2514 StringDictionary::Allocate(property_count); |
| 2480 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2515 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2481 } | 2516 } |
| 2482 StringDictionary* dictionary = StringDictionary::cast(obj); | 2517 StringDictionary* dictionary = StringDictionary::cast(obj); |
| 2483 | 2518 |
| 2484 DescriptorArray* descs = map()->instance_descriptors(); | 2519 DescriptorArray* descs = map_of_this->instance_descriptors(); |
| 2485 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 2520 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 2486 PropertyDetails details = descs->GetDetails(i); | 2521 PropertyDetails details = descs->GetDetails(i); |
| 2487 switch (details.type()) { | 2522 switch (details.type()) { |
| 2488 case CONSTANT_FUNCTION: { | 2523 case CONSTANT_FUNCTION: { |
| 2489 PropertyDetails d = | 2524 PropertyDetails d = |
| 2490 PropertyDetails(details.attributes(), NORMAL, details.index()); | 2525 PropertyDetails(details.attributes(), NORMAL, details.index()); |
| 2491 Object* value = descs->GetConstantFunction(i); | 2526 Object* value = descs->GetConstantFunction(i); |
| 2492 Object* result; | 2527 Object* result; |
| 2493 { MaybeObject* maybe_result = | 2528 { MaybeObject* maybe_result = |
| 2494 dictionary->Add(descs->GetKey(i), value, d); | 2529 dictionary->Add(descs->GetKey(i), value, d); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2524 case MAP_TRANSITION: | 2559 case MAP_TRANSITION: |
| 2525 case CONSTANT_TRANSITION: | 2560 case CONSTANT_TRANSITION: |
| 2526 case NULL_DESCRIPTOR: | 2561 case NULL_DESCRIPTOR: |
| 2527 case INTERCEPTOR: | 2562 case INTERCEPTOR: |
| 2528 break; | 2563 break; |
| 2529 default: | 2564 default: |
| 2530 UNREACHABLE(); | 2565 UNREACHABLE(); |
| 2531 } | 2566 } |
| 2532 } | 2567 } |
| 2533 | 2568 |
| 2569 Heap* current_heap = map_of_this->heap(); |
| 2570 |
| 2534 // Copy the next enumeration index from instance descriptor. | 2571 // Copy the next enumeration index from instance descriptor. |
| 2535 int index = map()->instance_descriptors()->NextEnumerationIndex(); | 2572 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); |
| 2536 dictionary->SetNextEnumerationIndex(index); | 2573 dictionary->SetNextEnumerationIndex(index); |
| 2537 | 2574 |
| 2538 { MaybeObject* maybe_obj = heap->isolate()->context()->global_context()-> | 2575 { MaybeObject* maybe_obj = |
| 2576 current_heap->isolate()->context()->global_context()-> |
| 2539 normalized_map_cache()->Get(this, mode); | 2577 normalized_map_cache()->Get(this, mode); |
| 2540 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2578 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2541 } | 2579 } |
| 2542 Map* new_map = Map::cast(obj); | 2580 Map* new_map = Map::cast(obj); |
| 2543 | 2581 |
| 2544 // We have now successfully allocated all the necessary objects. | 2582 // We have now successfully allocated all the necessary objects. |
| 2545 // Changes can now be made with the guarantee that all of them take effect. | 2583 // Changes can now be made with the guarantee that all of them take effect. |
| 2546 | 2584 |
| 2547 // Resize the object in the heap if necessary. | 2585 // Resize the object in the heap if necessary. |
| 2548 int new_instance_size = new_map->instance_size(); | 2586 int new_instance_size = new_map->instance_size(); |
| 2549 int instance_size_delta = map()->instance_size() - new_instance_size; | 2587 int instance_size_delta = map_of_this->instance_size() - new_instance_size; |
| 2550 ASSERT(instance_size_delta >= 0); | 2588 ASSERT(instance_size_delta >= 0); |
| 2551 heap->CreateFillerObjectAt(this->address() + new_instance_size, | 2589 current_heap->CreateFillerObjectAt(this->address() + new_instance_size, |
| 2552 instance_size_delta); | 2590 instance_size_delta); |
| 2553 | 2591 |
| 2554 set_map(new_map); | 2592 set_map(new_map); |
| 2555 map()->set_instance_descriptors(heap->empty_descriptor_array()); | 2593 new_map->set_instance_descriptors(current_heap->empty_descriptor_array()); |
| 2556 | 2594 |
| 2557 set_properties(dictionary); | 2595 set_properties(dictionary); |
| 2558 | 2596 |
| 2559 heap->isolate()->counters()->props_to_dictionary()->Increment(); | 2597 current_heap->isolate()->counters()->props_to_dictionary()->Increment(); |
| 2560 | 2598 |
| 2561 #ifdef DEBUG | 2599 #ifdef DEBUG |
| 2562 if (FLAG_trace_normalization) { | 2600 if (FLAG_trace_normalization) { |
| 2563 PrintF("Object properties have been normalized:\n"); | 2601 PrintF("Object properties have been normalized:\n"); |
| 2564 Print(); | 2602 Print(); |
| 2565 } | 2603 } |
| 2566 #endif | 2604 #endif |
| 2567 return this; | 2605 return this; |
| 2568 } | 2606 } |
| 2569 | 2607 |
| 2570 | 2608 |
| 2571 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { | 2609 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { |
| 2572 if (HasFastProperties()) return this; | 2610 if (HasFastProperties()) return this; |
| 2573 ASSERT(!IsGlobalObject()); | 2611 ASSERT(!IsGlobalObject()); |
| 2574 return property_dictionary()-> | 2612 return property_dictionary()-> |
| 2575 TransformPropertiesToFastFor(this, unused_property_fields); | 2613 TransformPropertiesToFastFor(this, unused_property_fields); |
| 2576 } | 2614 } |
| 2577 | 2615 |
| 2578 | 2616 |
| 2579 MaybeObject* JSObject::NormalizeElements() { | 2617 MaybeObject* JSObject::NormalizeElements() { |
| 2580 ASSERT(!HasExternalArrayElements()); | 2618 ASSERT(!HasExternalArrayElements()); |
| 2581 // Find the backing store. | 2619 // Find the backing store. |
| 2582 FixedArray* original = FixedArray::cast(elements()); | 2620 FixedArray* original = FixedArray::cast(elements()); |
| 2621 Map* old_map = original->map(); |
| 2622 Heap* heap = old_map->heap(); |
| 2583 bool is_arguments = | 2623 bool is_arguments = |
| 2584 (original->map() == GetHeap()->non_strict_arguments_elements_map()); | 2624 (old_map == heap->non_strict_arguments_elements_map()); |
| 2585 if (is_arguments) { | 2625 if (is_arguments) { |
| 2586 original = FixedArray::cast(original->get(1)); | 2626 original = FixedArray::cast(original->get(1)); |
| 2587 } | 2627 } |
| 2588 if (original->IsDictionary()) return original; | 2628 if (original->IsDictionary()) return original; |
| 2589 | 2629 |
| 2590 ASSERT(HasFastElements() || HasFastArgumentsElements()); | 2630 ASSERT(HasFastElements() || HasFastArgumentsElements()); |
| 2591 // Compute the effective length and allocate a new backing store. | 2631 // Compute the effective length and allocate a new backing store. |
| 2592 int length = IsJSArray() | 2632 int length = IsJSArray() |
| 2593 ? Smi::cast(JSArray::cast(this)->length())->value() | 2633 ? Smi::cast(JSArray::cast(this)->length())->value() |
| 2594 : original->length(); | 2634 : original->length(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2611 } | 2651 } |
| 2612 } | 2652 } |
| 2613 | 2653 |
| 2614 // Switch to using the dictionary as the backing storage for elements. | 2654 // Switch to using the dictionary as the backing storage for elements. |
| 2615 if (is_arguments) { | 2655 if (is_arguments) { |
| 2616 FixedArray::cast(elements())->set(1, dictionary); | 2656 FixedArray::cast(elements())->set(1, dictionary); |
| 2617 } else { | 2657 } else { |
| 2618 // Set the new map first to satify the elements type assert in | 2658 // Set the new map first to satify the elements type assert in |
| 2619 // set_elements(). | 2659 // set_elements(). |
| 2620 Object* new_map; | 2660 Object* new_map; |
| 2621 MaybeObject* maybe = map()->GetSlowElementsMap(); | 2661 MaybeObject* maybe = old_map->GetSlowElementsMap(); |
| 2622 if (!maybe->ToObject(&new_map)) return maybe; | 2662 if (!maybe->ToObject(&new_map)) return maybe; |
| 2623 set_map(Map::cast(new_map)); | 2663 set_map(Map::cast(new_map)); |
| 2624 set_elements(dictionary); | 2664 set_elements(dictionary); |
| 2625 } | 2665 } |
| 2626 | 2666 |
| 2627 GetIsolate()->counters()->elements_to_dictionary()->Increment(); | 2667 heap->isolate()->counters()->elements_to_dictionary()->Increment(); |
| 2628 | 2668 |
| 2629 #ifdef DEBUG | 2669 #ifdef DEBUG |
| 2630 if (FLAG_trace_normalization) { | 2670 if (FLAG_trace_normalization) { |
| 2631 PrintF("Object elements have been normalized:\n"); | 2671 PrintF("Object elements have been normalized:\n"); |
| 2632 Print(); | 2672 Print(); |
| 2633 } | 2673 } |
| 2634 #endif | 2674 #endif |
| 2635 | 2675 |
| 2636 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); | 2676 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); |
| 2637 return dictionary; | 2677 return dictionary; |
| 2638 } | 2678 } |
| 2639 | 2679 |
| 2640 | 2680 |
| 2641 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name, | 2681 MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name, |
| 2642 DeleteMode mode) { | 2682 DeleteMode mode) { |
| 2643 // Check local property, ignore interceptor. | 2683 // Check local property, ignore interceptor. |
| 2644 Heap* heap = GetHeap(); | |
| 2645 LookupResult result; | 2684 LookupResult result; |
| 2646 LocalLookupRealNamedProperty(name, &result); | 2685 LocalLookupRealNamedProperty(name, &result); |
| 2647 if (!result.IsProperty()) return heap->true_value(); | 2686 if (!result.IsProperty()) return GetHeap()->true_value(); |
| 2648 | 2687 |
| 2649 // Normalize object if needed. | 2688 // Normalize object if needed. |
| 2650 Object* obj; | 2689 Object* obj; |
| 2651 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 2690 { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
| 2652 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2691 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2653 } | 2692 } |
| 2654 | 2693 |
| 2655 return DeleteNormalizedProperty(name, mode); | 2694 return DeleteNormalizedProperty(name, mode); |
| 2656 } | 2695 } |
| 2657 | 2696 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2683 } | 2722 } |
| 2684 MaybeObject* raw_result = | 2723 MaybeObject* raw_result = |
| 2685 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); | 2724 this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION); |
| 2686 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 2725 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 2687 return raw_result; | 2726 return raw_result; |
| 2688 } | 2727 } |
| 2689 | 2728 |
| 2690 | 2729 |
| 2691 MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index, | 2730 MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index, |
| 2692 DeleteMode mode) { | 2731 DeleteMode mode) { |
| 2693 Heap* heap = GetHeap(); | |
| 2694 ASSERT(!HasExternalArrayElements()); | 2732 ASSERT(!HasExternalArrayElements()); |
| 2695 // We don't have to handle strict mode deletion of non-configurable | 2733 // We don't have to handle strict mode deletion of non-configurable |
| 2696 // properties. | 2734 // properties. |
| 2697 ASSERT(mode != STRICT_DELETION); | 2735 ASSERT(mode != STRICT_DELETION); |
| 2698 switch (GetElementsKind()) { | 2736 switch (GetElementsKind()) { |
| 2699 case FAST_ELEMENTS: { | 2737 case FAST_ELEMENTS: { |
| 2700 return DeleteFastElement(index); | 2738 return DeleteFastElement(index); |
| 2701 } | 2739 } |
| 2702 case DICTIONARY_ELEMENTS: { | 2740 case DICTIONARY_ELEMENTS: { |
| 2703 NumberDictionary* dictionary = element_dictionary(); | 2741 NumberDictionary* dictionary = element_dictionary(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2714 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2752 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 2715 case EXTERNAL_SHORT_ELEMENTS: | 2753 case EXTERNAL_SHORT_ELEMENTS: |
| 2716 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2754 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 2717 case EXTERNAL_INT_ELEMENTS: | 2755 case EXTERNAL_INT_ELEMENTS: |
| 2718 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2756 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 2719 case EXTERNAL_FLOAT_ELEMENTS: | 2757 case EXTERNAL_FLOAT_ELEMENTS: |
| 2720 case EXTERNAL_PIXEL_ELEMENTS: | 2758 case EXTERNAL_PIXEL_ELEMENTS: |
| 2721 UNREACHABLE(); | 2759 UNREACHABLE(); |
| 2722 break; | 2760 break; |
| 2723 } | 2761 } |
| 2724 return heap->true_value(); | 2762 return GetHeap()->true_value(); |
| 2725 } | 2763 } |
| 2726 | 2764 |
| 2727 | 2765 |
| 2728 MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) { | 2766 MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) { |
| 2729 Isolate* isolate = GetIsolate(); | 2767 Isolate* isolate = GetIsolate(); |
| 2730 Heap* heap = isolate->heap(); | 2768 Heap* heap = isolate->heap(); |
| 2731 // Make sure that the top context does not change when doing | 2769 // Make sure that the top context does not change when doing |
| 2732 // callbacks or interceptor calls. | 2770 // callbacks or interceptor calls. |
| 2733 AssertNoContextChange ncc; | 2771 AssertNoContextChange ncc; |
| 2734 HandleScope scope(isolate); | 2772 HandleScope scope(isolate); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2949 } else { | 2987 } else { |
| 2950 Object* key = NumberDictionary::cast(elements)->SlowReverseLookup(object); | 2988 Object* key = NumberDictionary::cast(elements)->SlowReverseLookup(object); |
| 2951 if (!key->IsUndefined()) return true; | 2989 if (!key->IsUndefined()) return true; |
| 2952 } | 2990 } |
| 2953 return false; | 2991 return false; |
| 2954 } | 2992 } |
| 2955 | 2993 |
| 2956 | 2994 |
| 2957 // Check whether this object references another object. | 2995 // Check whether this object references another object. |
| 2958 bool JSObject::ReferencesObject(Object* obj) { | 2996 bool JSObject::ReferencesObject(Object* obj) { |
| 2959 Heap* heap = GetHeap(); | 2997 Map* map_of_this = map(); |
| 2998 Heap* heap = map_of_this->heap(); |
| 2960 AssertNoAllocation no_alloc; | 2999 AssertNoAllocation no_alloc; |
| 2961 | 3000 |
| 2962 // Is the object the constructor for this object? | 3001 // Is the object the constructor for this object? |
| 2963 if (map()->constructor() == obj) { | 3002 if (map_of_this->constructor() == obj) { |
| 2964 return true; | 3003 return true; |
| 2965 } | 3004 } |
| 2966 | 3005 |
| 2967 // Is the object the prototype for this object? | 3006 // Is the object the prototype for this object? |
| 2968 if (map()->prototype() == obj) { | 3007 if (map_of_this->prototype() == obj) { |
| 2969 return true; | 3008 return true; |
| 2970 } | 3009 } |
| 2971 | 3010 |
| 2972 // Check if the object is among the named properties. | 3011 // Check if the object is among the named properties. |
| 2973 Object* key = SlowReverseLookup(obj); | 3012 Object* key = SlowReverseLookup(obj); |
| 2974 if (!key->IsUndefined()) { | 3013 if (!key->IsUndefined()) { |
| 2975 return true; | 3014 return true; |
| 2976 } | 3015 } |
| 2977 | 3016 |
| 2978 // Check if the object is among the indexed properties. | 3017 // Check if the object is among the indexed properties. |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 } | 3645 } |
| 3607 } | 3646 } |
| 3608 } | 3647 } |
| 3609 } | 3648 } |
| 3610 } | 3649 } |
| 3611 return heap->undefined_value(); | 3650 return heap->undefined_value(); |
| 3612 } | 3651 } |
| 3613 | 3652 |
| 3614 | 3653 |
| 3615 Object* JSObject::SlowReverseLookup(Object* value) { | 3654 Object* JSObject::SlowReverseLookup(Object* value) { |
| 3616 Heap* heap = GetHeap(); | |
| 3617 if (HasFastProperties()) { | 3655 if (HasFastProperties()) { |
| 3618 DescriptorArray* descs = map()->instance_descriptors(); | 3656 DescriptorArray* descs = map()->instance_descriptors(); |
| 3619 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 3657 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 3620 if (descs->GetType(i) == FIELD) { | 3658 if (descs->GetType(i) == FIELD) { |
| 3621 if (FastPropertyAt(descs->GetFieldIndex(i)) == value) { | 3659 if (FastPropertyAt(descs->GetFieldIndex(i)) == value) { |
| 3622 return descs->GetKey(i); | 3660 return descs->GetKey(i); |
| 3623 } | 3661 } |
| 3624 } else if (descs->GetType(i) == CONSTANT_FUNCTION) { | 3662 } else if (descs->GetType(i) == CONSTANT_FUNCTION) { |
| 3625 if (descs->GetConstantFunction(i) == value) { | 3663 if (descs->GetConstantFunction(i) == value) { |
| 3626 return descs->GetKey(i); | 3664 return descs->GetKey(i); |
| 3627 } | 3665 } |
| 3628 } | 3666 } |
| 3629 } | 3667 } |
| 3630 return heap->undefined_value(); | 3668 return GetHeap()->undefined_value(); |
| 3631 } else { | 3669 } else { |
| 3632 return property_dictionary()->SlowReverseLookup(value); | 3670 return property_dictionary()->SlowReverseLookup(value); |
| 3633 } | 3671 } |
| 3634 } | 3672 } |
| 3635 | 3673 |
| 3636 | 3674 |
| 3637 MaybeObject* Map::CopyDropDescriptors() { | 3675 MaybeObject* Map::CopyDropDescriptors() { |
| 3638 Heap* heap = GetHeap(); | 3676 Heap* heap = GetHeap(); |
| 3639 Object* result; | 3677 Object* result; |
| 3640 { MaybeObject* maybe_result = | 3678 { MaybeObject* maybe_result = |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3724 } | 3762 } |
| 3725 cast(new_map)->set_instance_descriptors(DescriptorArray::cast(descriptors)); | 3763 cast(new_map)->set_instance_descriptors(DescriptorArray::cast(descriptors)); |
| 3726 return new_map; | 3764 return new_map; |
| 3727 } | 3765 } |
| 3728 | 3766 |
| 3729 | 3767 |
| 3730 MaybeObject* Map::UpdateCodeCache(String* name, Code* code) { | 3768 MaybeObject* Map::UpdateCodeCache(String* name, Code* code) { |
| 3731 // Allocate the code cache if not present. | 3769 // Allocate the code cache if not present. |
| 3732 if (code_cache()->IsFixedArray()) { | 3770 if (code_cache()->IsFixedArray()) { |
| 3733 Object* result; | 3771 Object* result; |
| 3734 { MaybeObject* maybe_result = GetHeap()->AllocateCodeCache(); | 3772 { MaybeObject* maybe_result = code->heap()->AllocateCodeCache(); |
| 3735 if (!maybe_result->ToObject(&result)) return maybe_result; | 3773 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 3736 } | 3774 } |
| 3737 set_code_cache(result); | 3775 set_code_cache(result); |
| 3738 } | 3776 } |
| 3739 | 3777 |
| 3740 // Update the code cache. | 3778 // Update the code cache. |
| 3741 return CodeCache::cast(code_cache())->Update(name, code); | 3779 return CodeCache::cast(code_cache())->Update(name, code); |
| 3742 } | 3780 } |
| 3743 | 3781 |
| 3744 | 3782 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3910 Object* CodeCache::Lookup(String* name, Code::Flags flags) { | 3948 Object* CodeCache::Lookup(String* name, Code::Flags flags) { |
| 3911 if (Code::ExtractTypeFromFlags(flags) == NORMAL) { | 3949 if (Code::ExtractTypeFromFlags(flags) == NORMAL) { |
| 3912 return LookupNormalTypeCache(name, flags); | 3950 return LookupNormalTypeCache(name, flags); |
| 3913 } else { | 3951 } else { |
| 3914 return LookupDefaultCache(name, flags); | 3952 return LookupDefaultCache(name, flags); |
| 3915 } | 3953 } |
| 3916 } | 3954 } |
| 3917 | 3955 |
| 3918 | 3956 |
| 3919 Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) { | 3957 Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) { |
| 3920 Heap* heap = GetHeap(); | |
| 3921 FixedArray* cache = default_cache(); | 3958 FixedArray* cache = default_cache(); |
| 3922 int length = cache->length(); | 3959 int length = cache->length(); |
| 3923 for (int i = 0; i < length; i += kCodeCacheEntrySize) { | 3960 for (int i = 0; i < length; i += kCodeCacheEntrySize) { |
| 3924 Object* key = cache->get(i + kCodeCacheEntryNameOffset); | 3961 Object* key = cache->get(i + kCodeCacheEntryNameOffset); |
| 3925 // Skip deleted elements. | 3962 // Skip deleted elements. |
| 3926 if (key->IsNull()) continue; | 3963 if (key->IsNull()) continue; |
| 3927 if (key->IsUndefined()) return key; | 3964 if (key->IsUndefined()) return key; |
| 3928 if (name->Equals(String::cast(key))) { | 3965 if (name->Equals(String::cast(key))) { |
| 3929 Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset)); | 3966 Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset)); |
| 3930 if (code->flags() == flags) { | 3967 if (code->flags() == flags) { |
| 3931 return code; | 3968 return code; |
| 3932 } | 3969 } |
| 3933 } | 3970 } |
| 3934 } | 3971 } |
| 3935 return heap->undefined_value(); | 3972 return GetHeap()->undefined_value(); |
| 3936 } | 3973 } |
| 3937 | 3974 |
| 3938 | 3975 |
| 3939 Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) { | 3976 Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) { |
| 3940 if (!normal_type_cache()->IsUndefined()) { | 3977 if (!normal_type_cache()->IsUndefined()) { |
| 3941 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 3978 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
| 3942 return cache->Lookup(name, flags); | 3979 return cache->Lookup(name, flags); |
| 3943 } else { | 3980 } else { |
| 3944 return GetHeap()->undefined_value(); | 3981 return GetHeap()->undefined_value(); |
| 3945 } | 3982 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4016 uint32_t HashForObject(Object* obj) { | 4053 uint32_t HashForObject(Object* obj) { |
| 4017 FixedArray* pair = FixedArray::cast(obj); | 4054 FixedArray* pair = FixedArray::cast(obj); |
| 4018 String* name = String::cast(pair->get(0)); | 4055 String* name = String::cast(pair->get(0)); |
| 4019 Code* code = Code::cast(pair->get(1)); | 4056 Code* code = Code::cast(pair->get(1)); |
| 4020 return NameFlagsHashHelper(name, code->flags()); | 4057 return NameFlagsHashHelper(name, code->flags()); |
| 4021 } | 4058 } |
| 4022 | 4059 |
| 4023 MUST_USE_RESULT MaybeObject* AsObject() { | 4060 MUST_USE_RESULT MaybeObject* AsObject() { |
| 4024 ASSERT(code_ != NULL); | 4061 ASSERT(code_ != NULL); |
| 4025 Object* obj; | 4062 Object* obj; |
| 4026 { MaybeObject* maybe_obj = code_->GetHeap()->AllocateFixedArray(2); | 4063 { MaybeObject* maybe_obj = code_->heap()->AllocateFixedArray(2); |
| 4027 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4064 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 4028 } | 4065 } |
| 4029 FixedArray* pair = FixedArray::cast(obj); | 4066 FixedArray* pair = FixedArray::cast(obj); |
| 4030 pair->set(0, name_); | 4067 pair->set(0, name_); |
| 4031 pair->set(1, code_); | 4068 pair->set(1, code_); |
| 4032 return pair; | 4069 return pair; |
| 4033 } | 4070 } |
| 4034 | 4071 |
| 4035 private: | 4072 private: |
| 4036 String* name_; | 4073 String* name_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4094 if (element->IsString() && | 4131 if (element->IsString() && |
| 4095 key->IsString() && String::cast(element)->Equals(String::cast(key))) { | 4132 key->IsString() && String::cast(element)->Equals(String::cast(key))) { |
| 4096 return true; | 4133 return true; |
| 4097 } | 4134 } |
| 4098 } | 4135 } |
| 4099 return false; | 4136 return false; |
| 4100 } | 4137 } |
| 4101 | 4138 |
| 4102 | 4139 |
| 4103 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 4140 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
| 4104 Heap* heap = GetHeap(); | |
| 4105 ASSERT(!array->HasExternalArrayElements()); | 4141 ASSERT(!array->HasExternalArrayElements()); |
| 4106 switch (array->GetElementsKind()) { | 4142 switch (array->GetElementsKind()) { |
| 4107 case JSObject::FAST_ELEMENTS: | 4143 case JSObject::FAST_ELEMENTS: |
| 4108 return UnionOfKeys(FixedArray::cast(array->elements())); | 4144 return UnionOfKeys(FixedArray::cast(array->elements())); |
| 4109 case JSObject::DICTIONARY_ELEMENTS: { | 4145 case JSObject::DICTIONARY_ELEMENTS: { |
| 4110 NumberDictionary* dict = array->element_dictionary(); | 4146 NumberDictionary* dict = array->element_dictionary(); |
| 4111 int size = dict->NumberOfElements(); | 4147 int size = dict->NumberOfElements(); |
| 4112 | 4148 |
| 4113 // Allocate a temporary fixed array. | 4149 // Allocate a temporary fixed array. |
| 4114 Object* object; | 4150 Object* object; |
| 4115 { MaybeObject* maybe_object = heap->AllocateFixedArray(size); | 4151 { MaybeObject* maybe_object = GetHeap()->AllocateFixedArray(size); |
| 4116 if (!maybe_object->ToObject(&object)) return maybe_object; | 4152 if (!maybe_object->ToObject(&object)) return maybe_object; |
| 4117 } | 4153 } |
| 4118 FixedArray* key_array = FixedArray::cast(object); | 4154 FixedArray* key_array = FixedArray::cast(object); |
| 4119 | 4155 |
| 4120 int capacity = dict->Capacity(); | 4156 int capacity = dict->Capacity(); |
| 4121 int pos = 0; | 4157 int pos = 0; |
| 4122 // Copy the elements from the JSArray to the temporary fixed array. | 4158 // Copy the elements from the JSArray to the temporary fixed array. |
| 4123 for (int i = 0; i < capacity; i++) { | 4159 for (int i = 0; i < capacity; i++) { |
| 4124 if (dict->IsKey(dict->KeyAt(i))) { | 4160 if (dict->IsKey(dict->KeyAt(i))) { |
| 4125 key_array->set(pos++, dict->ValueAt(i)); | 4161 key_array->set(pos++, dict->ValueAt(i)); |
| 4126 } | 4162 } |
| 4127 } | 4163 } |
| 4128 // Compute the union of this and the temporary fixed array. | 4164 // Compute the union of this and the temporary fixed array. |
| 4129 return UnionOfKeys(key_array); | 4165 return UnionOfKeys(key_array); |
| 4130 } | 4166 } |
| 4131 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: | 4167 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: |
| 4132 UNIMPLEMENTED(); | 4168 UNIMPLEMENTED(); |
| 4133 break; | 4169 break; |
| 4134 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 4170 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
| 4135 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 4171 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 4136 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 4172 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
| 4137 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 4173 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 4138 case JSObject::EXTERNAL_INT_ELEMENTS: | 4174 case JSObject::EXTERNAL_INT_ELEMENTS: |
| 4139 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 4175 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 4140 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 4176 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
| 4141 case JSObject::EXTERNAL_PIXEL_ELEMENTS: | 4177 case JSObject::EXTERNAL_PIXEL_ELEMENTS: |
| 4142 break; | 4178 break; |
| 4143 } | 4179 } |
| 4144 UNREACHABLE(); | 4180 UNREACHABLE(); |
| 4145 return heap->null_value(); // Failure case needs to "return" a value. | 4181 return GetHeap()->null_value(); // Failure case needs to "return" a value. |
| 4146 } | 4182 } |
| 4147 | 4183 |
| 4148 | 4184 |
| 4149 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { | 4185 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { |
| 4150 Heap* heap = GetHeap(); | |
| 4151 int len0 = length(); | 4186 int len0 = length(); |
| 4152 #ifdef DEBUG | 4187 #ifdef DEBUG |
| 4153 if (FLAG_enable_slow_asserts) { | 4188 if (FLAG_enable_slow_asserts) { |
| 4154 for (int i = 0; i < len0; i++) { | 4189 for (int i = 0; i < len0; i++) { |
| 4155 ASSERT(get(i)->IsString() || get(i)->IsNumber()); | 4190 ASSERT(get(i)->IsString() || get(i)->IsNumber()); |
| 4156 } | 4191 } |
| 4157 } | 4192 } |
| 4158 #endif | 4193 #endif |
| 4159 int len1 = other->length(); | 4194 int len1 = other->length(); |
| 4160 // Optimize if 'other' is empty. | 4195 // Optimize if 'other' is empty. |
| 4161 // We cannot optimize if 'this' is empty, as other may have holes | 4196 // We cannot optimize if 'this' is empty, as other may have holes |
| 4162 // or non keys. | 4197 // or non keys. |
| 4163 if (len1 == 0) return this; | 4198 if (len1 == 0) return this; |
| 4164 | 4199 |
| 4165 // Compute how many elements are not in this. | 4200 // Compute how many elements are not in this. |
| 4166 int extra = 0; | 4201 int extra = 0; |
| 4167 for (int y = 0; y < len1; y++) { | 4202 for (int y = 0; y < len1; y++) { |
| 4168 Object* value = other->get(y); | 4203 Object* value = other->get(y); |
| 4169 if (!value->IsTheHole() && !HasKey(this, value)) extra++; | 4204 if (!value->IsTheHole() && !HasKey(this, value)) extra++; |
| 4170 } | 4205 } |
| 4171 | 4206 |
| 4172 if (extra == 0) return this; | 4207 if (extra == 0) return this; |
| 4173 | 4208 |
| 4174 // Allocate the result | 4209 // Allocate the result |
| 4175 Object* obj; | 4210 Object* obj; |
| 4176 { MaybeObject* maybe_obj = heap->AllocateFixedArray(len0 + extra); | 4211 { MaybeObject* maybe_obj = GetHeap()->AllocateFixedArray(len0 + extra); |
| 4177 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 4212 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 4178 } | 4213 } |
| 4179 // Fill in the content | 4214 // Fill in the content |
| 4180 AssertNoAllocation no_gc; | 4215 AssertNoAllocation no_gc; |
| 4181 FixedArray* result = FixedArray::cast(obj); | 4216 FixedArray* result = FixedArray::cast(obj); |
| 4182 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | 4217 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
| 4183 for (int i = 0; i < len0; i++) { | 4218 for (int i = 0; i < len0; i++) { |
| 4184 Object* e = get(i); | 4219 Object* e = get(i); |
| 4185 ASSERT(e->IsString() || e->IsNumber()); | 4220 ASSERT(e->IsString() || e->IsNumber()); |
| 4186 result->set(i, e, mode); | 4221 result->set(i, e, mode); |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5486 return CompareStringContentsPartial(isolate, | 5521 return CompareStringContentsPartial(isolate, |
| 5487 isolate->objects_string_compare_buffer_a(), rhs); | 5522 isolate->objects_string_compare_buffer_a(), rhs); |
| 5488 } | 5523 } |
| 5489 } | 5524 } |
| 5490 | 5525 |
| 5491 | 5526 |
| 5492 bool String::MarkAsUndetectable() { | 5527 bool String::MarkAsUndetectable() { |
| 5493 if (StringShape(this).IsSymbol()) return false; | 5528 if (StringShape(this).IsSymbol()) return false; |
| 5494 | 5529 |
| 5495 Map* map = this->map(); | 5530 Map* map = this->map(); |
| 5496 Heap* heap = map->GetHeap(); | 5531 Heap* heap = map->heap(); |
| 5497 if (map == heap->string_map()) { | 5532 if (map == heap->string_map()) { |
| 5498 this->set_map(heap->undetectable_string_map()); | 5533 this->set_map(heap->undetectable_string_map()); |
| 5499 return true; | 5534 return true; |
| 5500 } else if (map == heap->ascii_string_map()) { | 5535 } else if (map == heap->ascii_string_map()) { |
| 5501 this->set_map(heap->undetectable_ascii_string_map()); | 5536 this->set_map(heap->undetectable_ascii_string_map()); |
| 5502 return true; | 5537 return true; |
| 5503 } | 5538 } |
| 5504 // Rest cannot be marked as undetectable | 5539 // Rest cannot be marked as undetectable |
| 5505 return false; | 5540 return false; |
| 5506 } | 5541 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5815 | 5850 |
| 5816 MaybeObject* JSFunction::SetPrototype(Object* value) { | 5851 MaybeObject* JSFunction::SetPrototype(Object* value) { |
| 5817 ASSERT(should_have_prototype()); | 5852 ASSERT(should_have_prototype()); |
| 5818 Object* construct_prototype = value; | 5853 Object* construct_prototype = value; |
| 5819 | 5854 |
| 5820 // If the value is not a JSObject, store the value in the map's | 5855 // If the value is not a JSObject, store the value in the map's |
| 5821 // constructor field so it can be accessed. Also, set the prototype | 5856 // constructor field so it can be accessed. Also, set the prototype |
| 5822 // used for constructing objects to the original object prototype. | 5857 // used for constructing objects to the original object prototype. |
| 5823 // See ECMA-262 13.2.2. | 5858 // See ECMA-262 13.2.2. |
| 5824 if (!value->IsJSObject()) { | 5859 if (!value->IsJSObject()) { |
| 5825 Heap* heap = GetHeap(); | |
| 5826 // Copy the map so this does not affect unrelated functions. | 5860 // Copy the map so this does not affect unrelated functions. |
| 5827 // Remove map transitions because they point to maps with a | 5861 // Remove map transitions because they point to maps with a |
| 5828 // different prototype. | 5862 // different prototype. |
| 5829 Object* new_map; | 5863 Object* new_object; |
| 5830 { MaybeObject* maybe_new_map = map()->CopyDropTransitions(); | 5864 { MaybeObject* maybe_new_map = map()->CopyDropTransitions(); |
| 5831 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 5865 if (!maybe_new_map->ToObject(&new_object)) return maybe_new_map; |
| 5832 } | 5866 } |
| 5833 set_map(Map::cast(new_map)); | 5867 Map* new_map = Map::cast(new_object); |
| 5834 map()->set_constructor(value); | 5868 Heap* heap = new_map->heap(); |
| 5835 map()->set_non_instance_prototype(true); | 5869 set_map(new_map); |
| 5870 new_map->set_constructor(value); |
| 5871 new_map->set_non_instance_prototype(true); |
| 5836 construct_prototype = | 5872 construct_prototype = |
| 5837 heap->isolate()->context()->global_context()-> | 5873 heap->isolate()->context()->global_context()-> |
| 5838 initial_object_prototype(); | 5874 initial_object_prototype(); |
| 5839 } else { | 5875 } else { |
| 5840 map()->set_non_instance_prototype(false); | 5876 map()->set_non_instance_prototype(false); |
| 5841 } | 5877 } |
| 5842 | 5878 |
| 5843 return SetInstancePrototype(construct_prototype); | 5879 return SetInstancePrototype(construct_prototype); |
| 5844 } | 5880 } |
| 5845 | 5881 |
| 5846 | 5882 |
| 5847 Object* JSFunction::RemovePrototype() { | 5883 Object* JSFunction::RemovePrototype() { |
| 5848 Context* global_context = context()->global_context(); | 5884 Context* global_context = context()->global_context(); |
| 5849 Map* no_prototype_map = shared()->strict_mode() | 5885 Map* no_prototype_map = shared()->strict_mode() |
| 5850 ? global_context->strict_mode_function_without_prototype_map() | 5886 ? global_context->strict_mode_function_without_prototype_map() |
| 5851 : global_context->function_without_prototype_map(); | 5887 : global_context->function_without_prototype_map(); |
| 5852 | 5888 |
| 5853 if (map() == no_prototype_map) { | 5889 if (map() == no_prototype_map) { |
| 5854 // Be idempotent. | 5890 // Be idempotent. |
| 5855 return this; | 5891 return this; |
| 5856 } | 5892 } |
| 5857 | 5893 |
| 5858 ASSERT(!shared()->strict_mode() || | 5894 ASSERT(!shared()->strict_mode() || |
| 5859 map() == global_context->strict_mode_function_map()); | 5895 map() == global_context->strict_mode_function_map()); |
| 5860 ASSERT(shared()->strict_mode() || map() == global_context->function_map()); | 5896 ASSERT(shared()->strict_mode() || map() == global_context->function_map()); |
| 5861 | 5897 |
| 5862 set_map(no_prototype_map); | 5898 set_map(no_prototype_map); |
| 5863 set_prototype_or_initial_map(GetHeap()->the_hole_value()); | 5899 set_prototype_or_initial_map(no_prototype_map->heap()->the_hole_value()); |
| 5864 return this; | 5900 return this; |
| 5865 } | 5901 } |
| 5866 | 5902 |
| 5867 | 5903 |
| 5868 Object* JSFunction::SetInstanceClassName(String* name) { | 5904 Object* JSFunction::SetInstanceClassName(String* name) { |
| 5869 shared()->set_instance_class_name(name); | 5905 shared()->set_instance_class_name(name); |
| 5870 return this; | 5906 return this; |
| 5871 } | 5907 } |
| 5872 | 5908 |
| 5873 | 5909 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5935 return instance_size; | 5971 return instance_size; |
| 5936 } | 5972 } |
| 5937 | 5973 |
| 5938 | 5974 |
| 5939 int SharedFunctionInfo::CalculateInObjectProperties() { | 5975 int SharedFunctionInfo::CalculateInObjectProperties() { |
| 5940 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; | 5976 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; |
| 5941 } | 5977 } |
| 5942 | 5978 |
| 5943 | 5979 |
| 5944 bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) { | 5980 bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) { |
| 5945 Heap* heap = GetHeap(); | |
| 5946 | |
| 5947 // Check the basic conditions for generating inline constructor code. | 5981 // Check the basic conditions for generating inline constructor code. |
| 5948 if (!FLAG_inline_new | 5982 if (!FLAG_inline_new |
| 5949 || !has_only_simple_this_property_assignments() | 5983 || !has_only_simple_this_property_assignments() |
| 5950 || this_property_assignments_count() == 0) { | 5984 || this_property_assignments_count() == 0) { |
| 5951 return false; | 5985 return false; |
| 5952 } | 5986 } |
| 5953 | 5987 |
| 5954 // If the prototype is null inline constructors cause no problems. | 5988 // If the prototype is null inline constructors cause no problems. |
| 5955 if (!prototype->IsJSObject()) { | 5989 if (!prototype->IsJSObject()) { |
| 5956 ASSERT(prototype->IsNull()); | 5990 ASSERT(prototype->IsNull()); |
| 5957 return true; | 5991 return true; |
| 5958 } | 5992 } |
| 5959 | 5993 |
| 5994 Heap* heap = GetHeap(); |
| 5995 |
| 5960 // Traverse the proposed prototype chain looking for setters for properties of | 5996 // Traverse the proposed prototype chain looking for setters for properties of |
| 5961 // the same names as are set by the inline constructor. | 5997 // the same names as are set by the inline constructor. |
| 5962 for (Object* obj = prototype; | 5998 for (Object* obj = prototype; |
| 5963 obj != heap->null_value(); | 5999 obj != heap->null_value(); |
| 5964 obj = obj->GetPrototype()) { | 6000 obj = obj->GetPrototype()) { |
| 5965 JSObject* js_object = JSObject::cast(obj); | 6001 JSObject* js_object = JSObject::cast(obj); |
| 5966 for (int i = 0; i < this_property_assignments_count(); i++) { | 6002 for (int i = 0; i < this_property_assignments_count(); i++) { |
| 5967 LookupResult result; | 6003 LookupResult result; |
| 5968 String* name = GetThisPropertyAssignmentName(i); | 6004 String* name = GetThisPropertyAssignmentName(i); |
| 5969 js_object->LocalLookupRealNamedProperty(name, &result); | 6005 js_object->LocalLookupRealNamedProperty(name, &result); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6269 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && | 6305 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && |
| 6270 rinfo->IsPatchedDebugBreakSlotSequence())); | 6306 rinfo->IsPatchedDebugBreakSlotSequence())); |
| 6271 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); | 6307 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); |
| 6272 Object* old_target = target; | 6308 Object* old_target = target; |
| 6273 VisitPointer(&target); | 6309 VisitPointer(&target); |
| 6274 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. | 6310 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. |
| 6275 } | 6311 } |
| 6276 | 6312 |
| 6277 | 6313 |
| 6278 void Code::InvalidateRelocation() { | 6314 void Code::InvalidateRelocation() { |
| 6279 set_relocation_info(GetHeap()->empty_byte_array()); | 6315 set_relocation_info(heap()->empty_byte_array()); |
| 6280 } | 6316 } |
| 6281 | 6317 |
| 6282 | 6318 |
| 6283 void Code::Relocate(intptr_t delta) { | 6319 void Code::Relocate(intptr_t delta) { |
| 6284 for (RelocIterator it(this, RelocInfo::kApplyMask); !it.done(); it.next()) { | 6320 for (RelocIterator it(this, RelocInfo::kApplyMask); !it.done(); it.next()) { |
| 6285 it.rinfo()->apply(delta); | 6321 it.rinfo()->apply(delta); |
| 6286 } | 6322 } |
| 6287 CPU::FlushICache(instruction_start(), instruction_size()); | 6323 CPU::FlushICache(instruction_start(), instruction_size()); |
| 6288 } | 6324 } |
| 6289 | 6325 |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6897 | 6933 |
| 6898 static Failure* ArrayLengthRangeError(Heap* heap) { | 6934 static Failure* ArrayLengthRangeError(Heap* heap) { |
| 6899 HandleScope scope; | 6935 HandleScope scope; |
| 6900 return heap->isolate()->Throw( | 6936 return heap->isolate()->Throw( |
| 6901 *FACTORY->NewRangeError("invalid_array_length", | 6937 *FACTORY->NewRangeError("invalid_array_length", |
| 6902 HandleVector<Object>(NULL, 0))); | 6938 HandleVector<Object>(NULL, 0))); |
| 6903 } | 6939 } |
| 6904 | 6940 |
| 6905 | 6941 |
| 6906 MaybeObject* JSObject::SetElementsLength(Object* len) { | 6942 MaybeObject* JSObject::SetElementsLength(Object* len) { |
| 6907 Heap* heap = GetHeap(); | |
| 6908 // We should never end in here with a pixel or external array. | 6943 // We should never end in here with a pixel or external array. |
| 6909 ASSERT(AllowsSetElementsLength()); | 6944 ASSERT(AllowsSetElementsLength()); |
| 6910 | 6945 |
| 6911 MaybeObject* maybe_smi_length = len->ToSmi(); | 6946 MaybeObject* maybe_smi_length = len->ToSmi(); |
| 6912 Object* smi_length = Smi::FromInt(0); | 6947 Object* smi_length = Smi::FromInt(0); |
| 6913 if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) { | 6948 if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) { |
| 6914 const int value = Smi::cast(smi_length)->value(); | 6949 const int value = Smi::cast(smi_length)->value(); |
| 6915 if (value < 0) return ArrayLengthRangeError(heap); | 6950 if (value < 0) return ArrayLengthRangeError(GetHeap()); |
| 6916 switch (GetElementsKind()) { | 6951 switch (GetElementsKind()) { |
| 6917 case FAST_ELEMENTS: { | 6952 case FAST_ELEMENTS: { |
| 6918 int old_capacity = FixedArray::cast(elements())->length(); | 6953 int old_capacity = FixedArray::cast(elements())->length(); |
| 6919 if (value <= old_capacity) { | 6954 if (value <= old_capacity) { |
| 6920 if (IsJSArray()) { | 6955 if (IsJSArray()) { |
| 6921 Object* obj; | 6956 Object* obj; |
| 6922 { MaybeObject* maybe_obj = EnsureWritableFastElements(); | 6957 { MaybeObject* maybe_obj = EnsureWritableFastElements(); |
| 6923 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6958 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 6924 } | 6959 } |
| 6925 int old_length = FastD2I(JSArray::cast(this)->length()->Number()); | 6960 int old_length = FastD2I(JSArray::cast(this)->length()->Number()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6979 break; | 7014 break; |
| 6980 } | 7015 } |
| 6981 } | 7016 } |
| 6982 | 7017 |
| 6983 // General slow case. | 7018 // General slow case. |
| 6984 if (len->IsNumber()) { | 7019 if (len->IsNumber()) { |
| 6985 uint32_t length; | 7020 uint32_t length; |
| 6986 if (len->ToArrayIndex(&length)) { | 7021 if (len->ToArrayIndex(&length)) { |
| 6987 return SetSlowElements(len); | 7022 return SetSlowElements(len); |
| 6988 } else { | 7023 } else { |
| 6989 return ArrayLengthRangeError(heap); | 7024 return ArrayLengthRangeError(GetHeap()); |
| 6990 } | 7025 } |
| 6991 } | 7026 } |
| 6992 | 7027 |
| 6993 // len is not a number so make the array size one and | 7028 // len is not a number so make the array size one and |
| 6994 // set only element to len. | 7029 // set only element to len. |
| 6995 Object* obj; | 7030 Object* obj; |
| 6996 { MaybeObject* maybe_obj = heap->AllocateFixedArray(1); | 7031 { MaybeObject* maybe_obj = GetHeap()->AllocateFixedArray(1); |
| 6997 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7032 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 6998 } | 7033 } |
| 6999 FixedArray::cast(obj)->set(0, len); | 7034 FixedArray::cast(obj)->set(0, len); |
| 7000 if (IsJSArray()) JSArray::cast(this)->set_length(Smi::FromInt(1)); | 7035 if (IsJSArray()) JSArray::cast(this)->set_length(Smi::FromInt(1)); |
| 7001 set_elements(FixedArray::cast(obj)); | 7036 set_elements(FixedArray::cast(obj)); |
| 7002 return this; | 7037 return this; |
| 7003 } | 7038 } |
| 7004 | 7039 |
| 7005 | 7040 |
| 7006 MaybeObject* JSObject::SetPrototype(Object* value, | 7041 MaybeObject* JSObject::SetPrototype(Object* value, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7141 VMState state(isolate, EXTERNAL); | 7176 VMState state(isolate, EXTERNAL); |
| 7142 result = getter(index, info); | 7177 result = getter(index, info); |
| 7143 } | 7178 } |
| 7144 if (!result.IsEmpty()) return true; | 7179 if (!result.IsEmpty()) return true; |
| 7145 } | 7180 } |
| 7146 return holder_handle->HasElementPostInterceptor(*receiver_handle, index); | 7181 return holder_handle->HasElementPostInterceptor(*receiver_handle, index); |
| 7147 } | 7182 } |
| 7148 | 7183 |
| 7149 | 7184 |
| 7150 JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) { | 7185 JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) { |
| 7151 Heap* heap = GetHeap(); | |
| 7152 | |
| 7153 // Check access rights if needed. | 7186 // Check access rights if needed. |
| 7154 if (IsAccessCheckNeeded() && | 7187 if (IsAccessCheckNeeded()) { |
| 7155 !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 7188 Heap* heap = GetHeap(); |
| 7156 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 7189 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
| 7157 return UNDEFINED_ELEMENT; | 7190 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 7191 return UNDEFINED_ELEMENT; |
| 7192 } |
| 7158 } | 7193 } |
| 7159 | 7194 |
| 7160 if (IsJSGlobalProxy()) { | 7195 if (IsJSGlobalProxy()) { |
| 7161 Object* proto = GetPrototype(); | 7196 Object* proto = GetPrototype(); |
| 7162 if (proto->IsNull()) return UNDEFINED_ELEMENT; | 7197 if (proto->IsNull()) return UNDEFINED_ELEMENT; |
| 7163 ASSERT(proto->IsJSGlobalObject()); | 7198 ASSERT(proto->IsJSGlobalObject()); |
| 7164 return JSObject::cast(proto)->HasLocalElement(index); | 7199 return JSObject::cast(proto)->HasLocalElement(index); |
| 7165 } | 7200 } |
| 7166 | 7201 |
| 7167 // Check for lookup interceptor | 7202 // Check for lookup interceptor |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7255 if (NumberDictionary::cast(elements)->FindEntry(index) != | 7290 if (NumberDictionary::cast(elements)->FindEntry(index) != |
| 7256 NumberDictionary::kNotFound) { | 7291 NumberDictionary::kNotFound) { |
| 7257 return true; | 7292 return true; |
| 7258 } | 7293 } |
| 7259 } | 7294 } |
| 7260 return false; | 7295 return false; |
| 7261 } | 7296 } |
| 7262 | 7297 |
| 7263 | 7298 |
| 7264 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) { | 7299 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) { |
| 7265 Heap* heap = GetHeap(); | |
| 7266 | |
| 7267 // Check access rights if needed. | 7300 // Check access rights if needed. |
| 7268 if (IsAccessCheckNeeded() && | 7301 if (IsAccessCheckNeeded()) { |
| 7269 !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 7302 Heap* heap = GetHeap(); |
| 7270 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 7303 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
| 7271 return false; | 7304 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 7305 return false; |
| 7306 } |
| 7272 } | 7307 } |
| 7273 | 7308 |
| 7274 // Check for lookup interceptor | 7309 // Check for lookup interceptor |
| 7275 if (HasIndexedInterceptor()) { | 7310 if (HasIndexedInterceptor()) { |
| 7276 return HasElementWithInterceptor(receiver, index); | 7311 return HasElementWithInterceptor(receiver, index); |
| 7277 } | 7312 } |
| 7278 | 7313 |
| 7279 ElementsKind kind = GetElementsKind(); | 7314 ElementsKind kind = GetElementsKind(); |
| 7280 switch (kind) { | 7315 switch (kind) { |
| 7281 case FAST_ELEMENTS: | 7316 case FAST_ELEMENTS: |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7661 #endif | 7696 #endif |
| 7662 } | 7697 } |
| 7663 return value; | 7698 return value; |
| 7664 } | 7699 } |
| 7665 | 7700 |
| 7666 | 7701 |
| 7667 MaybeObject* JSObject::SetElement(uint32_t index, | 7702 MaybeObject* JSObject::SetElement(uint32_t index, |
| 7668 Object* value, | 7703 Object* value, |
| 7669 StrictModeFlag strict_mode, | 7704 StrictModeFlag strict_mode, |
| 7670 bool check_prototype) { | 7705 bool check_prototype) { |
| 7671 Heap* heap = GetHeap(); | |
| 7672 // Check access rights if needed. | 7706 // Check access rights if needed. |
| 7673 if (IsAccessCheckNeeded() && | 7707 if (IsAccessCheckNeeded()) { |
| 7674 !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) { | 7708 Heap* heap = GetHeap(); |
| 7675 HandleScope scope; | 7709 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) { |
| 7676 Handle<Object> value_handle(value); | 7710 HandleScope scope; |
| 7677 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET); | 7711 Handle<Object> value_handle(value); |
| 7678 return *value_handle; | 7712 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET); |
| 7713 return *value_handle; |
| 7714 } |
| 7679 } | 7715 } |
| 7680 | 7716 |
| 7681 if (IsJSGlobalProxy()) { | 7717 if (IsJSGlobalProxy()) { |
| 7682 Object* proto = GetPrototype(); | 7718 Object* proto = GetPrototype(); |
| 7683 if (proto->IsNull()) return value; | 7719 if (proto->IsNull()) return value; |
| 7684 ASSERT(proto->IsJSGlobalObject()); | 7720 ASSERT(proto->IsJSGlobalObject()); |
| 7685 return JSObject::cast(proto)->SetElement(index, | 7721 return JSObject::cast(proto)->SetElement(index, |
| 7686 value, | 7722 value, |
| 7687 strict_mode, | 7723 strict_mode, |
| 7688 check_prototype); | 7724 check_prototype); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7791 if (!maybe_len->ToObject(&len)) return maybe_len; | 7827 if (!maybe_len->ToObject(&len)) return maybe_len; |
| 7792 } | 7828 } |
| 7793 set_length(len); | 7829 set_length(len); |
| 7794 } | 7830 } |
| 7795 return value; | 7831 return value; |
| 7796 } | 7832 } |
| 7797 | 7833 |
| 7798 | 7834 |
| 7799 MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver, | 7835 MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver, |
| 7800 uint32_t index) { | 7836 uint32_t index) { |
| 7801 Heap* heap = GetHeap(); | |
| 7802 // Get element works for both JSObject and JSArray since | 7837 // Get element works for both JSObject and JSArray since |
| 7803 // JSArray::length cannot change. | 7838 // JSArray::length cannot change. |
| 7804 switch (GetElementsKind()) { | 7839 switch (GetElementsKind()) { |
| 7805 case FAST_ELEMENTS: { | 7840 case FAST_ELEMENTS: { |
| 7806 FixedArray* elms = FixedArray::cast(elements()); | 7841 FixedArray* elms = FixedArray::cast(elements()); |
| 7807 if (index < static_cast<uint32_t>(elms->length())) { | 7842 if (index < static_cast<uint32_t>(elms->length())) { |
| 7808 Object* value = elms->get(index); | 7843 Object* value = elms->get(index); |
| 7809 if (!value->IsTheHole()) return value; | 7844 if (!value->IsTheHole()) return value; |
| 7810 } | 7845 } |
| 7811 break; | 7846 break; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 7840 } | 7875 } |
| 7841 break; | 7876 break; |
| 7842 } | 7877 } |
| 7843 case NON_STRICT_ARGUMENTS_ELEMENTS: | 7878 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 7844 UNIMPLEMENTED(); | 7879 UNIMPLEMENTED(); |
| 7845 break; | 7880 break; |
| 7846 } | 7881 } |
| 7847 | 7882 |
| 7848 // Continue searching via the prototype chain. | 7883 // Continue searching via the prototype chain. |
| 7849 Object* pt = GetPrototype(); | 7884 Object* pt = GetPrototype(); |
| 7850 if (pt->IsNull()) return heap->undefined_value(); | 7885 if (pt->IsNull()) return GetHeap()->undefined_value(); |
| 7851 return pt->GetElementWithReceiver(receiver, index); | 7886 return pt->GetElementWithReceiver(receiver, index); |
| 7852 } | 7887 } |
| 7853 | 7888 |
| 7854 | 7889 |
| 7855 MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver, | 7890 MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver, |
| 7856 uint32_t index) { | 7891 uint32_t index) { |
| 7857 Isolate* isolate = GetIsolate(); | 7892 Isolate* isolate = GetIsolate(); |
| 7858 // Make sure that the top context does not change when doing | 7893 // Make sure that the top context does not change when doing |
| 7859 // callbacks or interceptor calls. | 7894 // callbacks or interceptor calls. |
| 7860 AssertNoContextChange ncc; | 7895 AssertNoContextChange ncc; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 7882 | 7917 |
| 7883 MaybeObject* raw_result = | 7918 MaybeObject* raw_result = |
| 7884 holder_handle->GetElementPostInterceptor(*this_handle, index); | 7919 holder_handle->GetElementPostInterceptor(*this_handle, index); |
| 7885 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 7920 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 7886 return raw_result; | 7921 return raw_result; |
| 7887 } | 7922 } |
| 7888 | 7923 |
| 7889 | 7924 |
| 7890 MaybeObject* JSObject::GetElementWithReceiver(Object* receiver, | 7925 MaybeObject* JSObject::GetElementWithReceiver(Object* receiver, |
| 7891 uint32_t index) { | 7926 uint32_t index) { |
| 7892 Heap* heap = GetHeap(); | |
| 7893 // Check access rights if needed. | 7927 // Check access rights if needed. |
| 7894 if (IsAccessCheckNeeded() && | 7928 if (IsAccessCheckNeeded()) { |
| 7895 !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_GET)) { | 7929 Heap* heap = GetHeap(); |
| 7896 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET); | 7930 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_GET)) { |
| 7897 return heap->undefined_value(); | 7931 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET); |
| 7932 return heap->undefined_value(); |
| 7933 } |
| 7898 } | 7934 } |
| 7899 | 7935 |
| 7900 if (HasIndexedInterceptor()) { | 7936 if (HasIndexedInterceptor()) { |
| 7901 return GetElementWithInterceptor(receiver, index); | 7937 return GetElementWithInterceptor(receiver, index); |
| 7902 } | 7938 } |
| 7903 | 7939 |
| 7904 // Get element works for both JSObject and JSArray since | 7940 // Get element works for both JSObject and JSArray since |
| 7905 // JSArray::length cannot change. | 7941 // JSArray::length cannot change. |
| 7906 switch (GetElementsKind()) { | 7942 switch (GetElementsKind()) { |
| 7907 case FAST_ELEMENTS: { | 7943 case FAST_ELEMENTS: { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7972 } else if (index < static_cast<uint32_t>(arguments->length())) { | 8008 } else if (index < static_cast<uint32_t>(arguments->length())) { |
| 7973 Object* value = arguments->get(index); | 8009 Object* value = arguments->get(index); |
| 7974 if (!value->IsTheHole()) return value; | 8010 if (!value->IsTheHole()) return value; |
| 7975 } | 8011 } |
| 7976 } | 8012 } |
| 7977 break; | 8013 break; |
| 7978 } | 8014 } |
| 7979 } | 8015 } |
| 7980 | 8016 |
| 7981 Object* pt = GetPrototype(); | 8017 Object* pt = GetPrototype(); |
| 8018 Heap* heap = GetHeap(); |
| 7982 if (pt == heap->null_value()) return heap->undefined_value(); | 8019 if (pt == heap->null_value()) return heap->undefined_value(); |
| 7983 return pt->GetElementWithReceiver(receiver, index); | 8020 return pt->GetElementWithReceiver(receiver, index); |
| 7984 } | 8021 } |
| 7985 | 8022 |
| 7986 | 8023 |
| 7987 MaybeObject* JSObject::GetExternalElement(uint32_t index) { | 8024 MaybeObject* JSObject::GetExternalElement(uint32_t index) { |
| 7988 // Get element works for both JSObject and JSArray since | 8025 // Get element works for both JSObject and JSArray since |
| 7989 // JSArray::length cannot change. | 8026 // JSArray::length cannot change. |
| 7990 switch (GetElementsKind()) { | 8027 switch (GetElementsKind()) { |
| 7991 case EXTERNAL_PIXEL_ELEMENTS: { | 8028 case EXTERNAL_PIXEL_ELEMENTS: { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8214 Object* result = | 8251 Object* result = |
| 8215 constructor->shared()->get_api_func_data()->indexed_property_handler(); | 8252 constructor->shared()->get_api_func_data()->indexed_property_handler(); |
| 8216 return InterceptorInfo::cast(result); | 8253 return InterceptorInfo::cast(result); |
| 8217 } | 8254 } |
| 8218 | 8255 |
| 8219 | 8256 |
| 8220 MaybeObject* JSObject::GetPropertyPostInterceptor( | 8257 MaybeObject* JSObject::GetPropertyPostInterceptor( |
| 8221 JSObject* receiver, | 8258 JSObject* receiver, |
| 8222 String* name, | 8259 String* name, |
| 8223 PropertyAttributes* attributes) { | 8260 PropertyAttributes* attributes) { |
| 8224 Heap* heap = GetHeap(); | |
| 8225 // Check local property in holder, ignore interceptor. | 8261 // Check local property in holder, ignore interceptor. |
| 8226 LookupResult result; | 8262 LookupResult result; |
| 8227 LocalLookupRealNamedProperty(name, &result); | 8263 LocalLookupRealNamedProperty(name, &result); |
| 8228 if (result.IsProperty()) { | 8264 if (result.IsProperty()) { |
| 8229 return GetProperty(receiver, &result, name, attributes); | 8265 return GetProperty(receiver, &result, name, attributes); |
| 8230 } | 8266 } |
| 8231 // Continue searching via the prototype chain. | 8267 // Continue searching via the prototype chain. |
| 8232 Object* pt = GetPrototype(); | 8268 Object* pt = GetPrototype(); |
| 8233 *attributes = ABSENT; | 8269 *attributes = ABSENT; |
| 8234 if (pt->IsNull()) return heap->undefined_value(); | 8270 if (pt->IsNull()) return GetHeap()->undefined_value(); |
| 8235 return pt->GetPropertyWithReceiver(receiver, name, attributes); | 8271 return pt->GetPropertyWithReceiver(receiver, name, attributes); |
| 8236 } | 8272 } |
| 8237 | 8273 |
| 8238 | 8274 |
| 8239 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( | 8275 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( |
| 8240 JSObject* receiver, | 8276 JSObject* receiver, |
| 8241 String* name, | 8277 String* name, |
| 8242 PropertyAttributes* attributes) { | 8278 PropertyAttributes* attributes) { |
| 8243 Heap* heap = GetHeap(); | |
| 8244 // Check local property in holder, ignore interceptor. | 8279 // Check local property in holder, ignore interceptor. |
| 8245 LookupResult result; | 8280 LookupResult result; |
| 8246 LocalLookupRealNamedProperty(name, &result); | 8281 LocalLookupRealNamedProperty(name, &result); |
| 8247 if (result.IsProperty()) { | 8282 if (result.IsProperty()) { |
| 8248 return GetProperty(receiver, &result, name, attributes); | 8283 return GetProperty(receiver, &result, name, attributes); |
| 8249 } | 8284 } |
| 8250 return heap->undefined_value(); | 8285 return GetHeap()->undefined_value(); |
| 8251 } | 8286 } |
| 8252 | 8287 |
| 8253 | 8288 |
| 8254 MaybeObject* JSObject::GetPropertyWithInterceptor( | 8289 MaybeObject* JSObject::GetPropertyWithInterceptor( |
| 8255 JSObject* receiver, | 8290 JSObject* receiver, |
| 8256 String* name, | 8291 String* name, |
| 8257 PropertyAttributes* attributes) { | 8292 PropertyAttributes* attributes) { |
| 8258 Isolate* isolate = GetIsolate(); | 8293 Isolate* isolate = GetIsolate(); |
| 8259 InterceptorInfo* interceptor = GetNamedInterceptor(); | 8294 InterceptorInfo* interceptor = GetNamedInterceptor(); |
| 8260 HandleScope scope(isolate); | 8295 HandleScope scope(isolate); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 8285 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( | 8320 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( |
| 8286 *receiver_handle, | 8321 *receiver_handle, |
| 8287 *name_handle, | 8322 *name_handle, |
| 8288 attributes); | 8323 attributes); |
| 8289 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 8324 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 8290 return result; | 8325 return result; |
| 8291 } | 8326 } |
| 8292 | 8327 |
| 8293 | 8328 |
| 8294 bool JSObject::HasRealNamedProperty(String* key) { | 8329 bool JSObject::HasRealNamedProperty(String* key) { |
| 8295 Heap* heap = GetHeap(); | |
| 8296 // Check access rights if needed. | 8330 // Check access rights if needed. |
| 8297 if (IsAccessCheckNeeded() && | 8331 if (IsAccessCheckNeeded()) { |
| 8298 !heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 8332 Heap* heap = GetHeap(); |
| 8299 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 8333 if (!heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
| 8300 return false; | 8334 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 8335 return false; |
| 8336 } |
| 8301 } | 8337 } |
| 8302 | 8338 |
| 8303 LookupResult result; | 8339 LookupResult result; |
| 8304 LocalLookupRealNamedProperty(key, &result); | 8340 LocalLookupRealNamedProperty(key, &result); |
| 8305 return result.IsProperty() && (result.type() != INTERCEPTOR); | 8341 return result.IsProperty() && (result.type() != INTERCEPTOR); |
| 8306 } | 8342 } |
| 8307 | 8343 |
| 8308 | 8344 |
| 8309 bool JSObject::HasRealElementProperty(uint32_t index) { | 8345 bool JSObject::HasRealElementProperty(uint32_t index) { |
| 8310 Heap* heap = GetHeap(); | |
| 8311 // Check access rights if needed. | 8346 // Check access rights if needed. |
| 8312 if (IsAccessCheckNeeded() && | 8347 if (IsAccessCheckNeeded()) { |
| 8313 !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 8348 Heap* heap = GetHeap(); |
| 8314 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 8349 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
| 8315 return false; | 8350 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 8351 return false; |
| 8352 } |
| 8316 } | 8353 } |
| 8317 | 8354 |
| 8318 // Handle [] on String objects. | 8355 // Handle [] on String objects. |
| 8319 if (this->IsStringObjectWithCharacterAt(index)) return true; | 8356 if (this->IsStringObjectWithCharacterAt(index)) return true; |
| 8320 | 8357 |
| 8321 switch (GetElementsKind()) { | 8358 switch (GetElementsKind()) { |
| 8322 case FAST_ELEMENTS: { | 8359 case FAST_ELEMENTS: { |
| 8323 uint32_t length = IsJSArray() ? | 8360 uint32_t length = IsJSArray() ? |
| 8324 static_cast<uint32_t>( | 8361 static_cast<uint32_t>( |
| 8325 Smi::cast(JSArray::cast(this)->length())->value()) : | 8362 Smi::cast(JSArray::cast(this)->length())->value()) : |
| (...skipping 18 matching lines...) Expand all Loading... |
| 8344 case DICTIONARY_ELEMENTS: { | 8381 case DICTIONARY_ELEMENTS: { |
| 8345 return element_dictionary()->FindEntry(index) | 8382 return element_dictionary()->FindEntry(index) |
| 8346 != NumberDictionary::kNotFound; | 8383 != NumberDictionary::kNotFound; |
| 8347 } | 8384 } |
| 8348 case NON_STRICT_ARGUMENTS_ELEMENTS: | 8385 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 8349 UNIMPLEMENTED(); | 8386 UNIMPLEMENTED(); |
| 8350 break; | 8387 break; |
| 8351 } | 8388 } |
| 8352 // All possibilities have been handled above already. | 8389 // All possibilities have been handled above already. |
| 8353 UNREACHABLE(); | 8390 UNREACHABLE(); |
| 8354 return heap->null_value(); | 8391 return GetHeap()->null_value(); |
| 8355 } | 8392 } |
| 8356 | 8393 |
| 8357 | 8394 |
| 8358 bool JSObject::HasRealNamedCallbackProperty(String* key) { | 8395 bool JSObject::HasRealNamedCallbackProperty(String* key) { |
| 8359 Heap* heap = GetHeap(); | |
| 8360 // Check access rights if needed. | 8396 // Check access rights if needed. |
| 8361 if (IsAccessCheckNeeded() && | 8397 if (IsAccessCheckNeeded()) { |
| 8362 !heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 8398 Heap* heap = GetHeap(); |
| 8363 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 8399 if (!heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
| 8364 return false; | 8400 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 8401 return false; |
| 8402 } |
| 8365 } | 8403 } |
| 8366 | 8404 |
| 8367 LookupResult result; | 8405 LookupResult result; |
| 8368 LocalLookupRealNamedProperty(key, &result); | 8406 LocalLookupRealNamedProperty(key, &result); |
| 8369 return result.IsProperty() && (result.type() == CALLBACKS); | 8407 return result.IsProperty() && (result.type() == CALLBACKS); |
| 8370 } | 8408 } |
| 8371 | 8409 |
| 8372 | 8410 |
| 8373 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { | 8411 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { |
| 8374 if (HasFastProperties()) { | 8412 if (HasFastProperties()) { |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9015 } | 9053 } |
| 9016 ASSERT(element->IsNull() || !String::cast(element)->Equals(key)); | 9054 ASSERT(element->IsNull() || !String::cast(element)->Equals(key)); |
| 9017 entry = NextProbe(entry, count++, capacity); | 9055 entry = NextProbe(entry, count++, capacity); |
| 9018 } | 9056 } |
| 9019 return kNotFound; | 9057 return kNotFound; |
| 9020 } | 9058 } |
| 9021 | 9059 |
| 9022 | 9060 |
| 9023 template<typename Shape, typename Key> | 9061 template<typename Shape, typename Key> |
| 9024 MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { | 9062 MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { |
| 9025 Heap* heap = GetHeap(); | |
| 9026 int capacity = Capacity(); | 9063 int capacity = Capacity(); |
| 9027 int nof = NumberOfElements() + n; | 9064 int nof = NumberOfElements() + n; |
| 9028 int nod = NumberOfDeletedElements(); | 9065 int nod = NumberOfDeletedElements(); |
| 9029 // Return if: | 9066 // Return if: |
| 9030 // 50% is still free after adding n elements and | 9067 // 50% is still free after adding n elements and |
| 9031 // at most 50% of the free elements are deleted elements. | 9068 // at most 50% of the free elements are deleted elements. |
| 9032 if (nod <= (capacity - nof) >> 1) { | 9069 if (nod <= (capacity - nof) >> 1) { |
| 9033 int needed_free = nof >> 1; | 9070 int needed_free = nof >> 1; |
| 9034 if (nof + needed_free <= capacity) return this; | 9071 if (nof + needed_free <= capacity) return this; |
| 9035 } | 9072 } |
| 9036 | 9073 |
| 9037 const int kMinCapacityForPretenure = 256; | 9074 const int kMinCapacityForPretenure = 256; |
| 9038 bool pretenure = | 9075 bool pretenure = |
| 9039 (capacity > kMinCapacityForPretenure) && !heap->InNewSpace(this); | 9076 (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this); |
| 9040 Object* obj; | 9077 Object* obj; |
| 9041 { MaybeObject* maybe_obj = | 9078 { MaybeObject* maybe_obj = |
| 9042 Allocate(nof * 2, pretenure ? TENURED : NOT_TENURED); | 9079 Allocate(nof * 2, pretenure ? TENURED : NOT_TENURED); |
| 9043 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 9080 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 9044 } | 9081 } |
| 9045 | 9082 |
| 9046 AssertNoAllocation no_gc; | 9083 AssertNoAllocation no_gc; |
| 9047 HashTable* table = HashTable::cast(obj); | 9084 HashTable* table = HashTable::cast(obj); |
| 9048 WriteBarrierMode mode = table->GetWriteBarrierMode(no_gc); | 9085 WriteBarrierMode mode = table->GetWriteBarrierMode(no_gc); |
| 9049 | 9086 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9161 template | 9198 template |
| 9162 int Dictionary<StringDictionaryShape, String*>::NumberOfEnumElements(); | 9199 int Dictionary<StringDictionaryShape, String*>::NumberOfEnumElements(); |
| 9163 | 9200 |
| 9164 template | 9201 template |
| 9165 int HashTable<NumberDictionaryShape, uint32_t>::FindEntry(uint32_t); | 9202 int HashTable<NumberDictionaryShape, uint32_t>::FindEntry(uint32_t); |
| 9166 | 9203 |
| 9167 | 9204 |
| 9168 // Collates undefined and unexisting elements below limit from position | 9205 // Collates undefined and unexisting elements below limit from position |
| 9169 // zero of the elements. The object stays in Dictionary mode. | 9206 // zero of the elements. The object stays in Dictionary mode. |
| 9170 MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) { | 9207 MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) { |
| 9171 Heap* heap = GetHeap(); | |
| 9172 ASSERT(HasDictionaryElements()); | 9208 ASSERT(HasDictionaryElements()); |
| 9173 // Must stay in dictionary mode, either because of requires_slow_elements, | 9209 // Must stay in dictionary mode, either because of requires_slow_elements, |
| 9174 // or because we are not going to sort (and therefore compact) all of the | 9210 // or because we are not going to sort (and therefore compact) all of the |
| 9175 // elements. | 9211 // elements. |
| 9176 NumberDictionary* dict = element_dictionary(); | 9212 NumberDictionary* dict = element_dictionary(); |
| 9177 HeapNumber* result_double = NULL; | 9213 HeapNumber* result_double = NULL; |
| 9178 if (limit > static_cast<uint32_t>(Smi::kMaxValue)) { | 9214 if (limit > static_cast<uint32_t>(Smi::kMaxValue)) { |
| 9179 // Allocate space for result before we start mutating the object. | 9215 // Allocate space for result before we start mutating the object. |
| 9180 Object* new_double; | 9216 Object* new_double; |
| 9181 { MaybeObject* maybe_new_double = heap->AllocateHeapNumber(0.0); | 9217 { MaybeObject* maybe_new_double = GetHeap()->AllocateHeapNumber(0.0); |
| 9182 if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double; | 9218 if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double; |
| 9183 } | 9219 } |
| 9184 result_double = HeapNumber::cast(new_double); | 9220 result_double = HeapNumber::cast(new_double); |
| 9185 } | 9221 } |
| 9186 | 9222 |
| 9187 Object* obj; | 9223 Object* obj; |
| 9188 { MaybeObject* maybe_obj = | 9224 { MaybeObject* maybe_obj = |
| 9189 NumberDictionary::Allocate(dict->NumberOfElements()); | 9225 NumberDictionary::Allocate(dict->NumberOfElements()); |
| 9190 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 9226 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 9191 } | 9227 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9231 // allocation. Bailout. | 9267 // allocation. Bailout. |
| 9232 return Smi::FromInt(-1); | 9268 return Smi::FromInt(-1); |
| 9233 } | 9269 } |
| 9234 new_dict->AddNumberEntry(key, value, details)->ToObjectUnchecked(); | 9270 new_dict->AddNumberEntry(key, value, details)->ToObjectUnchecked(); |
| 9235 } | 9271 } |
| 9236 } | 9272 } |
| 9237 } | 9273 } |
| 9238 | 9274 |
| 9239 uint32_t result = pos; | 9275 uint32_t result = pos; |
| 9240 PropertyDetails no_details = PropertyDetails(NONE, NORMAL); | 9276 PropertyDetails no_details = PropertyDetails(NONE, NORMAL); |
| 9277 Heap* heap = GetHeap(); |
| 9241 while (undefs > 0) { | 9278 while (undefs > 0) { |
| 9242 if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { | 9279 if (pos > static_cast<uint32_t>(Smi::kMaxValue)) { |
| 9243 // Adding an entry with the key beyond smi-range requires | 9280 // Adding an entry with the key beyond smi-range requires |
| 9244 // allocation. Bailout. | 9281 // allocation. Bailout. |
| 9245 return Smi::FromInt(-1); | 9282 return Smi::FromInt(-1); |
| 9246 } | 9283 } |
| 9247 new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)-> | 9284 new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)-> |
| 9248 ToObjectUnchecked(); | 9285 ToObjectUnchecked(); |
| 9249 pos++; | 9286 pos++; |
| 9250 undefs--; | 9287 undefs--; |
| 9251 } | 9288 } |
| 9252 | 9289 |
| 9253 set_elements(new_dict); | 9290 set_elements(new_dict); |
| 9254 | 9291 |
| 9255 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { | 9292 if (result <= static_cast<uint32_t>(Smi::kMaxValue)) { |
| 9256 return Smi::FromInt(static_cast<int>(result)); | 9293 return Smi::FromInt(static_cast<int>(result)); |
| 9257 } | 9294 } |
| 9258 | 9295 |
| 9259 ASSERT_NE(NULL, result_double); | 9296 ASSERT_NE(NULL, result_double); |
| 9260 result_double->set_value(static_cast<double>(result)); | 9297 result_double->set_value(static_cast<double>(result)); |
| 9261 return result_double; | 9298 return result_double; |
| 9262 } | 9299 } |
| 9263 | 9300 |
| 9264 | 9301 |
| 9265 // Collects all defined (non-hole) and non-undefined (array) elements at | 9302 // Collects all defined (non-hole) and non-undefined (array) elements at |
| 9266 // the start of the elements array. | 9303 // the start of the elements array. |
| 9267 // If the object is in dictionary mode, it is converted to fast elements | 9304 // If the object is in dictionary mode, it is converted to fast elements |
| 9268 // mode. | 9305 // mode. |
| 9269 MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) { | 9306 MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) { |
| 9307 ASSERT(!HasExternalArrayElements()); |
| 9308 |
| 9270 Heap* heap = GetHeap(); | 9309 Heap* heap = GetHeap(); |
| 9271 ASSERT(!HasExternalArrayElements()); | |
| 9272 | 9310 |
| 9273 if (HasDictionaryElements()) { | 9311 if (HasDictionaryElements()) { |
| 9274 // Convert to fast elements containing only the existing properties. | 9312 // Convert to fast elements containing only the existing properties. |
| 9275 // Ordering is irrelevant, since we are going to sort anyway. | 9313 // Ordering is irrelevant, since we are going to sort anyway. |
| 9276 NumberDictionary* dict = element_dictionary(); | 9314 NumberDictionary* dict = element_dictionary(); |
| 9277 if (IsJSArray() || dict->requires_slow_elements() || | 9315 if (IsJSArray() || dict->requires_slow_elements() || |
| 9278 dict->max_number_key() >= limit) { | 9316 dict->max_number_key() >= limit) { |
| 9279 return PrepareSlowElementsForSort(limit); | 9317 return PrepareSlowElementsForSort(limit); |
| 9280 } | 9318 } |
| 9281 // Convert to fast elements. | 9319 // Convert to fast elements. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9516 | 9554 |
| 9517 JSGlobalPropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { | 9555 JSGlobalPropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { |
| 9518 ASSERT(!HasFastProperties()); | 9556 ASSERT(!HasFastProperties()); |
| 9519 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 9557 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 9520 return JSGlobalPropertyCell::cast(value); | 9558 return JSGlobalPropertyCell::cast(value); |
| 9521 } | 9559 } |
| 9522 | 9560 |
| 9523 | 9561 |
| 9524 MaybeObject* GlobalObject::EnsurePropertyCell(String* name) { | 9562 MaybeObject* GlobalObject::EnsurePropertyCell(String* name) { |
| 9525 ASSERT(!HasFastProperties()); | 9563 ASSERT(!HasFastProperties()); |
| 9526 Heap* heap = GetHeap(); | |
| 9527 int entry = property_dictionary()->FindEntry(name); | 9564 int entry = property_dictionary()->FindEntry(name); |
| 9528 if (entry == StringDictionary::kNotFound) { | 9565 if (entry == StringDictionary::kNotFound) { |
| 9566 Heap* heap = GetHeap(); |
| 9529 Object* cell; | 9567 Object* cell; |
| 9530 { MaybeObject* maybe_cell = | 9568 { MaybeObject* maybe_cell = |
| 9531 heap->AllocateJSGlobalPropertyCell(heap->the_hole_value()); | 9569 heap->AllocateJSGlobalPropertyCell(heap->the_hole_value()); |
| 9532 if (!maybe_cell->ToObject(&cell)) return maybe_cell; | 9570 if (!maybe_cell->ToObject(&cell)) return maybe_cell; |
| 9533 } | 9571 } |
| 9534 PropertyDetails details(NONE, NORMAL); | 9572 PropertyDetails details(NONE, NORMAL); |
| 9535 details = details.AsDeleted(); | 9573 details = details.AsDeleted(); |
| 9536 Object* dictionary; | 9574 Object* dictionary; |
| 9537 { MaybeObject* maybe_dictionary = | 9575 { MaybeObject* maybe_dictionary = |
| 9538 property_dictionary()->Add(name, cell, details); | 9576 property_dictionary()->Add(name, cell, details); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9693 // Add the new symbol and return it along with the symbol table. | 9731 // Add the new symbol and return it along with the symbol table. |
| 9694 entry = table->FindInsertionEntry(key->Hash()); | 9732 entry = table->FindInsertionEntry(key->Hash()); |
| 9695 table->set(EntryToIndex(entry), symbol); | 9733 table->set(EntryToIndex(entry), symbol); |
| 9696 table->ElementAdded(); | 9734 table->ElementAdded(); |
| 9697 *s = symbol; | 9735 *s = symbol; |
| 9698 return table; | 9736 return table; |
| 9699 } | 9737 } |
| 9700 | 9738 |
| 9701 | 9739 |
| 9702 Object* CompilationCacheTable::Lookup(String* src) { | 9740 Object* CompilationCacheTable::Lookup(String* src) { |
| 9703 Heap* heap = GetHeap(); | |
| 9704 StringKey key(src); | 9741 StringKey key(src); |
| 9705 int entry = FindEntry(&key); | 9742 int entry = FindEntry(&key); |
| 9706 if (entry == kNotFound) return heap->undefined_value(); | 9743 if (entry == kNotFound) return GetHeap()->undefined_value(); |
| 9707 return get(EntryToIndex(entry) + 1); | 9744 return get(EntryToIndex(entry) + 1); |
| 9708 } | 9745 } |
| 9709 | 9746 |
| 9710 | 9747 |
| 9711 Object* CompilationCacheTable::LookupEval(String* src, | 9748 Object* CompilationCacheTable::LookupEval(String* src, |
| 9712 Context* context, | 9749 Context* context, |
| 9713 StrictModeFlag strict_mode) { | 9750 StrictModeFlag strict_mode) { |
| 9714 StringSharedKey key(src, context->closure()->shared(), strict_mode); | 9751 StringSharedKey key(src, context->closure()->shared(), strict_mode); |
| 9715 int entry = FindEntry(&key); | 9752 int entry = FindEntry(&key); |
| 9716 if (entry == kNotFound) return GetHeap()->undefined_value(); | 9753 if (entry == kNotFound) return GetHeap()->undefined_value(); |
| 9717 return get(EntryToIndex(entry) + 1); | 9754 return get(EntryToIndex(entry) + 1); |
| 9718 } | 9755 } |
| 9719 | 9756 |
| 9720 | 9757 |
| 9721 Object* CompilationCacheTable::LookupRegExp(String* src, | 9758 Object* CompilationCacheTable::LookupRegExp(String* src, |
| 9722 JSRegExp::Flags flags) { | 9759 JSRegExp::Flags flags) { |
| 9723 Heap* heap = GetHeap(); | |
| 9724 RegExpKey key(src, flags); | 9760 RegExpKey key(src, flags); |
| 9725 int entry = FindEntry(&key); | 9761 int entry = FindEntry(&key); |
| 9726 if (entry == kNotFound) return heap->undefined_value(); | 9762 if (entry == kNotFound) return GetHeap()->undefined_value(); |
| 9727 return get(EntryToIndex(entry) + 1); | 9763 return get(EntryToIndex(entry) + 1); |
| 9728 } | 9764 } |
| 9729 | 9765 |
| 9730 | 9766 |
| 9731 MaybeObject* CompilationCacheTable::Put(String* src, Object* value) { | 9767 MaybeObject* CompilationCacheTable::Put(String* src, Object* value) { |
| 9732 StringKey key(src); | 9768 StringKey key(src); |
| 9733 Object* obj; | 9769 Object* obj; |
| 9734 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); | 9770 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); |
| 9735 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 9771 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 9736 } | 9772 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9836 } | 9872 } |
| 9837 | 9873 |
| 9838 Object* AsObject() { return symbols_; } | 9874 Object* AsObject() { return symbols_; } |
| 9839 | 9875 |
| 9840 private: | 9876 private: |
| 9841 FixedArray* symbols_; | 9877 FixedArray* symbols_; |
| 9842 }; | 9878 }; |
| 9843 | 9879 |
| 9844 | 9880 |
| 9845 Object* MapCache::Lookup(FixedArray* array) { | 9881 Object* MapCache::Lookup(FixedArray* array) { |
| 9846 Heap* heap = GetHeap(); | |
| 9847 SymbolsKey key(array); | 9882 SymbolsKey key(array); |
| 9848 int entry = FindEntry(&key); | 9883 int entry = FindEntry(&key); |
| 9849 if (entry == kNotFound) return heap->undefined_value(); | 9884 if (entry == kNotFound) return GetHeap()->undefined_value(); |
| 9850 return get(EntryToIndex(entry) + 1); | 9885 return get(EntryToIndex(entry) + 1); |
| 9851 } | 9886 } |
| 9852 | 9887 |
| 9853 | 9888 |
| 9854 MaybeObject* MapCache::Put(FixedArray* array, Map* value) { | 9889 MaybeObject* MapCache::Put(FixedArray* array, Map* value) { |
| 9855 SymbolsKey key(array); | 9890 SymbolsKey key(array); |
| 9856 Object* obj; | 9891 Object* obj; |
| 9857 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); | 9892 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); |
| 9858 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 9893 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 9859 } | 9894 } |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10195 storage->set(index++, k); | 10230 storage->set(index++, k); |
| 10196 } | 10231 } |
| 10197 } | 10232 } |
| 10198 ASSERT(storage->length() >= index); | 10233 ASSERT(storage->length() >= index); |
| 10199 } | 10234 } |
| 10200 | 10235 |
| 10201 | 10236 |
| 10202 // Backwards lookup (slow). | 10237 // Backwards lookup (slow). |
| 10203 template<typename Shape, typename Key> | 10238 template<typename Shape, typename Key> |
| 10204 Object* Dictionary<Shape, Key>::SlowReverseLookup(Object* value) { | 10239 Object* Dictionary<Shape, Key>::SlowReverseLookup(Object* value) { |
| 10205 Heap* heap = Dictionary<Shape, Key>::GetHeap(); | |
| 10206 int capacity = HashTable<Shape, Key>::Capacity(); | 10240 int capacity = HashTable<Shape, Key>::Capacity(); |
| 10207 for (int i = 0; i < capacity; i++) { | 10241 for (int i = 0; i < capacity; i++) { |
| 10208 Object* k = HashTable<Shape, Key>::KeyAt(i); | 10242 Object* k = HashTable<Shape, Key>::KeyAt(i); |
| 10209 if (Dictionary<Shape, Key>::IsKey(k)) { | 10243 if (Dictionary<Shape, Key>::IsKey(k)) { |
| 10210 Object* e = ValueAt(i); | 10244 Object* e = ValueAt(i); |
| 10211 if (e->IsJSGlobalPropertyCell()) { | 10245 if (e->IsJSGlobalPropertyCell()) { |
| 10212 e = JSGlobalPropertyCell::cast(e)->value(); | 10246 e = JSGlobalPropertyCell::cast(e)->value(); |
| 10213 } | 10247 } |
| 10214 if (e == value) return k; | 10248 if (e == value) return k; |
| 10215 } | 10249 } |
| 10216 } | 10250 } |
| 10251 Heap* heap = Dictionary<Shape, Key>::GetHeap(); |
| 10217 return heap->undefined_value(); | 10252 return heap->undefined_value(); |
| 10218 } | 10253 } |
| 10219 | 10254 |
| 10220 | 10255 |
| 10221 MaybeObject* StringDictionary::TransformPropertiesToFastFor( | 10256 MaybeObject* StringDictionary::TransformPropertiesToFastFor( |
| 10222 JSObject* obj, int unused_property_fields) { | 10257 JSObject* obj, int unused_property_fields) { |
| 10223 Heap* heap = GetHeap(); | |
| 10224 // Make sure we preserve dictionary representation if there are too many | 10258 // Make sure we preserve dictionary representation if there are too many |
| 10225 // descriptors. | 10259 // descriptors. |
| 10226 if (NumberOfElements() > DescriptorArray::kMaxNumberOfDescriptors) return obj; | 10260 if (NumberOfElements() > DescriptorArray::kMaxNumberOfDescriptors) return obj; |
| 10227 | 10261 |
| 10228 // Figure out if it is necessary to generate new enumeration indices. | 10262 // Figure out if it is necessary to generate new enumeration indices. |
| 10229 int max_enumeration_index = | 10263 int max_enumeration_index = |
| 10230 NextEnumerationIndex() + | 10264 NextEnumerationIndex() + |
| 10231 (DescriptorArray::kMaxNumberOfDescriptors - | 10265 (DescriptorArray::kMaxNumberOfDescriptors - |
| 10232 NumberOfElements()); | 10266 NumberOfElements()); |
| 10233 if (!PropertyDetails::IsValidIndex(max_enumeration_index)) { | 10267 if (!PropertyDetails::IsValidIndex(max_enumeration_index)) { |
| 10234 Object* result; | 10268 Object* result; |
| 10235 { MaybeObject* maybe_result = GenerateNewEnumerationIndices(); | 10269 { MaybeObject* maybe_result = GenerateNewEnumerationIndices(); |
| 10236 if (!maybe_result->ToObject(&result)) return maybe_result; | 10270 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 10237 } | 10271 } |
| 10238 } | 10272 } |
| 10239 | 10273 |
| 10240 int instance_descriptor_length = 0; | 10274 int instance_descriptor_length = 0; |
| 10241 int number_of_fields = 0; | 10275 int number_of_fields = 0; |
| 10242 | 10276 |
| 10277 Heap* heap = GetHeap(); |
| 10278 |
| 10243 // Compute the length of the instance descriptor. | 10279 // Compute the length of the instance descriptor. |
| 10244 int capacity = Capacity(); | 10280 int capacity = Capacity(); |
| 10245 for (int i = 0; i < capacity; i++) { | 10281 for (int i = 0; i < capacity; i++) { |
| 10246 Object* k = KeyAt(i); | 10282 Object* k = KeyAt(i); |
| 10247 if (IsKey(k)) { | 10283 if (IsKey(k)) { |
| 10248 Object* value = ValueAt(i); | 10284 Object* value = ValueAt(i); |
| 10249 PropertyType type = DetailsAt(i).type(); | 10285 PropertyType type = DetailsAt(i).type(); |
| 10250 ASSERT(type != FIELD); | 10286 ASSERT(type != FIELD); |
| 10251 instance_descriptor_length++; | 10287 instance_descriptor_length++; |
| 10252 if (type == NORMAL && | 10288 if (type == NORMAL && |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10361 | 10397 |
| 10362 // If there is no break point info object or no break points in the break | 10398 // If there is no break point info object or no break points in the break |
| 10363 // point info object there is no break point at this code position. | 10399 // point info object there is no break point at this code position. |
| 10364 if (break_point_info->IsUndefined()) return false; | 10400 if (break_point_info->IsUndefined()) return false; |
| 10365 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; | 10401 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; |
| 10366 } | 10402 } |
| 10367 | 10403 |
| 10368 | 10404 |
| 10369 // Get the break point info object for this code position. | 10405 // Get the break point info object for this code position. |
| 10370 Object* DebugInfo::GetBreakPointInfo(int code_position) { | 10406 Object* DebugInfo::GetBreakPointInfo(int code_position) { |
| 10371 Heap* heap = GetHeap(); | |
| 10372 // Find the index of the break point info object for this code position. | 10407 // Find the index of the break point info object for this code position. |
| 10373 int index = GetBreakPointInfoIndex(code_position); | 10408 int index = GetBreakPointInfoIndex(code_position); |
| 10374 | 10409 |
| 10375 // Return the break point info object if any. | 10410 // Return the break point info object if any. |
| 10376 if (index == kNoBreakPointInfo) return heap->undefined_value(); | 10411 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); |
| 10377 return BreakPointInfo::cast(break_points()->get(index)); | 10412 return BreakPointInfo::cast(break_points()->get(index)); |
| 10378 } | 10413 } |
| 10379 | 10414 |
| 10380 | 10415 |
| 10381 // Clear a break point at the specified code position. | 10416 // Clear a break point at the specified code position. |
| 10382 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, | 10417 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, |
| 10383 int code_position, | 10418 int code_position, |
| 10384 Handle<Object> break_point_object) { | 10419 Handle<Object> break_point_object) { |
| 10385 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position)); | 10420 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position)); |
| 10386 if (break_point_info->IsUndefined()) return; | 10421 if (break_point_info->IsUndefined()) return; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10439 set_statement_position(Smi::FromInt(statement_position)); | 10474 set_statement_position(Smi::FromInt(statement_position)); |
| 10440 new_break_point_info->set_break_point_objects( | 10475 new_break_point_info->set_break_point_objects( |
| 10441 isolate->heap()->undefined_value()); | 10476 isolate->heap()->undefined_value()); |
| 10442 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); | 10477 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); |
| 10443 debug_info->break_points()->set(index, *new_break_point_info); | 10478 debug_info->break_points()->set(index, *new_break_point_info); |
| 10444 } | 10479 } |
| 10445 | 10480 |
| 10446 | 10481 |
| 10447 // Get the break point objects for a code position. | 10482 // Get the break point objects for a code position. |
| 10448 Object* DebugInfo::GetBreakPointObjects(int code_position) { | 10483 Object* DebugInfo::GetBreakPointObjects(int code_position) { |
| 10449 Heap* heap = GetHeap(); | |
| 10450 Object* break_point_info = GetBreakPointInfo(code_position); | 10484 Object* break_point_info = GetBreakPointInfo(code_position); |
| 10451 if (break_point_info->IsUndefined()) { | 10485 if (break_point_info->IsUndefined()) { |
| 10452 return heap->undefined_value(); | 10486 return GetHeap()->undefined_value(); |
| 10453 } | 10487 } |
| 10454 return BreakPointInfo::cast(break_point_info)->break_point_objects(); | 10488 return BreakPointInfo::cast(break_point_info)->break_point_objects(); |
| 10455 } | 10489 } |
| 10456 | 10490 |
| 10457 | 10491 |
| 10458 // Get the total number of break points. | 10492 // Get the total number of break points. |
| 10459 int DebugInfo::GetBreakPointCount() { | 10493 int DebugInfo::GetBreakPointCount() { |
| 10460 if (break_points()->IsUndefined()) return 0; | 10494 if (break_points()->IsUndefined()) return 0; |
| 10461 int count = 0; | 10495 int count = 0; |
| 10462 for (int i = 0; i < break_points()->length(); i++) { | 10496 for (int i = 0; i < break_points()->length(); i++) { |
| 10463 if (!break_points()->get(i)->IsUndefined()) { | 10497 if (!break_points()->get(i)->IsUndefined()) { |
| 10464 BreakPointInfo* break_point_info = | 10498 BreakPointInfo* break_point_info = |
| 10465 BreakPointInfo::cast(break_points()->get(i)); | 10499 BreakPointInfo::cast(break_points()->get(i)); |
| 10466 count += break_point_info->GetBreakPointCount(); | 10500 count += break_point_info->GetBreakPointCount(); |
| 10467 } | 10501 } |
| 10468 } | 10502 } |
| 10469 return count; | 10503 return count; |
| 10470 } | 10504 } |
| 10471 | 10505 |
| 10472 | 10506 |
| 10473 Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info, | 10507 Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info, |
| 10474 Handle<Object> break_point_object) { | 10508 Handle<Object> break_point_object) { |
| 10475 Heap* heap = Isolate::Current()->heap(); | 10509 Heap* heap = debug_info->GetHeap(); |
| 10476 if (debug_info->break_points()->IsUndefined()) return heap->undefined_value(); | 10510 if (debug_info->break_points()->IsUndefined()) return heap->undefined_value(); |
| 10477 for (int i = 0; i < debug_info->break_points()->length(); i++) { | 10511 for (int i = 0; i < debug_info->break_points()->length(); i++) { |
| 10478 if (!debug_info->break_points()->get(i)->IsUndefined()) { | 10512 if (!debug_info->break_points()->get(i)->IsUndefined()) { |
| 10479 Handle<BreakPointInfo> break_point_info = | 10513 Handle<BreakPointInfo> break_point_info = |
| 10480 Handle<BreakPointInfo>(BreakPointInfo::cast( | 10514 Handle<BreakPointInfo>(BreakPointInfo::cast( |
| 10481 debug_info->break_points()->get(i))); | 10515 debug_info->break_points()->get(i))); |
| 10482 if (BreakPointInfo::HasBreakPointObject(break_point_info, | 10516 if (BreakPointInfo::HasBreakPointObject(break_point_info, |
| 10483 break_point_object)) { | 10517 break_point_object)) { |
| 10484 return *break_point_info; | 10518 return *break_point_info; |
| 10485 } | 10519 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10602 if (break_point_objects()->IsUndefined()) return 0; | 10636 if (break_point_objects()->IsUndefined()) return 0; |
| 10603 // Single beak point. | 10637 // Single beak point. |
| 10604 if (!break_point_objects()->IsFixedArray()) return 1; | 10638 if (!break_point_objects()->IsFixedArray()) return 1; |
| 10605 // Multiple break points. | 10639 // Multiple break points. |
| 10606 return FixedArray::cast(break_point_objects())->length(); | 10640 return FixedArray::cast(break_point_objects())->length(); |
| 10607 } | 10641 } |
| 10608 #endif | 10642 #endif |
| 10609 | 10643 |
| 10610 | 10644 |
| 10611 } } // namespace v8::internal | 10645 } } // namespace v8::internal |
| OLD | NEW |