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

Side by Side Diff: src/objects-inl.h

Issue 13741010: Eagerly parse expected transitions in JSON. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add assert Created 7 years, 8 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.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 FixedArray* new_properties; 1481 FixedArray* new_properties;
1482 MaybeObject* maybe_properties = properties()->CopySize(new_size); 1482 MaybeObject* maybe_properties = properties()->CopySize(new_size);
1483 if (!maybe_properties->To(&new_properties)) return maybe_properties; 1483 if (!maybe_properties->To(&new_properties)) return maybe_properties;
1484 set_properties(new_properties); 1484 set_properties(new_properties);
1485 } 1485 }
1486 set_map(map); 1486 set_map(map);
1487 return this; 1487 return this;
1488 } 1488 }
1489 1489
1490 1490
1491 bool JSObject::TryTransitionToField(Handle<JSObject> object, 1491 MaybeObject* JSObject::TransitionToMap(Map* map) {
1492 Handle<Name> key) { 1492 ASSERT(this->map()->inobject_properties() == map->inobject_properties());
1493 if (!object->map()->HasTransitionArray()) return false; 1493 ElementsKind expected_kind = this->map()->elements_kind();
1494 Handle<Map> target; 1494 if (map->elements_kind() != expected_kind) {
1495 { 1495 MaybeObject* maybe_map = map->AsElementsKind(expected_kind);
1496 AssertNoAllocation no_allocation; 1496 if (!maybe_map->To(&map)) return maybe_map;
1497 TransitionArray* transitions = object->map()->transitions();
1498 int transition = transitions->Search(*key);
1499 if (transition == TransitionArray::kNotFound) return false;
1500 PropertyDetails target_details = transitions->GetTargetDetails(transition);
1501 if (target_details.type() != FIELD) return false;
1502 if (target_details.attributes() != NONE) return false;
1503 target = Handle<Map>(transitions->GetTarget(transition));
1504 } 1497 }
1505 JSObject::AddFastPropertyUsingMap(object, target); 1498 int total_size =
1506 return true; 1499 map->NumberOfOwnDescriptors() + map->unused_property_fields();
1500 int out_of_object = total_size - map->inobject_properties();
1501 if (out_of_object != properties()->length()) {
1502 FixedArray* new_properties;
1503 MaybeObject* maybe_properties = properties()->CopySize(out_of_object);
1504 if (!maybe_properties->To(&new_properties)) return maybe_properties;
1505 set_properties(new_properties);
1506 }
1507 set_map(map);
1508 return this;
1507 } 1509 }
1508 1510
1509 1511
1512 Handle<String> JSObject::ExpectedTransitionKey(Handle<Map> map) {
1513 AssertNoAllocation no_gc;
1514 if (!map->HasTransitionArray()) return Handle<String>::null();
1515 TransitionArray* transitions = map->transitions();
1516 if (!transitions->IsSimpleTransition()) return Handle<String>::null();
1517 int transition = TransitionArray::kSimpleTransitionIndex;
1518 PropertyDetails details = transitions->GetTargetDetails(transition);
1519 Name* name = transitions->GetKey(transition);
1520 if (details.type() != FIELD) return Handle<String>::null();
1521 if (details.attributes() != NONE) return Handle<String>::null();
1522 if (!name->IsString()) return Handle<String>::null();
1523 return Handle<String>(String::cast(name));
1524 }
1525
1526
1527 Handle<Map> JSObject::ExpectedTransitionTarget(Handle<Map> map) {
1528 ASSERT(!ExpectedTransitionKey(map).is_null());
1529 return Handle<Map>(map->transitions()->GetTarget(
1530 TransitionArray::kSimpleTransitionIndex));
1531 }
1532
1533
1534 Handle<Map> JSObject::FindTransitionToField(Handle<Map> map, Handle<Name> key) {
1535 AssertNoAllocation no_allocation;
1536 if (!map->HasTransitionArray()) return Handle<Map>::null();
1537 TransitionArray* transitions = map->transitions();
1538 int transition = transitions->Search(*key);
1539 if (transition == TransitionArray::kNotFound) return Handle<Map>::null();
1540 PropertyDetails target_details = transitions->GetTargetDetails(transition);
1541 if (target_details.type() != FIELD) return Handle<Map>::null();
1542 if (target_details.attributes() != NONE) return Handle<Map>::null();
1543 return Handle<Map>(transitions->GetTarget(transition));
1544 }
1545
1546
1510 int JSObject::LastAddedFieldIndex() { 1547 int JSObject::LastAddedFieldIndex() {
1511 Map* map = this->map(); 1548 Map* map = this->map();
1512 int last_added = map->LastAdded(); 1549 int last_added = map->LastAdded();
1513 return map->instance_descriptors()->GetFieldIndex(last_added); 1550 return map->instance_descriptors()->GetFieldIndex(last_added);
1514 } 1551 }
1515 1552
1516 1553
1517 ACCESSORS(Oddball, to_string, String, kToStringOffset) 1554 ACCESSORS(Oddball, to_string, String, kToStringOffset)
1518 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) 1555 ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
1519 1556
(...skipping 4525 matching lines...) Expand 10 before | Expand all | Expand 10 after
6045 #undef WRITE_UINT32_FIELD 6082 #undef WRITE_UINT32_FIELD
6046 #undef READ_SHORT_FIELD 6083 #undef READ_SHORT_FIELD
6047 #undef WRITE_SHORT_FIELD 6084 #undef WRITE_SHORT_FIELD
6048 #undef READ_BYTE_FIELD 6085 #undef READ_BYTE_FIELD
6049 #undef WRITE_BYTE_FIELD 6086 #undef WRITE_BYTE_FIELD
6050 6087
6051 6088
6052 } } // namespace v8::internal 6089 } } // namespace v8::internal
6053 6090
6054 #endif // V8_OBJECTS_INL_H_ 6091 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698