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

Side by Side Diff: src/runtime.cc

Issue 11365221: Allow property indexes to refer to slots inside the object header. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 kNonStrictMode)); 1672 kNonStrictMode));
1673 return *value; 1673 return *value;
1674 } 1674 }
1675 1675
1676 // Set the value, but only if we're assigning the initial value to a 1676 // Set the value, but only if we're assigning the initial value to a
1677 // constant. For now, we determine this by checking if the 1677 // constant. For now, we determine this by checking if the
1678 // current value is the hole. 1678 // current value is the hole.
1679 // Strict mode handling not needed (const is disallowed in strict mode). 1679 // Strict mode handling not needed (const is disallowed in strict mode).
1680 if (lookup.IsField()) { 1680 if (lookup.IsField()) {
1681 FixedArray* properties = global->properties(); 1681 FixedArray* properties = global->properties();
1682 int index = lookup.GetFieldIndex(); 1682 int index = lookup.GetFieldIndex().FieldIndex();
1683 if (properties->get(index)->IsTheHole() || !lookup.IsReadOnly()) { 1683 if (properties->get(index)->IsTheHole() || !lookup.IsReadOnly()) {
1684 properties->set(index, *value); 1684 properties->set(index, *value);
1685 } 1685 }
1686 } else if (lookup.IsNormal()) { 1686 } else if (lookup.IsNormal()) {
1687 if (global->GetNormalizedProperty(&lookup)->IsTheHole() || 1687 if (global->GetNormalizedProperty(&lookup)->IsTheHole() ||
1688 !lookup.IsReadOnly()) { 1688 !lookup.IsReadOnly()) {
1689 global->SetNormalizedProperty(&lookup, *value); 1689 global->SetNormalizedProperty(&lookup, *value);
1690 } 1690 }
1691 } else { 1691 } else {
1692 // Ignore re-initialization of constants that have already been 1692 // Ignore re-initialization of constants that have already been
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 // This is the property that was introduced by the const declaration. 1762 // This is the property that was introduced by the const declaration.
1763 // Set it if it hasn't been set before. NOTE: We cannot use 1763 // Set it if it hasn't been set before. NOTE: We cannot use
1764 // GetProperty() to get the current value as it 'unholes' the value. 1764 // GetProperty() to get the current value as it 'unholes' the value.
1765 LookupResult lookup(isolate); 1765 LookupResult lookup(isolate);
1766 object->LocalLookupRealNamedProperty(*name, &lookup); 1766 object->LocalLookupRealNamedProperty(*name, &lookup);
1767 ASSERT(lookup.IsFound()); // the property was declared 1767 ASSERT(lookup.IsFound()); // the property was declared
1768 ASSERT(lookup.IsReadOnly()); // and it was declared as read-only 1768 ASSERT(lookup.IsReadOnly()); // and it was declared as read-only
1769 1769
1770 if (lookup.IsField()) { 1770 if (lookup.IsField()) {
1771 FixedArray* properties = object->properties(); 1771 FixedArray* properties = object->properties();
1772 int index = lookup.GetFieldIndex(); 1772 int index = lookup.GetFieldIndex().FieldIndex();
1773 if (properties->get(index)->IsTheHole()) { 1773 if (properties->get(index)->IsTheHole()) {
1774 properties->set(index, *value); 1774 properties->set(index, *value);
1775 } 1775 }
1776 } else if (lookup.IsNormal()) { 1776 } else if (lookup.IsNormal()) {
1777 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) { 1777 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) {
1778 object->SetNormalizedProperty(&lookup, *value); 1778 object->SetNormalizedProperty(&lookup, *value);
1779 } 1779 }
1780 } else { 1780 } else {
1781 // We should not reach here. Any real, named property should be 1781 // We should not reach here. Any real, named property should be
1782 // either a field or a dictionary slot. 1782 // either a field or a dictionary slot.
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 Object* value = receiver->FastPropertyAt(offset); 4069 Object* value = receiver->FastPropertyAt(offset);
4070 return value->IsTheHole() 4070 return value->IsTheHole()
4071 ? isolate->heap()->undefined_value() 4071 ? isolate->heap()->undefined_value()
4072 : value; 4072 : value;
4073 } 4073 }
4074 // Lookup cache miss. Perform lookup and update the cache if 4074 // Lookup cache miss. Perform lookup and update the cache if
4075 // appropriate. 4075 // appropriate.
4076 LookupResult result(isolate); 4076 LookupResult result(isolate);
4077 receiver->LocalLookup(key, &result); 4077 receiver->LocalLookup(key, &result);
4078 if (result.IsField()) { 4078 if (result.IsField()) {
4079 int offset = result.GetFieldIndex(); 4079 int offset = result.GetFieldIndex().FieldIndex();
4080 keyed_lookup_cache->Update(receiver_map, key, offset); 4080 keyed_lookup_cache->Update(receiver_map, key, offset);
4081 return receiver->FastPropertyAt(offset); 4081 return receiver->FastPropertyAt(offset);
4082 } 4082 }
4083 } else { 4083 } else {
4084 // Attempt dictionary lookup. 4084 // Attempt dictionary lookup.
4085 StringDictionary* dictionary = receiver->property_dictionary(); 4085 StringDictionary* dictionary = receiver->property_dictionary();
4086 int entry = dictionary->FindEntry(key); 4086 int entry = dictionary->FindEntry(key);
4087 if ((entry != StringDictionary::kNotFound) && 4087 if ((entry != StringDictionary::kNotFound) &&
4088 (dictionary->DetailsAt(entry).type() == NORMAL)) { 4088 (dictionary->DetailsAt(entry).type() == NORMAL)) {
4089 Object* value = dictionary->ValueAt(entry); 4089 Object* value = dictionary->ValueAt(entry);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 ASSERT(args.length() == 2); 4243 ASSERT(args.length() == 2);
4244 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 4244 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4245 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); 4245 CONVERT_ARG_HANDLE_CHECKED(String, key, 1);
4246 LookupResult lookup(isolate); 4246 LookupResult lookup(isolate);
4247 object->LookupRealNamedProperty(*key, &lookup); 4247 object->LookupRealNamedProperty(*key, &lookup);
4248 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); 4248 if (!lookup.IsFound()) return isolate->heap()->undefined_value();
4249 switch (lookup.type()) { 4249 switch (lookup.type()) {
4250 case NORMAL: 4250 case NORMAL:
4251 return lookup.holder()->GetNormalizedProperty(&lookup); 4251 return lookup.holder()->GetNormalizedProperty(&lookup);
4252 case FIELD: 4252 case FIELD:
4253 return lookup.holder()->FastPropertyAt(lookup.GetFieldIndex()); 4253 return lookup.holder()->FastPropertyAt(
4254 lookup.GetFieldIndex().FieldIndex());
4254 case CONSTANT_FUNCTION: 4255 case CONSTANT_FUNCTION:
4255 return lookup.GetConstantFunction(); 4256 return lookup.GetConstantFunction();
4256 case CALLBACKS: 4257 case CALLBACKS:
4257 case HANDLER: 4258 case HANDLER:
4258 case INTERCEPTOR: 4259 case INTERCEPTOR:
4259 case TRANSITION: 4260 case TRANSITION:
4260 return isolate->heap()->undefined_value(); 4261 return isolate->heap()->undefined_value();
4261 case NONEXISTENT: 4262 case NONEXISTENT:
4262 UNREACHABLE(); 4263 UNREACHABLE();
4263 } 4264 }
(...skipping 5739 matching lines...) Expand 10 before | Expand all | Expand 10 after
10003 Object* value; 10004 Object* value;
10004 switch (result->type()) { 10005 switch (result->type()) {
10005 case NORMAL: 10006 case NORMAL:
10006 value = result->holder()->GetNormalizedProperty(result); 10007 value = result->holder()->GetNormalizedProperty(result);
10007 if (value->IsTheHole()) { 10008 if (value->IsTheHole()) {
10008 return heap->undefined_value(); 10009 return heap->undefined_value();
10009 } 10010 }
10010 return value; 10011 return value;
10011 case FIELD: 10012 case FIELD:
10012 value = 10013 value =
10013 JSObject::cast( 10014 JSObject::cast(result->holder())->FastPropertyAt(
10014 result->holder())->FastPropertyAt(result->GetFieldIndex()); 10015 result->GetFieldIndex().FieldIndex());
10015 if (value->IsTheHole()) { 10016 if (value->IsTheHole()) {
10016 return heap->undefined_value(); 10017 return heap->undefined_value();
10017 } 10018 }
10018 return value; 10019 return value;
10019 case CONSTANT_FUNCTION: 10020 case CONSTANT_FUNCTION:
10020 return result->GetConstantFunction(); 10021 return result->GetConstantFunction();
10021 case CALLBACKS: { 10022 case CALLBACKS: {
10022 Object* structure = result->GetCallbackObject(); 10023 Object* structure = result->GetCallbackObject();
10023 if (structure->IsForeign() || structure->IsAccessorInfo()) { 10024 if (structure->IsForeign() || structure->IsAccessorInfo()) {
10024 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( 10025 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback(
(...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after
13316 // Handle last resort GC and make sure to allow future allocations 13317 // Handle last resort GC and make sure to allow future allocations
13317 // to grow the heap without causing GCs (if possible). 13318 // to grow the heap without causing GCs (if possible).
13318 isolate->counters()->gc_last_resort_from_js()->Increment(); 13319 isolate->counters()->gc_last_resort_from_js()->Increment();
13319 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13320 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13320 "Runtime::PerformGC"); 13321 "Runtime::PerformGC");
13321 } 13322 }
13322 } 13323 }
13323 13324
13324 13325
13325 } } // namespace v8::internal 13326 } } // namespace v8::internal
OLDNEW
« src/property.h ('K') | « src/property.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698