Reviewers: Igor Sheludko,
Message:
PTAL
Description:
Restore DefineApiAccessorProperty
BUG=
Please review this at https://codereview.chromium.org/428463005/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+40, -8 lines):
M src/apinatives.js
M src/runtime.h
M src/runtime.cc
M test/mjsunit/runtime-gen/estimatenumberofelements.js
M tools/generate-runtime-tests.py
Index: src/apinatives.js
diff --git a/src/apinatives.js b/src/apinatives.js
index
0ba5c6838db004f06dde4961470964734f346ad9..65dc3cb9608cc574abca2412133f675ba6cc80d5
100644
--- a/src/apinatives.js
+++ b/src/apinatives.js
@@ -104,10 +104,10 @@ function ConfigureTemplateInstance(obj, data) {
// TODO(verwaest): The 5th value used to be access_control. Remove
once
// the bindings are updated.
var name = properties[i + 1];
- var getter = Instantiate(properties[i + 2]);
- var setter = Instantiate(properties[i + 3]);
+ var getter = properties[i + 2];
+ var setter = properties[i + 3];
var attribute = properties[i + 4];
- %DefineAccessorPropertyUnchecked(obj, name, getter, setter,
attribute);
+ %DefineApiAccessorProperty(obj, name, getter, setter, attribute);
} else {
throw "Bad properties array";
}
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
49591df299c1a126173eb99febf61eca68194d60..ba6f33c5313ed589930c4808fb00553383aeca3b
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4927,6 +4927,37 @@ static bool IsValidAccessor(Handle<Object> obj) {
}
+// Transform getter or setter into something DefineAccessor can handle.
+static Handle<Object> InstantiateAccessorComponent(Isolate* isolate,
+ Handle<Object>
component) {
+ if (component->IsUndefined()) return isolate->factory()->null_value();
+ Handle<FunctionTemplateInfo> info =
+ Handle<FunctionTemplateInfo>::cast(component);
+ return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
+}
+
+
+RUNTIME_FUNCTION(Runtime_DefineApiAccessorProperty) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 5);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
+ CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
+ CONVERT_SMI_ARG_CHECKED(attribute, 4);
+ RUNTIME_ASSERT(getter->IsUndefined() ||
getter->IsFunctionTemplateInfo());
+ RUNTIME_ASSERT(setter->IsUndefined() ||
setter->IsFunctionTemplateInfo());
+ RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid(
+ static_cast<PropertyAttributes>(attribute)));
+ RETURN_FAILURE_ON_EXCEPTION(
+ isolate, JSObject::DefineAccessor(
+ object, name, InstantiateAccessorComponent(isolate,
getter),
+ InstantiateAccessorComponent(isolate, setter),
+ static_cast<PropertyAttributes>(attribute)));
+ return isolate->heap()->undefined_value();
+}
+
+
// Implements part of 8.12.9 DefineOwnProperty.
// There are 3 cases that lead here:
// Step 4b - define a new accessor property.
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
c505f8b53c005273f4f54b2fb39b0104728f84b8..3224a282b70772bbee7c2ad574d2e9176277e780
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -228,6 +228,7 @@ namespace internal {
F(AddNamedProperty, 4, 1) \
F(AddPropertyForTemplate, 4, 1) \
F(SetProperty, 4, 1) \
+ F(DefineApiAccessorProperty, 5, 1) \
F(DefineDataPropertyUnchecked, 4, 1) \
F(DefineAccessorPropertyUnchecked, 5, 1) \
F(GetDataProperty, 2, 1) \
Index: test/mjsunit/runtime-gen/estimatenumberofelements.js
diff --git a/test/mjsunit/runtime-gen/estimatenumberofelements.js
b/test/mjsunit/runtime-gen/estimatenumberofelements.js
index
dd1f397f867de258ce520b5b8be8a5362ab2617a..e7bfe9559746138713b159bd12febde10f8ac1cd
100644
--- a/test/mjsunit/runtime-gen/estimatenumberofelements.js
+++ b/test/mjsunit/runtime-gen/estimatenumberofelements.js
@@ -1,5 +1,5 @@
// Copyright 2014 the V8 project authors. All rights reserved.
// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
// Flags: --allow-natives-syntax --harmony
-var _object = new Array();
-%EstimateNumberOfElements(_object);
+var _array = new Array();
+%EstimateNumberOfElements(_array);
Index: tools/generate-runtime-tests.py
diff --git a/tools/generate-runtime-tests.py
b/tools/generate-runtime-tests.py
index
64ef663d331d953d09340cc5bc0a05b3c36b2eca..1af90ec46aba561767899c50d0abb80626d8e534
100755
--- a/tools/generate-runtime-tests.py
+++ b/tools/generate-runtime-tests.py
@@ -47,8 +47,8 @@ EXPAND_MACROS = [
# that the parser doesn't bit-rot. Change the values as needed when you
add,
# remove or change runtime functions, but make sure we don't lose our
ability
# to parse them!
-EXPECTED_FUNCTION_COUNT = 421
-EXPECTED_FUZZABLE_COUNT = 335
+EXPECTED_FUNCTION_COUNT = 422
+EXPECTED_FUZZABLE_COUNT = 336
EXPECTED_CCTEST_COUNT = 8
EXPECTED_UNKNOWN_COUNT = 4
EXPECTED_BUILTINS_COUNT = 815
@@ -245,7 +245,7 @@ CUSTOM_KNOWN_GOOD_INPUT = {
"NumberToRadixString": [None, "2", None],
"ParseJson": ["\"{}\"", 1],
"RegExpExecMultiple": [None, None, "['a']", "['a']", None],
- "DefineAccessorProperty": [None, None, "undefined", "undefined", None,
None],
+ "DefineApiAccessorProperty": [None, None, "undefined", "undefined",
None, None],
"SetIteratorInitialize": [None, None, "2", None],
"SetDebugEventListener": ["undefined", None, None],
"SetFunctionBreakPoint": [None, 200, None, None],
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.