Skip to content

Commit

Permalink
Get the target field index when transitioning.
Browse files Browse the repository at this point in the history
  • Loading branch information
verwaest@chromium.org committed Oct 19, 2012
1 parent 8902fd7 commit 2d2c123
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/json-parser.h
Expand Up @@ -289,7 +289,6 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() {
// Parse a JSON object. Position must be right at '{'.
template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
int current_index = 0;
Handle<Object> prototype;
Handle<JSFunction> object_constructor(
isolate()->native_context()->object_function());
Expand Down Expand Up @@ -339,11 +338,11 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
prototype = value;
} else {
if (JSObject::TryTransitionToField(json_object, key)) {
json_object->FastPropertyAtPut(current_index++, *value);
int index = json_object->LastAddedFieldIndex();
json_object->FastPropertyAtPut(index, *value);
} else {
JSObject::SetLocalPropertyIgnoreAttributes(
json_object, key, value, NONE);
current_index = json_object->NumberOfLocalProperties();
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/objects-inl.h
Expand Up @@ -1444,6 +1444,13 @@ bool JSObject::TryTransitionToField(Handle<JSObject> object,
}


int JSObject::LastAddedFieldIndex() {
Map* map = this->map();
int last_added = map->LastAdded();
return map->instance_descriptors()->GetFieldIndex(last_added);
}


ACCESSORS(Oddball, to_string, String, kToStringOffset)
ACCESSORS(Oddball, to_number, Object, kToNumberOffset)

Expand Down
2 changes: 2 additions & 0 deletions src/objects.h
Expand Up @@ -1626,6 +1626,8 @@ class JSObject: public JSReceiver {
static inline bool TryTransitionToField(Handle<JSObject> object,
Handle<String> key);

inline int LastAddedFieldIndex();

// Extend the receiver with a single fast property appeared first in the
// passed map. This also extends the property backing store if necessary.
static void AddFastPropertyUsingMap(Handle<JSObject> object, Handle<Map> map);
Expand Down

0 comments on commit 2d2c123

Please sign in to comment.