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

Unified Diff: src/property-descriptor.cc

Issue 1607943003: [runtime] Introduce maps for the likely cases of FromPropertyDescriptor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 11 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-descriptor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/property-descriptor.cc
diff --git a/src/property-descriptor.cc b/src/property-descriptor.cc
index 243a9faac3a76cd33f1d5563cb065b5b5e34c772..750f948adbe399263ce44f194e82d9d3d8ffde6c 100644
--- a/src/property-descriptor.cc
+++ b/src/property-descriptor.cc
@@ -13,6 +13,8 @@
namespace v8 {
namespace internal {
+namespace {
+
// Helper function for ToPropertyDescriptor. Comments describe steps for
// "enumerable", other properties are handled the same way.
// Returns false if an exception was thrown.
@@ -101,19 +103,51 @@ bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj,
}
-static void CreateDataProperty(Isolate* isolate, Handle<JSObject> object,
- Handle<String> name, Handle<Object> value) {
+void CreateDataProperty(Isolate* isolate, Handle<JSObject> object,
+ Handle<String> name, Handle<Object> value) {
LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<bool> result = JSObject::CreateDataProperty(&it, value);
CHECK(result.IsJust() && result.FromJust());
}
+} // namespace
+
// ES6 6.2.4.4 "FromPropertyDescriptor"
Handle<Object> PropertyDescriptor::ToObject(Isolate* isolate) {
DCHECK(!(PropertyDescriptor::IsAccessorDescriptor(this) &&
PropertyDescriptor::IsDataDescriptor(this)));
Factory* factory = isolate->factory();
+ if (IsRegularAccessorProperty()) {
+ // Fast case for regular accessor properties.
+ Handle<JSObject> result = factory->NewJSObjectFromMap(
+ isolate->accessor_property_descriptor_map());
+ result->InObjectPropertyAtPut(JSAccessorPropertyDescriptor::kGetIndex,
+ *get());
+ result->InObjectPropertyAtPut(JSAccessorPropertyDescriptor::kSetIndex,
+ *set());
+ result->InObjectPropertyAtPut(
+ JSAccessorPropertyDescriptor::kEnumerableIndex,
+ isolate->heap()->ToBoolean(enumerable()));
+ result->InObjectPropertyAtPut(
+ JSAccessorPropertyDescriptor::kConfigurableIndex,
+ isolate->heap()->ToBoolean(configurable()));
+ return result;
+ }
+ if (IsRegularDataProperty()) {
+ // Fast case for regular data properties.
+ Handle<JSObject> result =
+ factory->NewJSObjectFromMap(isolate->data_property_descriptor_map());
+ result->InObjectPropertyAtPut(JSDataPropertyDescriptor::kValueIndex,
+ *value());
+ result->InObjectPropertyAtPut(JSDataPropertyDescriptor::kWritableIndex,
+ isolate->heap()->ToBoolean(writable()));
+ result->InObjectPropertyAtPut(JSDataPropertyDescriptor::kEnumerableIndex,
+ isolate->heap()->ToBoolean(enumerable()));
+ result->InObjectPropertyAtPut(JSDataPropertyDescriptor::kConfigurableIndex,
+ isolate->heap()->ToBoolean(configurable()));
+ return result;
+ }
Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
if (has_value()) {
CreateDataProperty(isolate, result, factory->value_string(), value());
« no previous file with comments | « src/property-descriptor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698