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

Unified Diff: src/runtime.cc

Issue 300283002: Introduce FieldIndex to unify and abstract property/field offset (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix mutable boxed double runtime function Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/property.cc ('k') | src/string-stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index e5966efd8fec8c087442df54573470e218af212e..07987e2e39e271da31ce4b88346de252736167f3 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -2555,7 +2555,7 @@ RUNTIME_FUNCTION(RuntimeHidden_InitializeConstGlobal) {
// Strict mode handling not needed (const is disallowed in strict mode).
if (lookup.IsField()) {
FixedArray* properties = global->properties();
- int index = lookup.GetFieldIndex().field_index();
+ int index = lookup.GetFieldIndex().outobject_array_index();
if (properties->get(index)->IsTheHole() || !lookup.IsReadOnly()) {
properties->set(index, *value);
}
@@ -2644,9 +2644,10 @@ RUNTIME_FUNCTION(RuntimeHidden_InitializeConstContextSlot) {
if (lookup.IsField()) {
FixedArray* properties = object->properties();
- int index = lookup.GetFieldIndex().field_index();
- if (properties->get(index)->IsTheHole()) {
- properties->set(index, *value);
+ FieldIndex index = lookup.GetFieldIndex();
+ ASSERT(!index.is_inobject());
+ if (properties->get(index.outobject_array_index())->IsTheHole()) {
+ properties->set(index.outobject_array_index(), *value);
}
} else if (lookup.IsNormal()) {
if (object->GetNormalizedProperty(&lookup)->IsTheHole()) {
@@ -5053,10 +5054,11 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
// Attempt to use lookup cache.
Handle<Map> receiver_map(receiver->map(), isolate);
KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache();
- int offset = keyed_lookup_cache->Lookup(receiver_map, key);
- if (offset != -1) {
+ int index = keyed_lookup_cache->Lookup(receiver_map, key);
+ if (index != -1) {
// Doubles are not cached, so raw read the value.
- Object* value = receiver->RawFastPropertyAt(offset);
+ Object* value = receiver->RawFastPropertyAt(
+ FieldIndex::ForKeyedLookupCacheIndex(*receiver_map, index));
return value->IsTheHole()
? isolate->heap()->undefined_value()
: value;
@@ -5066,15 +5068,16 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
LookupResult result(isolate);
receiver->LookupOwn(key, &result);
if (result.IsField()) {
- int offset = result.GetFieldIndex().field_index();
+ FieldIndex field_index = result.GetFieldIndex();
// Do not track double fields in the keyed lookup cache. Reading
// double values requires boxing.
if (!result.representation().IsDouble()) {
- keyed_lookup_cache->Update(receiver_map, key, offset);
+ keyed_lookup_cache->Update(receiver_map, key,
+ field_index.GetKeyedLookupCacheIndex());
}
AllowHeapAllocation allow_allocation;
- return *JSObject::FastPropertyAt(
- receiver, result.representation(), offset);
+ return *JSObject::FastPropertyAt(receiver, result.representation(),
+ field_index);
}
} else {
// Attempt dictionary lookup.
@@ -10776,7 +10779,7 @@ static Handle<Object> DebugLookupResultValue(Isolate* isolate,
case FIELD:
value = JSObject::FastPropertyAt(handle(result->holder(), isolate),
result->representation(),
- result->GetFieldIndex().field_index());
+ result->GetFieldIndex());
break;
case CONSTANT:
return handle(result->GetConstant(), isolate);
@@ -14545,14 +14548,17 @@ RUNTIME_FUNCTION(Runtime_LoadMutableDouble) {
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1);
- int idx = index->value() >> 1;
- int inobject_properties = object->map()->inobject_properties();
- if (idx < 0) {
- idx = -idx + inobject_properties - 1;
- }
- int max_idx = object->properties()->length() + inobject_properties;
- RUNTIME_ASSERT(idx < max_idx);
- Handle<Object> raw_value(object->RawFastPropertyAt(idx), isolate);
+ RUNTIME_ASSERT((index->value() & 1) == 1);
+ FieldIndex field_index =
+ FieldIndex::ForLoadByFieldIndex(object->map(), index->value());
+ if (field_index.is_inobject()) {
+ RUNTIME_ASSERT(field_index.property_index() <
+ object->map()->inobject_properties());
+ } else {
+ RUNTIME_ASSERT(field_index.outobject_array_index() <
+ object->properties()->length());
+ }
+ Handle<Object> raw_value(object->RawFastPropertyAt(field_index), isolate);
RUNTIME_ASSERT(raw_value->IsNumber() || raw_value->IsUninitialized());
return *Object::NewStorageFor(isolate, raw_value, Representation::Double());
}
« no previous file with comments | « src/property.cc ('k') | src/string-stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698