Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: src/objects.cc

Issue 2866008: [Isolates] Move contents of Top into Isolate.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: ensure we're synced Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return CreateJSValue(global_context->boolean_function(), this); 68 return CreateJSValue(global_context->boolean_function(), this);
69 } else if (IsString()) { 69 } else if (IsString()) {
70 return CreateJSValue(global_context->string_function(), this); 70 return CreateJSValue(global_context->string_function(), this);
71 } 71 }
72 ASSERT(IsJSObject()); 72 ASSERT(IsJSObject());
73 return this; 73 return this;
74 } 74 }
75 75
76 76
77 Object* Object::ToObject() { 77 Object* Object::ToObject() {
78 Context* global_context = Top::context()->global_context(); 78 Context* global_context = Isolate::Current()->context()->global_context();
79 if (IsJSObject()) { 79 if (IsJSObject()) {
80 return this; 80 return this;
81 } else if (IsNumber()) { 81 } else if (IsNumber()) {
82 return CreateJSValue(global_context->number_function(), this); 82 return CreateJSValue(global_context->number_function(), this);
83 } else if (IsBoolean()) { 83 } else if (IsBoolean()) {
84 return CreateJSValue(global_context->boolean_function(), this); 84 return CreateJSValue(global_context->boolean_function(), this);
85 } else if (IsString()) { 85 } else if (IsString()) {
86 return CreateJSValue(global_context->string_function(), this); 86 return CreateJSValue(global_context->string_function(), this);
87 } 87 }
88 88
(...skipping 19 matching lines...) Expand all
108 if (IsHeapNumber()) { 108 if (IsHeapNumber()) {
109 return HeapNumber::cast(this)->HeapNumberToBoolean(); 109 return HeapNumber::cast(this)->HeapNumberToBoolean();
110 } 110 }
111 return HEAP->true_value(); 111 return HEAP->true_value();
112 } 112 }
113 113
114 114
115 void Object::Lookup(String* name, LookupResult* result) { 115 void Object::Lookup(String* name, LookupResult* result) {
116 if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result); 116 if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result);
117 Object* holder = NULL; 117 Object* holder = NULL;
118 Context* global_context = Top::context()->global_context(); 118 Context* global_context = Isolate::Current()->context()->global_context();
119 if (IsString()) { 119 if (IsString()) {
120 holder = global_context->string_function()->instance_prototype(); 120 holder = global_context->string_function()->instance_prototype();
121 } else if (IsNumber()) { 121 } else if (IsNumber()) {
122 holder = global_context->number_function()->instance_prototype(); 122 holder = global_context->number_function()->instance_prototype();
123 } else if (IsBoolean()) { 123 } else if (IsBoolean()) {
124 holder = global_context->boolean_function()->instance_prototype(); 124 holder = global_context->boolean_function()->instance_prototype();
125 } 125 }
126 ASSERT(holder != NULL); // Cannot handle null or undefined. 126 ASSERT(holder != NULL); // Cannot handle null or undefined.
127 JSObject::cast(holder)->Lookup(name, result); 127 JSObject::cast(holder)->Lookup(name, result);
128 } 128 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 break; 264 break;
265 } 265 }
266 default: 266 default:
267 UNREACHABLE(); 267 UNREACHABLE();
268 } 268 }
269 } 269 }
270 270
271 // No accessible property found. 271 // No accessible property found.
272 *attributes = ABSENT; 272 *attributes = ABSENT;
273 Top::ReportFailedAccessCheck(this, v8::ACCESS_GET); 273 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
274 return HEAP->undefined_value(); 274 return HEAP->undefined_value();
275 } 275 }
276 276
277 277
278 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( 278 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
279 Object* receiver, 279 Object* receiver,
280 LookupResult* result, 280 LookupResult* result,
281 String* name, 281 String* name,
282 bool continue_search) { 282 bool continue_search) {
283 if (result->IsProperty()) { 283 if (result->IsProperty()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 continue_search); 326 continue_search);
327 } 327 }
328 break; 328 break;
329 } 329 }
330 330
331 default: 331 default:
332 UNREACHABLE(); 332 UNREACHABLE();
333 } 333 }
334 } 334 }
335 335
336 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 336 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
337 return ABSENT; 337 return ABSENT;
338 } 338 }
339 339
340 340
341 Object* JSObject::GetNormalizedProperty(LookupResult* result) { 341 Object* JSObject::GetNormalizedProperty(LookupResult* result) {
342 ASSERT(!HasFastProperties()); 342 ASSERT(!HasFastProperties());
343 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); 343 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry());
344 if (IsGlobalObject()) { 344 if (IsGlobalObject()) {
345 value = JSGlobalPropertyCell::cast(value)->value(); 345 value = JSGlobalPropertyCell::cast(value)->value();
346 } 346 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // only continue with a current object just after the interceptor 456 // only continue with a current object just after the interceptor
457 // holder in the prototype chain. 457 // holder in the prototype chain.
458 Object* last = result->IsProperty() ? result->holder() : HEAP->null_value(); 458 Object* last = result->IsProperty() ? result->holder() : HEAP->null_value();
459 for (Object* current = this; true; current = current->GetPrototype()) { 459 for (Object* current = this; true; current = current->GetPrototype()) {
460 if (current->IsAccessCheckNeeded()) { 460 if (current->IsAccessCheckNeeded()) {
461 // Check if we're allowed to read from the current object. Note 461 // Check if we're allowed to read from the current object. Note
462 // that even though we may not actually end up loading the named 462 // that even though we may not actually end up loading the named
463 // property from the current object, we still check that we have 463 // property from the current object, we still check that we have
464 // access to it. 464 // access to it.
465 JSObject* checked = JSObject::cast(current); 465 JSObject* checked = JSObject::cast(current);
466 if (!Top::MayNamedAccess(checked, name, v8::ACCESS_GET)) { 466 if (!Isolate::Current()->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
467 return checked->GetPropertyWithFailedAccessCheck(receiver, 467 return checked->GetPropertyWithFailedAccessCheck(receiver,
468 result, 468 result,
469 name, 469 name,
470 attributes); 470 attributes);
471 } 471 }
472 } 472 }
473 // Stop traversing the chain once we reach the last object in the 473 // Stop traversing the chain once we reach the last object in the
474 // chain; either the holder of the result or null in case of an 474 // chain; either the holder of the result or null in case of an
475 // absent property. 475 // absent property.
476 if (current == last) break; 476 if (current == last) break;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // Non-JS objects do not have integer indexed properties. 514 // Non-JS objects do not have integer indexed properties.
515 if (!IsJSObject()) return HEAP->undefined_value(); 515 if (!IsJSObject()) return HEAP->undefined_value();
516 return JSObject::cast(this)->GetElementWithReceiver(JSObject::cast(receiver), 516 return JSObject::cast(this)->GetElementWithReceiver(JSObject::cast(receiver),
517 index); 517 index);
518 } 518 }
519 519
520 520
521 Object* Object::GetPrototype() { 521 Object* Object::GetPrototype() {
522 // The object is either a number, a string, a boolean, or a real JS object. 522 // The object is either a number, a string, a boolean, or a real JS object.
523 if (IsJSObject()) return JSObject::cast(this)->map()->prototype(); 523 if (IsJSObject()) return JSObject::cast(this)->map()->prototype();
524 Context* context = Top::context()->global_context(); 524 Context* context = Isolate::Current()->context()->global_context();
525 525
526 if (IsNumber()) return context->number_function()->instance_prototype(); 526 if (IsNumber()) return context->number_function()->instance_prototype();
527 if (IsString()) return context->string_function()->instance_prototype(); 527 if (IsString()) return context->string_function()->instance_prototype();
528 if (IsBoolean()) { 528 if (IsBoolean()) {
529 return context->boolean_function()->instance_prototype(); 529 return context->boolean_function()->instance_prototype();
530 } else { 530 } else {
531 return HEAP->null_value(); 531 return HEAP->null_value();
532 } 532 }
533 } 533 }
534 534
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 int requested = requested_bytes >> kObjectAlignmentBits; 580 int requested = requested_bytes >> kObjectAlignmentBits;
581 int value = (requested << kSpaceTagSize) | space; 581 int value = (requested << kSpaceTagSize) | space;
582 // We can't very well allocate a heap number in this situation, and if the 582 // We can't very well allocate a heap number in this situation, and if the
583 // requested memory is so large it seems reasonable to say that this is an 583 // requested memory is so large it seems reasonable to say that this is an
584 // out of memory situation. This fixes a crash in 584 // out of memory situation. This fixes a crash in
585 // js1_5/Regress/regress-303213.js. 585 // js1_5/Regress/regress-303213.js.
586 if (value >> kSpaceTagSize != requested || 586 if (value >> kSpaceTagSize != requested ||
587 !Smi::IsValid(value) || 587 !Smi::IsValid(value) ||
588 value != ((value << kFailureTypeTagSize) >> kFailureTypeTagSize) || 588 value != ((value << kFailureTypeTagSize) >> kFailureTypeTagSize) ||
589 !Smi::IsValid(value << kFailureTypeTagSize)) { 589 !Smi::IsValid(value << kFailureTypeTagSize)) {
590 Top::context()->mark_out_of_memory(); 590 Isolate::Current()->context()->mark_out_of_memory();
591 return Failure::OutOfMemoryException(); 591 return Failure::OutOfMemoryException();
592 } 592 }
593 return Construct(RETRY_AFTER_GC, value); 593 return Construct(RETRY_AFTER_GC, value);
594 } 594 }
595 595
596 596
597 // Should a word be prefixed by 'a' or 'an' in order to read naturally in 597 // Should a word be prefixed by 'a' or 'an' in order to read naturally in
598 // English? Returns false for non-ASCII or words that don't start with 598 // English? Returns false for non-ASCII or words that don't start with
599 // a capital letter. The a/an rule follows pronunciation in English. 599 // a capital letter. The a/an rule follows pronunciation in English.
600 // We don't use the BBC's overcorrect "an historic occasion" though if 600 // We don't use the BBC's overcorrect "an historic occasion" though if
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 // Allocate new instance descriptors with (name, index) added 1245 // Allocate new instance descriptors with (name, index) added
1246 FieldDescriptor new_field(name, index, attributes); 1246 FieldDescriptor new_field(name, index, attributes);
1247 Object* new_descriptors = 1247 Object* new_descriptors =
1248 old_descriptors->CopyInsert(&new_field, REMOVE_TRANSITIONS); 1248 old_descriptors->CopyInsert(&new_field, REMOVE_TRANSITIONS);
1249 if (new_descriptors->IsFailure()) return new_descriptors; 1249 if (new_descriptors->IsFailure()) return new_descriptors;
1250 1250
1251 // Only allow map transition if the object's map is NOT equal to the 1251 // Only allow map transition if the object's map is NOT equal to the
1252 // global object_function's map and there is not a transition for name. 1252 // global object_function's map and there is not a transition for name.
1253 bool allow_map_transition = 1253 bool allow_map_transition =
1254 !old_descriptors->Contains(name) && 1254 !old_descriptors->Contains(name) &&
1255 (Top::context()->global_context()->object_function()->map() != map()); 1255 (Isolate::Current()->context()->global_context()->object_function()->
1256 map() != map());
1256 1257
1257 ASSERT(index < map()->inobject_properties() || 1258 ASSERT(index < map()->inobject_properties() ||
1258 (index - map()->inobject_properties()) < properties()->length() || 1259 (index - map()->inobject_properties()) < properties()->length() ||
1259 map()->unused_property_fields() == 0); 1260 map()->unused_property_fields() == 0);
1260 // Allocate a new map for the object. 1261 // Allocate a new map for the object.
1261 Object* r = map()->CopyDropDescriptors(); 1262 Object* r = map()->CopyDropDescriptors();
1262 if (r->IsFailure()) return r; 1263 if (r->IsFailure()) return r;
1263 Map* new_map = Map::cast(r); 1264 Map* new_map = Map::cast(r);
1264 if (allow_map_transition) { 1265 if (allow_map_transition) {
1265 // Allocate new instance descriptors for the old map with map transition. 1266 // Allocate new instance descriptors for the old map with map transition.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 Object* new_map = map()->CopyDropDescriptors(); 1309 Object* new_map = map()->CopyDropDescriptors();
1309 if (new_map->IsFailure()) return new_map; 1310 if (new_map->IsFailure()) return new_map;
1310 1311
1311 DescriptorArray* descriptors = DescriptorArray::cast(new_descriptors); 1312 DescriptorArray* descriptors = DescriptorArray::cast(new_descriptors);
1312 Map::cast(new_map)->set_instance_descriptors(descriptors); 1313 Map::cast(new_map)->set_instance_descriptors(descriptors);
1313 Map* old_map = map(); 1314 Map* old_map = map();
1314 set_map(Map::cast(new_map)); 1315 set_map(Map::cast(new_map));
1315 1316
1316 // If the old map is the global object map (from new Object()), 1317 // If the old map is the global object map (from new Object()),
1317 // then transitions are not added to it, so we are done. 1318 // then transitions are not added to it, so we are done.
1318 if (old_map == Top::context()->global_context()->object_function()->map()) { 1319 if (old_map == Isolate::Current()->context()->global_context()->
1320 object_function()->map()) {
1319 return function; 1321 return function;
1320 } 1322 }
1321 1323
1322 // Do not add CONSTANT_TRANSITIONS to global objects 1324 // Do not add CONSTANT_TRANSITIONS to global objects
1323 if (IsGlobalObject()) { 1325 if (IsGlobalObject()) {
1324 return function; 1326 return function;
1325 } 1327 }
1326 1328
1327 // Add a CONSTANT_TRANSITION descriptor to the old map, 1329 // Add a CONSTANT_TRANSITION descriptor to the old map,
1328 // so future assignments to this property on other objects 1330 // so future assignments to this property on other objects
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 PropertyAttributes attributes) { 1443 PropertyAttributes attributes) {
1442 Map* old_map = map(); 1444 Map* old_map = map();
1443 Object* result = ConvertDescriptorToField(name, new_value, attributes); 1445 Object* result = ConvertDescriptorToField(name, new_value, attributes);
1444 if (result->IsFailure()) return result; 1446 if (result->IsFailure()) return result;
1445 // If we get to this point we have succeeded - do not return failure 1447 // If we get to this point we have succeeded - do not return failure
1446 // after this point. Later stuff is optional. 1448 // after this point. Later stuff is optional.
1447 if (!HasFastProperties()) { 1449 if (!HasFastProperties()) {
1448 return result; 1450 return result;
1449 } 1451 }
1450 // Do not add transitions to the map of "new Object()". 1452 // Do not add transitions to the map of "new Object()".
1451 if (map() == Top::context()->global_context()->object_function()->map()) { 1453 if (map() == Isolate::Current()->context()->global_context()->
1454 object_function()->map()) {
1452 return result; 1455 return result;
1453 } 1456 }
1454 1457
1455 MapTransitionDescriptor transition(name, 1458 MapTransitionDescriptor transition(name,
1456 map(), 1459 map(),
1457 attributes); 1460 attributes);
1458 Object* new_descriptors = 1461 Object* new_descriptors =
1459 old_map->instance_descriptors()-> 1462 old_map->instance_descriptors()->
1460 CopyInsert(&transition, KEEP_TRANSITIONS); 1463 CopyInsert(&transition, KEEP_TRANSITIONS);
1461 if (new_descriptors->IsFailure()) return result; // Yes, return _result_. 1464 if (new_descriptors->IsFailure()) return result; // Yes, return _result_.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 } 1605 }
1603 1606
1604 if (structure->IsFixedArray()) { 1607 if (structure->IsFixedArray()) {
1605 Object* setter = FixedArray::cast(structure)->get(kSetterIndex); 1608 Object* setter = FixedArray::cast(structure)->get(kSetterIndex);
1606 if (setter->IsJSFunction()) { 1609 if (setter->IsJSFunction()) {
1607 return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value); 1610 return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
1608 } else { 1611 } else {
1609 Handle<String> key(name); 1612 Handle<String> key(name);
1610 Handle<Object> holder_handle(holder); 1613 Handle<Object> holder_handle(holder);
1611 Handle<Object> args[2] = { key, holder_handle }; 1614 Handle<Object> args[2] = { key, holder_handle };
1612 return Top::Throw(*Factory::NewTypeError("no_setter_in_callback", 1615 return Isolate::Current()->Throw(
1613 HandleVector(args, 2))); 1616 *Factory::NewTypeError("no_setter_in_callback",
1617 HandleVector(args, 2)));
1614 } 1618 }
1615 } 1619 }
1616 1620
1617 UNREACHABLE(); 1621 UNREACHABLE();
1618 return NULL; 1622 return NULL;
1619 } 1623 }
1620 1624
1621 1625
1622 Object* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter, 1626 Object* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter,
1623 Object* value) { 1627 Object* value) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 } 1808 }
1805 break; 1809 break;
1806 } 1810 }
1807 default: { 1811 default: {
1808 break; 1812 break;
1809 } 1813 }
1810 } 1814 }
1811 } 1815 }
1812 } 1816 }
1813 1817
1814 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET); 1818 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
1815 return value; 1819 return value;
1816 } 1820 }
1817 1821
1818 1822
1819 Object* JSObject::SetProperty(LookupResult* result, 1823 Object* JSObject::SetProperty(LookupResult* result,
1820 String* name, 1824 String* name,
1821 Object* value, 1825 Object* value,
1822 PropertyAttributes attributes) { 1826 PropertyAttributes attributes) {
1823 // Make sure that the top context does not change when doing callbacks or 1827 // Make sure that the top context does not change when doing callbacks or
1824 // interceptor calls. 1828 // interceptor calls.
1825 AssertNoContextChange ncc; 1829 AssertNoContextChange ncc;
1826 1830
1827 // Optimization for 2-byte strings often used as keys in a decompression 1831 // Optimization for 2-byte strings often used as keys in a decompression
1828 // dictionary. We make these short keys into symbols to avoid constantly 1832 // dictionary. We make these short keys into symbols to avoid constantly
1829 // reallocating them. 1833 // reallocating them.
1830 if (!name->IsSymbol() && name->length() <= 2) { 1834 if (!name->IsSymbol() && name->length() <= 2) {
1831 Object* symbol_version = HEAP->LookupSymbol(name); 1835 Object* symbol_version = HEAP->LookupSymbol(name);
1832 if (!symbol_version->IsFailure()) name = String::cast(symbol_version); 1836 if (!symbol_version->IsFailure()) name = String::cast(symbol_version);
1833 } 1837 }
1834 1838
1835 // Check access rights if needed. 1839 // Check access rights if needed.
1836 if (IsAccessCheckNeeded() 1840 if (IsAccessCheckNeeded()
1837 && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { 1841 && !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
1838 return SetPropertyWithFailedAccessCheck(result, name, value); 1842 return SetPropertyWithFailedAccessCheck(result, name, value);
1839 } 1843 }
1840 1844
1841 if (IsJSGlobalProxy()) { 1845 if (IsJSGlobalProxy()) {
1842 Object* proto = GetPrototype(); 1846 Object* proto = GetPrototype();
1843 if (proto->IsNull()) return value; 1847 if (proto->IsNull()) return value;
1844 ASSERT(proto->IsJSGlobalObject()); 1848 ASSERT(proto->IsJSGlobalObject());
1845 return JSObject::cast(proto)->SetProperty(result, name, value, attributes); 1849 return JSObject::cast(proto)->SetProperty(result, name, value, attributes);
1846 } 1850 }
1847 1851
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 String* name, 1918 String* name,
1915 Object* value, 1919 Object* value,
1916 PropertyAttributes attributes) { 1920 PropertyAttributes attributes) {
1917 // Make sure that the top context does not change when doing callbacks or 1921 // Make sure that the top context does not change when doing callbacks or
1918 // interceptor calls. 1922 // interceptor calls.
1919 AssertNoContextChange ncc; 1923 AssertNoContextChange ncc;
1920 LookupResult result; 1924 LookupResult result;
1921 LocalLookup(name, &result); 1925 LocalLookup(name, &result);
1922 // Check access rights if needed. 1926 // Check access rights if needed.
1923 if (IsAccessCheckNeeded() 1927 if (IsAccessCheckNeeded()
1924 && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { 1928 && !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
1925 return SetPropertyWithFailedAccessCheck(&result, name, value); 1929 return SetPropertyWithFailedAccessCheck(&result, name, value);
1926 } 1930 }
1927 1931
1928 if (IsJSGlobalProxy()) { 1932 if (IsJSGlobalProxy()) {
1929 Object* proto = GetPrototype(); 1933 Object* proto = GetPrototype();
1930 if (proto->IsNull()) return value; 1934 if (proto->IsNull()) return value;
1931 ASSERT(proto->IsJSGlobalObject()); 1935 ASSERT(proto->IsJSGlobalObject());
1932 return JSObject::cast(proto)->IgnoreAttributesAndSetLocalProperty( 1936 return JSObject::cast(proto)->IgnoreAttributesAndSetLocalProperty(
1933 name, 1937 name,
1934 value, 1938 value,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 return GetPropertyAttribute(receiver, &result, key, true); 2067 return GetPropertyAttribute(receiver, &result, key, true);
2064 } 2068 }
2065 2069
2066 2070
2067 PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver, 2071 PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver,
2068 LookupResult* result, 2072 LookupResult* result,
2069 String* name, 2073 String* name,
2070 bool continue_search) { 2074 bool continue_search) {
2071 // Check access rights if needed. 2075 // Check access rights if needed.
2072 if (IsAccessCheckNeeded() && 2076 if (IsAccessCheckNeeded() &&
2073 !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) { 2077 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
2074 return GetPropertyAttributeWithFailedAccessCheck(receiver, 2078 return GetPropertyAttributeWithFailedAccessCheck(receiver,
2075 result, 2079 result,
2076 name, 2080 name,
2077 continue_search); 2081 continue_search);
2078 } 2082 }
2079 if (result->IsProperty()) { 2083 if (result->IsProperty()) {
2080 switch (result->type()) { 2084 switch (result->type()) {
2081 case NORMAL: // fall through 2085 case NORMAL: // fall through
2082 case FIELD: 2086 case FIELD:
2083 case CONSTANT_FUNCTION: 2087 case CONSTANT_FUNCTION:
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 Object* raw_result = 2360 Object* raw_result =
2357 this_handle->DeleteElementPostInterceptor(index, NORMAL_DELETION); 2361 this_handle->DeleteElementPostInterceptor(index, NORMAL_DELETION);
2358 RETURN_IF_SCHEDULED_EXCEPTION(); 2362 RETURN_IF_SCHEDULED_EXCEPTION();
2359 return raw_result; 2363 return raw_result;
2360 } 2364 }
2361 2365
2362 2366
2363 Object* JSObject::DeleteElement(uint32_t index, DeleteMode mode) { 2367 Object* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
2364 // Check access rights if needed. 2368 // Check access rights if needed.
2365 if (IsAccessCheckNeeded() && 2369 if (IsAccessCheckNeeded() &&
2366 !Top::MayIndexedAccess(this, index, v8::ACCESS_DELETE)) { 2370 !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
2367 Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 2371 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
2368 return HEAP->false_value(); 2372 return HEAP->false_value();
2369 } 2373 }
2370 2374
2371 if (IsJSGlobalProxy()) { 2375 if (IsJSGlobalProxy()) {
2372 Object* proto = GetPrototype(); 2376 Object* proto = GetPrototype();
2373 if (proto->IsNull()) return HEAP->false_value(); 2377 if (proto->IsNull()) return HEAP->false_value();
2374 ASSERT(proto->IsJSGlobalObject()); 2378 ASSERT(proto->IsJSGlobalObject());
2375 return JSGlobalObject::cast(proto)->DeleteElement(index, mode); 2379 return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
2376 } 2380 }
2377 2381
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 return HEAP->true_value(); 2423 return HEAP->true_value();
2420 } 2424 }
2421 2425
2422 2426
2423 Object* JSObject::DeleteProperty(String* name, DeleteMode mode) { 2427 Object* JSObject::DeleteProperty(String* name, DeleteMode mode) {
2424 // ECMA-262, 3rd, 8.6.2.5 2428 // ECMA-262, 3rd, 8.6.2.5
2425 ASSERT(name->IsString()); 2429 ASSERT(name->IsString());
2426 2430
2427 // Check access rights if needed. 2431 // Check access rights if needed.
2428 if (IsAccessCheckNeeded() && 2432 if (IsAccessCheckNeeded() &&
2429 !Top::MayNamedAccess(this, name, v8::ACCESS_DELETE)) { 2433 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
2430 Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 2434 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
2431 return HEAP->false_value(); 2435 return HEAP->false_value();
2432 } 2436 }
2433 2437
2434 if (IsJSGlobalProxy()) { 2438 if (IsJSGlobalProxy()) {
2435 Object* proto = GetPrototype(); 2439 Object* proto = GetPrototype();
2436 if (proto->IsNull()) return HEAP->false_value(); 2440 if (proto->IsNull()) return HEAP->false_value();
2437 ASSERT(proto->IsJSGlobalObject()); 2441 ASSERT(proto->IsJSGlobalObject());
2438 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); 2442 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
2439 } 2443 }
2440 2444
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 } 2524 }
2521 default: 2525 default:
2522 UNREACHABLE(); 2526 UNREACHABLE();
2523 break; 2527 break;
2524 } 2528 }
2525 2529
2526 // For functions check the context. 2530 // For functions check the context.
2527 if (IsJSFunction()) { 2531 if (IsJSFunction()) {
2528 // Get the constructor function for arguments array. 2532 // Get the constructor function for arguments array.
2529 JSObject* arguments_boilerplate = 2533 JSObject* arguments_boilerplate =
2530 Top::context()->global_context()->arguments_boilerplate(); 2534 Isolate::Current()->context()->global_context()->
2535 arguments_boilerplate();
2531 JSFunction* arguments_function = 2536 JSFunction* arguments_function =
2532 JSFunction::cast(arguments_boilerplate->map()->constructor()); 2537 JSFunction::cast(arguments_boilerplate->map()->constructor());
2533 2538
2534 // Get the context and don't check if it is the global context. 2539 // Get the context and don't check if it is the global context.
2535 JSFunction* f = JSFunction::cast(this); 2540 JSFunction* f = JSFunction::cast(this);
2536 Context* context = f->context(); 2541 Context* context = f->context();
2537 if (context->IsGlobalContext()) { 2542 if (context->IsGlobalContext()) {
2538 return false; 2543 return false;
2539 } 2544 }
2540 2545
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 if (is_element) { 2773 if (is_element) {
2769 return SetElementCallback(index, structure, attributes); 2774 return SetElementCallback(index, structure, attributes);
2770 } else { 2775 } else {
2771 return SetPropertyCallback(name, structure, attributes); 2776 return SetPropertyCallback(name, structure, attributes);
2772 } 2777 }
2773 } 2778 }
2774 2779
2775 2780
2776 bool JSObject::CanSetCallback(String* name) { 2781 bool JSObject::CanSetCallback(String* name) {
2777 ASSERT(!IsAccessCheckNeeded() 2782 ASSERT(!IsAccessCheckNeeded()
2778 || Top::MayNamedAccess(this, name, v8::ACCESS_SET)); 2783 || Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET));
2779 2784
2780 // Check if there is an API defined callback object which prohibits 2785 // Check if there is an API defined callback object which prohibits
2781 // callback overwriting in this object or it's prototype chain. 2786 // callback overwriting in this object or it's prototype chain.
2782 // This mechanism is needed for instance in a browser setting, where 2787 // This mechanism is needed for instance in a browser setting, where
2783 // certain accessors such as window.location should not be allowed 2788 // certain accessors such as window.location should not be allowed
2784 // to be overwritten because allowing overwriting could potentially 2789 // to be overwritten because allowing overwriting could potentially
2785 // cause security problems. 2790 // cause security problems.
2786 LookupResult callback_result; 2791 LookupResult callback_result;
2787 LookupCallback(name, &callback_result); 2792 LookupCallback(name, &callback_result);
2788 if (callback_result.IsProperty()) { 2793 if (callback_result.IsProperty()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 ok = TransformToFastProperties(0); 2854 ok = TransformToFastProperties(0);
2850 if (ok->IsFailure()) return ok; 2855 if (ok->IsFailure()) return ok;
2851 } 2856 }
2852 return result; 2857 return result;
2853 } 2858 }
2854 2859
2855 Object* JSObject::DefineAccessor(String* name, bool is_getter, JSFunction* fun, 2860 Object* JSObject::DefineAccessor(String* name, bool is_getter, JSFunction* fun,
2856 PropertyAttributes attributes) { 2861 PropertyAttributes attributes) {
2857 // Check access rights if needed. 2862 // Check access rights if needed.
2858 if (IsAccessCheckNeeded() && 2863 if (IsAccessCheckNeeded() &&
2859 !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { 2864 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
2860 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET); 2865 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
2861 return HEAP->undefined_value(); 2866 return HEAP->undefined_value();
2862 } 2867 }
2863 2868
2864 if (IsJSGlobalProxy()) { 2869 if (IsJSGlobalProxy()) {
2865 Object* proto = GetPrototype(); 2870 Object* proto = GetPrototype();
2866 if (proto->IsNull()) return this; 2871 if (proto->IsNull()) return this;
2867 ASSERT(proto->IsJSGlobalObject()); 2872 ASSERT(proto->IsJSGlobalObject());
2868 return JSObject::cast(proto)->DefineAccessor(name, is_getter, 2873 return JSObject::cast(proto)->DefineAccessor(name, is_getter,
2869 fun, attributes); 2874 fun, attributes);
2870 } 2875 }
2871 2876
2872 Object* array = DefineGetterSetter(name, attributes); 2877 Object* array = DefineGetterSetter(name, attributes);
2873 if (array->IsFailure() || array->IsUndefined()) return array; 2878 if (array->IsFailure() || array->IsUndefined()) return array;
2874 FixedArray::cast(array)->set(is_getter ? 0 : 1, fun); 2879 FixedArray::cast(array)->set(is_getter ? 0 : 1, fun);
2875 return this; 2880 return this;
2876 } 2881 }
2877 2882
2878 2883
2879 Object* JSObject::DefineAccessor(AccessorInfo* info) { 2884 Object* JSObject::DefineAccessor(AccessorInfo* info) {
2880 String* name = String::cast(info->name()); 2885 String* name = String::cast(info->name());
2881 // Check access rights if needed. 2886 // Check access rights if needed.
2882 if (IsAccessCheckNeeded() && 2887 if (IsAccessCheckNeeded() &&
2883 !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { 2888 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
2884 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET); 2889 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
2885 return HEAP->undefined_value(); 2890 return HEAP->undefined_value();
2886 } 2891 }
2887 2892
2888 if (IsJSGlobalProxy()) { 2893 if (IsJSGlobalProxy()) {
2889 Object* proto = GetPrototype(); 2894 Object* proto = GetPrototype();
2890 if (proto->IsNull()) return this; 2895 if (proto->IsNull()) return this;
2891 ASSERT(proto->IsJSGlobalObject()); 2896 ASSERT(proto->IsJSGlobalObject());
2892 return JSObject::cast(proto)->DefineAccessor(info); 2897 return JSObject::cast(proto)->DefineAccessor(info);
2893 } 2898 }
2894 2899
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 } 2953 }
2949 2954
2950 2955
2951 Object* JSObject::LookupAccessor(String* name, bool is_getter) { 2956 Object* JSObject::LookupAccessor(String* name, bool is_getter) {
2952 // Make sure that the top context does not change when doing callbacks or 2957 // Make sure that the top context does not change when doing callbacks or
2953 // interceptor calls. 2958 // interceptor calls.
2954 AssertNoContextChange ncc; 2959 AssertNoContextChange ncc;
2955 2960
2956 // Check access rights if needed. 2961 // Check access rights if needed.
2957 if (IsAccessCheckNeeded() && 2962 if (IsAccessCheckNeeded() &&
2958 !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) { 2963 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
2959 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 2964 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
2960 return HEAP->undefined_value(); 2965 return HEAP->undefined_value();
2961 } 2966 }
2962 2967
2963 // Make the lookup and include prototypes. 2968 // Make the lookup and include prototypes.
2964 int accessor_index = is_getter ? kGetterIndex : kSetterIndex; 2969 int accessor_index = is_getter ? kGetterIndex : kSetterIndex;
2965 uint32_t index = 0; 2970 uint32_t index = 0;
2966 if (name->AsArrayIndex(&index)) { 2971 if (name->AsArrayIndex(&index)) {
2967 for (Object* obj = this; 2972 for (Object* obj = this;
2968 obj != HEAP->null_value(); 2973 obj != HEAP->null_value();
2969 obj = JSObject::cast(obj)->GetPrototype()) { 2974 obj = JSObject::cast(obj)->GetPrototype()) {
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
5033 if (!value->IsJSObject()) { 5038 if (!value->IsJSObject()) {
5034 // Copy the map so this does not affect unrelated functions. 5039 // Copy the map so this does not affect unrelated functions.
5035 // Remove map transitions because they point to maps with a 5040 // Remove map transitions because they point to maps with a
5036 // different prototype. 5041 // different prototype.
5037 Object* new_map = map()->CopyDropTransitions(); 5042 Object* new_map = map()->CopyDropTransitions();
5038 if (new_map->IsFailure()) return new_map; 5043 if (new_map->IsFailure()) return new_map;
5039 set_map(Map::cast(new_map)); 5044 set_map(Map::cast(new_map));
5040 map()->set_constructor(value); 5045 map()->set_constructor(value);
5041 map()->set_non_instance_prototype(true); 5046 map()->set_non_instance_prototype(true);
5042 construct_prototype = 5047 construct_prototype =
5043 Top::context()->global_context()->initial_object_prototype(); 5048 Isolate::Current()->context()->global_context()->
5049 initial_object_prototype();
5044 } else { 5050 } else {
5045 map()->set_non_instance_prototype(false); 5051 map()->set_non_instance_prototype(false);
5046 } 5052 }
5047 5053
5048 return SetInstancePrototype(construct_prototype); 5054 return SetInstancePrototype(construct_prototype);
5049 } 5055 }
5050 5056
5051 5057
5052 Object* JSFunction::RemovePrototype() { 5058 Object* JSFunction::RemovePrototype() {
5053 ASSERT(map() == context()->global_context()->function_map()); 5059 ASSERT(map() == context()->global_context()->function_map());
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
5575 5581
5576 // Computes the new capacity when expanding the elements of a JSObject. 5582 // Computes the new capacity when expanding the elements of a JSObject.
5577 static int NewElementsCapacity(int old_capacity) { 5583 static int NewElementsCapacity(int old_capacity) {
5578 // (old_capacity + 50%) + 16 5584 // (old_capacity + 50%) + 16
5579 return old_capacity + (old_capacity >> 1) + 16; 5585 return old_capacity + (old_capacity >> 1) + 16;
5580 } 5586 }
5581 5587
5582 5588
5583 static Object* ArrayLengthRangeError() { 5589 static Object* ArrayLengthRangeError() {
5584 HandleScope scope; 5590 HandleScope scope;
5585 return Top::Throw(*Factory::NewRangeError("invalid_array_length", 5591 return Isolate::Current()->Throw(
5586 HandleVector<Object>(NULL, 0))); 5592 *Factory::NewRangeError("invalid_array_length",
5593 HandleVector<Object>(NULL, 0)));
5587 } 5594 }
5588 5595
5589 5596
5590 Object* JSObject::SetElementsLength(Object* len) { 5597 Object* JSObject::SetElementsLength(Object* len) {
5591 // We should never end in here with a pixel or external array. 5598 // We should never end in here with a pixel or external array.
5592 ASSERT(AllowsSetElementsLength()); 5599 ASSERT(AllowsSetElementsLength());
5593 5600
5594 Object* smi_length = len->ToSmi(); 5601 Object* smi_length = len->ToSmi();
5595 if (smi_length->IsSmi()) { 5602 if (smi_length->IsSmi()) {
5596 int value = Smi::cast(smi_length)->value(); 5603 int value = Smi::cast(smi_length)->value();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5676 if (!value->IsJSObject() && !value->IsNull()) return value; 5683 if (!value->IsJSObject() && !value->IsNull()) return value;
5677 5684
5678 // Before we can set the prototype we need to be sure 5685 // Before we can set the prototype we need to be sure
5679 // prototype cycles are prevented. 5686 // prototype cycles are prevented.
5680 // It is sufficient to validate that the receiver is not in the new prototype 5687 // It is sufficient to validate that the receiver is not in the new prototype
5681 // chain. 5688 // chain.
5682 for (Object* pt = value; pt != HEAP->null_value(); pt = pt->GetPrototype()) { 5689 for (Object* pt = value; pt != HEAP->null_value(); pt = pt->GetPrototype()) {
5683 if (JSObject::cast(pt) == this) { 5690 if (JSObject::cast(pt) == this) {
5684 // Cycle detected. 5691 // Cycle detected.
5685 HandleScope scope; 5692 HandleScope scope;
5686 return Top::Throw(*Factory::NewError("cyclic_proto", 5693 return Isolate::Current()->Throw(
5687 HandleVector<Object>(NULL, 0))); 5694 *Factory::NewError("cyclic_proto", HandleVector<Object>(NULL, 0)));
5688 } 5695 }
5689 } 5696 }
5690 5697
5691 JSObject* real_receiver = this; 5698 JSObject* real_receiver = this;
5692 5699
5693 if (skip_hidden_prototypes) { 5700 if (skip_hidden_prototypes) {
5694 // Find the first object in the chain whose prototype object is not 5701 // Find the first object in the chain whose prototype object is not
5695 // hidden and set the new prototype on that object. 5702 // hidden and set the new prototype on that object.
5696 Object* current_proto = real_receiver->GetPrototype(); 5703 Object* current_proto = real_receiver->GetPrototype();
5697 while (current_proto->IsJSObject() && 5704 while (current_proto->IsJSObject() &&
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5802 } 5809 }
5803 if (!result.IsEmpty()) return true; 5810 if (!result.IsEmpty()) return true;
5804 } 5811 }
5805 return holder_handle->HasElementPostInterceptor(*receiver_handle, index); 5812 return holder_handle->HasElementPostInterceptor(*receiver_handle, index);
5806 } 5813 }
5807 5814
5808 5815
5809 bool JSObject::HasLocalElement(uint32_t index) { 5816 bool JSObject::HasLocalElement(uint32_t index) {
5810 // Check access rights if needed. 5817 // Check access rights if needed.
5811 if (IsAccessCheckNeeded() && 5818 if (IsAccessCheckNeeded() &&
5812 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 5819 !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5813 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 5820 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5814 return false; 5821 return false;
5815 } 5822 }
5816 5823
5817 // Check for lookup interceptor 5824 // Check for lookup interceptor
5818 if (HasIndexedInterceptor()) { 5825 if (HasIndexedInterceptor()) {
5819 return HasElementWithInterceptor(this, index); 5826 return HasElementWithInterceptor(this, index);
5820 } 5827 }
5821 5828
5822 // Handle [] on String objects. 5829 // Handle [] on String objects.
5823 if (this->IsStringObjectWithCharacterAt(index)) return true; 5830 if (this->IsStringObjectWithCharacterAt(index)) return true;
(...skipping 30 matching lines...) Expand all
5854 break; 5861 break;
5855 } 5862 }
5856 UNREACHABLE(); 5863 UNREACHABLE();
5857 return HEAP->null_value(); 5864 return HEAP->null_value();
5858 } 5865 }
5859 5866
5860 5867
5861 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) { 5868 bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
5862 // Check access rights if needed. 5869 // Check access rights if needed.
5863 if (IsAccessCheckNeeded() && 5870 if (IsAccessCheckNeeded() &&
5864 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 5871 !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
5865 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 5872 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
5866 return false; 5873 return false;
5867 } 5874 }
5868 5875
5869 // Check for lookup interceptor 5876 // Check for lookup interceptor
5870 if (HasIndexedInterceptor()) { 5877 if (HasIndexedInterceptor()) {
5871 return HasElementWithInterceptor(receiver, index); 5878 return HasElementWithInterceptor(receiver, index);
5872 } 5879 }
5873 5880
5874 switch (GetElementsKind()) { 5881 switch (GetElementsKind()) {
5875 case FAST_ELEMENTS: { 5882 case FAST_ELEMENTS: {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
6037 } 6044 }
6038 6045
6039 if (structure->IsFixedArray()) { 6046 if (structure->IsFixedArray()) {
6040 Object* setter = FixedArray::cast(structure)->get(kSetterIndex); 6047 Object* setter = FixedArray::cast(structure)->get(kSetterIndex);
6041 if (setter->IsJSFunction()) { 6048 if (setter->IsJSFunction()) {
6042 return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value); 6049 return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
6043 } else { 6050 } else {
6044 Handle<Object> holder_handle(holder); 6051 Handle<Object> holder_handle(holder);
6045 Handle<Object> key(Factory::NewNumberFromUint(index)); 6052 Handle<Object> key(Factory::NewNumberFromUint(index));
6046 Handle<Object> args[2] = { key, holder_handle }; 6053 Handle<Object> args[2] = { key, holder_handle };
6047 return Top::Throw(*Factory::NewTypeError("no_setter_in_callback", 6054 return Isolate::Current()->Throw(
6048 HandleVector(args, 2))); 6055 *Factory::NewTypeError("no_setter_in_callback",
6056 HandleVector(args, 2)));
6049 } 6057 }
6050 } 6058 }
6051 6059
6052 UNREACHABLE(); 6060 UNREACHABLE();
6053 return NULL; 6061 return NULL;
6054 } 6062 }
6055 6063
6056 6064
6057 // Adding n elements in fast case is O(n*n). 6065 // Adding n elements in fast case is O(n*n).
6058 // Note: revisit design to have dual undefined values to capture absent 6066 // Note: revisit design to have dual undefined values to capture absent
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 // Otherwise default to slow case. 6112 // Otherwise default to slow case.
6105 Object* obj = NormalizeElements(); 6113 Object* obj = NormalizeElements();
6106 if (obj->IsFailure()) return obj; 6114 if (obj->IsFailure()) return obj;
6107 ASSERT(HasDictionaryElements()); 6115 ASSERT(HasDictionaryElements());
6108 return SetElement(index, value); 6116 return SetElement(index, value);
6109 } 6117 }
6110 6118
6111 Object* JSObject::SetElement(uint32_t index, Object* value) { 6119 Object* JSObject::SetElement(uint32_t index, Object* value) {
6112 // Check access rights if needed. 6120 // Check access rights if needed.
6113 if (IsAccessCheckNeeded() && 6121 if (IsAccessCheckNeeded() &&
6114 !Top::MayIndexedAccess(this, index, v8::ACCESS_SET)) { 6122 !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
6115 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET); 6123 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
6116 return value; 6124 return value;
6117 } 6125 }
6118 6126
6119 if (IsJSGlobalProxy()) { 6127 if (IsJSGlobalProxy()) {
6120 Object* proto = GetPrototype(); 6128 Object* proto = GetPrototype();
6121 if (proto->IsNull()) return value; 6129 if (proto->IsNull()) return value;
6122 ASSERT(proto->IsJSGlobalObject()); 6130 ASSERT(proto->IsJSGlobalObject());
6123 return JSObject::cast(proto)->SetElement(index, value); 6131 return JSObject::cast(proto)->SetElement(index, value);
6124 } 6132 }
6125 6133
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
6343 Object* raw_result = 6351 Object* raw_result =
6344 holder_handle->GetElementPostInterceptor(*this_handle, index); 6352 holder_handle->GetElementPostInterceptor(*this_handle, index);
6345 RETURN_IF_SCHEDULED_EXCEPTION(); 6353 RETURN_IF_SCHEDULED_EXCEPTION();
6346 return raw_result; 6354 return raw_result;
6347 } 6355 }
6348 6356
6349 6357
6350 Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) { 6358 Object* JSObject::GetElementWithReceiver(JSObject* receiver, uint32_t index) {
6351 // Check access rights if needed. 6359 // Check access rights if needed.
6352 if (IsAccessCheckNeeded() && 6360 if (IsAccessCheckNeeded() &&
6353 !Top::MayIndexedAccess(this, index, v8::ACCESS_GET)) { 6361 !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_GET)) {
6354 Top::ReportFailedAccessCheck(this, v8::ACCESS_GET); 6362 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
6355 return HEAP->undefined_value(); 6363 return HEAP->undefined_value();
6356 } 6364 }
6357 6365
6358 if (HasIndexedInterceptor()) { 6366 if (HasIndexedInterceptor()) {
6359 return GetElementWithInterceptor(receiver, index); 6367 return GetElementWithInterceptor(receiver, index);
6360 } 6368 }
6361 6369
6362 // Get element works for both JSObject and JSArray since 6370 // Get element works for both JSObject and JSArray since
6363 // JSArray::length cannot change. 6371 // JSArray::length cannot change.
6364 switch (GetElementsKind()) { 6372 switch (GetElementsKind()) {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
6663 *name_handle, 6671 *name_handle,
6664 attributes); 6672 attributes);
6665 RETURN_IF_SCHEDULED_EXCEPTION(); 6673 RETURN_IF_SCHEDULED_EXCEPTION();
6666 return result; 6674 return result;
6667 } 6675 }
6668 6676
6669 6677
6670 bool JSObject::HasRealNamedProperty(String* key) { 6678 bool JSObject::HasRealNamedProperty(String* key) {
6671 // Check access rights if needed. 6679 // Check access rights if needed.
6672 if (IsAccessCheckNeeded() && 6680 if (IsAccessCheckNeeded() &&
6673 !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) { 6681 !Isolate::Current()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
6674 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 6682 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
6675 return false; 6683 return false;
6676 } 6684 }
6677 6685
6678 LookupResult result; 6686 LookupResult result;
6679 LocalLookupRealNamedProperty(key, &result); 6687 LocalLookupRealNamedProperty(key, &result);
6680 return result.IsProperty() && (result.type() != INTERCEPTOR); 6688 return result.IsProperty() && (result.type() != INTERCEPTOR);
6681 } 6689 }
6682 6690
6683 6691
6684 bool JSObject::HasRealElementProperty(uint32_t index) { 6692 bool JSObject::HasRealElementProperty(uint32_t index) {
6685 // Check access rights if needed. 6693 // Check access rights if needed.
6686 if (IsAccessCheckNeeded() && 6694 if (IsAccessCheckNeeded() &&
6687 !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 6695 !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
6688 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 6696 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
6689 return false; 6697 return false;
6690 } 6698 }
6691 6699
6692 // Handle [] on String objects. 6700 // Handle [] on String objects.
6693 if (this->IsStringObjectWithCharacterAt(index)) return true; 6701 if (this->IsStringObjectWithCharacterAt(index)) return true;
6694 6702
6695 switch (GetElementsKind()) { 6703 switch (GetElementsKind()) {
6696 case FAST_ELEMENTS: { 6704 case FAST_ELEMENTS: {
6697 uint32_t length = IsJSArray() ? 6705 uint32_t length = IsJSArray() ?
6698 static_cast<uint32_t>( 6706 static_cast<uint32_t>(
(...skipping 26 matching lines...) Expand all
6725 } 6733 }
6726 // All possibilities have been handled above already. 6734 // All possibilities have been handled above already.
6727 UNREACHABLE(); 6735 UNREACHABLE();
6728 return HEAP->null_value(); 6736 return HEAP->null_value();
6729 } 6737 }
6730 6738
6731 6739
6732 bool JSObject::HasRealNamedCallbackProperty(String* key) { 6740 bool JSObject::HasRealNamedCallbackProperty(String* key) {
6733 // Check access rights if needed. 6741 // Check access rights if needed.
6734 if (IsAccessCheckNeeded() && 6742 if (IsAccessCheckNeeded() &&
6735 !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) { 6743 !Isolate::Current()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
6736 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); 6744 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
6737 return false; 6745 return false;
6738 } 6746 }
6739 6747
6740 LookupResult result; 6748 LookupResult result;
6741 LocalLookupRealNamedProperty(key, &result); 6749 LocalLookupRealNamedProperty(key, &result);
6742 return result.IsProperty() && (result.type() == CALLBACKS); 6750 return result.IsProperty() && (result.type() == CALLBACKS);
6743 } 6751 }
6744 6752
6745 6753
6746 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { 6754 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) {
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
8721 if (break_point_objects()->IsUndefined()) return 0; 8729 if (break_point_objects()->IsUndefined()) return 0;
8722 // Single beak point. 8730 // Single beak point.
8723 if (!break_point_objects()->IsFixedArray()) return 1; 8731 if (!break_point_objects()->IsFixedArray()) return 1;
8724 // Multiple break points. 8732 // Multiple break points.
8725 return FixedArray::cast(break_point_objects())->length(); 8733 return FixedArray::cast(break_point_objects())->length();
8726 } 8734 }
8727 #endif 8735 #endif
8728 8736
8729 8737
8730 } } // namespace v8::internal 8738 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698