Get the target field index when transitioning.

Review URL: https://chromiumcodereview.appspot.com/11194080

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12772 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2012-10-19 10:48:18 +00:00
parent ace5bf3f94
commit a0c9856bce
3 changed files with 11 additions and 3 deletions

View File

@ -289,7 +289,6 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() {
// Parse a JSON object. Position must be right at '{'. // Parse a JSON object. Position must be right at '{'.
template <bool seq_ascii> template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() { Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
int current_index = 0;
Handle<Object> prototype; Handle<Object> prototype;
Handle<JSFunction> object_constructor( Handle<JSFunction> object_constructor(
isolate()->native_context()->object_function()); isolate()->native_context()->object_function());
@ -339,11 +338,11 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
prototype = value; prototype = value;
} else { } else {
if (JSObject::TryTransitionToField(json_object, key)) { if (JSObject::TryTransitionToField(json_object, key)) {
json_object->FastPropertyAtPut(current_index++, *value); int index = json_object->LastAddedFieldIndex();
json_object->FastPropertyAtPut(index, *value);
} else { } else {
JSObject::SetLocalPropertyIgnoreAttributes( JSObject::SetLocalPropertyIgnoreAttributes(
json_object, key, value, NONE); json_object, key, value, NONE);
current_index = json_object->NumberOfLocalProperties();
} }
} }
} }

View File

@ -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_string, String, kToStringOffset)
ACCESSORS(Oddball, to_number, Object, kToNumberOffset) ACCESSORS(Oddball, to_number, Object, kToNumberOffset)

View File

@ -1626,6 +1626,8 @@ class JSObject: public JSReceiver {
static inline bool TryTransitionToField(Handle<JSObject> object, static inline bool TryTransitionToField(Handle<JSObject> object,
Handle<String> key); Handle<String> key);
inline int LastAddedFieldIndex();
// Extend the receiver with a single fast property appeared first in the // Extend the receiver with a single fast property appeared first in the
// passed map. This also extends the property backing store if necessary. // passed map. This also extends the property backing store if necessary.
static void AddFastPropertyUsingMap(Handle<JSObject> object, Handle<Map> map); static void AddFastPropertyUsingMap(Handle<JSObject> object, Handle<Map> map);