Revision: 21575
Author: [email protected]
Date: Wed May 28 19:13:41 2014 UTC
Log: Simplify, speed-up correct-context ObjectObserve calls
The original patch which ensured that Object.observe did allocations in the
correct context regressed performance about 12%. This patch gets back most
of that (about 11%) by simply returning the correct function which is then
directly callable from JS, rather than by making the call from the runtime
function. A side-effect is that their implementation is shorter.
LOG=Y
BUG=NONE
[email protected]
Review URL: https://codereview.chromium.org/307543008
http://code.google.com/p/v8/source/detail?r=21575
Added:
/branches/bleeding_edge/test/mjsunit/runtime-gen/getobjectcontextnotifierperformchange.js
/branches/bleeding_edge/test/mjsunit/runtime-gen/getobjectcontextobjectgetnotifier.js
/branches/bleeding_edge/test/mjsunit/runtime-gen/getobjectcontextobjectobserve.js
Deleted:
/branches/bleeding_edge/test/mjsunit/runtime-gen/objectgetnotifierinobjectcontext.js
/branches/bleeding_edge/test/mjsunit/runtime-gen/objectnotifierperformchangeinobjectcontext.js
/branches/bleeding_edge/test/mjsunit/runtime-gen/objectobserveinobjectcontext.js
Modified:
/branches/bleeding_edge/src/object-observe.js
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/runtime.h
=======================================
--- /dev/null
+++
/branches/bleeding_edge/test/mjsunit/runtime-gen/getobjectcontextnotifierperformchange.js
Wed May 28 19:13:41 2014 UTC
@@ -0,0 +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_info = new Object();
+%GetObjectContextNotifierPerformChange(_object_info);
=======================================
--- /dev/null
+++
/branches/bleeding_edge/test/mjsunit/runtime-gen/getobjectcontextobjectgetnotifier.js
Wed May 28 19:13:41 2014 UTC
@@ -0,0 +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 Object();
+%GetObjectContextObjectGetNotifier(_object);
=======================================
--- /dev/null
+++
/branches/bleeding_edge/test/mjsunit/runtime-gen/getobjectcontextobjectobserve.js
Wed May 28 19:13:41 2014 UTC
@@ -0,0 +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 Object();
+%GetObjectContextObjectObserve(_object);
=======================================
---
/branches/bleeding_edge/test/mjsunit/runtime-gen/objectgetnotifierinobjectcontext.js
Thu May 8 13:11:59 2014 UTC
+++ /dev/null
@@ -1,5 +0,0 @@
-// 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 Object();
-%ObjectGetNotifierInObjectContext(_object);
=======================================
---
/branches/bleeding_edge/test/mjsunit/runtime-gen/objectnotifierperformchangeinobjectcontext.js
Thu May 8 13:11:59 2014 UTC
+++ /dev/null
@@ -1,7 +0,0 @@
-// 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_info = new Object();
-var _change_type = "foo";
-var _change_fn = function() {};
-%ObjectNotifierPerformChangeInObjectContext(_object_info, _change_type,
_change_fn);
=======================================
---
/branches/bleeding_edge/test/mjsunit/runtime-gen/objectobserveinobjectcontext.js
Thu May 8 13:11:59 2014 UTC
+++ /dev/null
@@ -1,7 +0,0 @@
-// 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 Object();
-var _callback = function() {};
-var _accept = new Object();
-%ObjectObserveInObjectContext(_object, _callback, _accept);
=======================================
--- /branches/bleeding_edge/src/object-observe.js Mon May 19 07:57:04 2014
UTC
+++ /branches/bleeding_edge/src/object-observe.js Wed May 28 19:13:41 2014
UTC
@@ -368,7 +368,8 @@
if (ObjectIsFrozen(callback))
throw MakeTypeError("observe_callback_frozen");
- return %ObjectObserveInObjectContext(object, callback, acceptList);
+ var objectObserveFn = %GetObjectContextObjectObserve(object);
+ return objectObserveFn(object, callback, acceptList);
}
function NativeObjectObserve(object, callback, acceptList) {
@@ -543,8 +544,8 @@
if (!IS_SPEC_FUNCTION(changeFn))
throw MakeTypeError("observe_perform_non_function");
- return %ObjectNotifierPerformChangeInObjectContext(
- objectInfo, changeType, changeFn);
+ var performChangeFn = %GetObjectContextNotifierPerformChange(objectInfo);
+ performChangeFn(objectInfo, changeType, changeFn);
}
function NativeObjectNotifierPerformChange(objectInfo, changeType,
changeFn) {
@@ -571,7 +572,8 @@
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
- return %ObjectGetNotifierInObjectContext(object);
+ var getNotifierFn = %GetObjectContextObjectGetNotifier(object);
+ return getNotifierFn(object);
}
function NativeObjectGetNotifier(object) {
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed May 28 09:58:27 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Wed May 28 19:13:41 2014 UTC
@@ -14889,64 +14889,33 @@
}
-RUNTIME_FUNCTION(Runtime_ObjectObserveInObjectContext) {
+RUNTIME_FUNCTION(Runtime_GetObjectContextObjectObserve) {
HandleScope scope(isolate);
- ASSERT(args.length() == 3);
+ ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, accept, 2);
Handle<Context> context(object->GetCreationContext(), isolate);
- Handle<JSFunction> function(context->native_object_observe(), isolate);
- Handle<Object> call_args[] = { object, callback, accept };
- Handle<Object> result;
-
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::Call(isolate, function,
- handle(context->object_function(), isolate),
- ARRAY_SIZE(call_args), call_args, true));
- return *result;
+ return context->native_object_observe();
}
-RUNTIME_FUNCTION(Runtime_ObjectGetNotifierInObjectContext) {
+RUNTIME_FUNCTION(Runtime_GetObjectContextObjectGetNotifier) {
HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
Handle<Context> context(object->GetCreationContext(), isolate);
- Handle<JSFunction> function(context->native_object_get_notifier(),
isolate);
- Handle<Object> call_args[] = { object };
- Handle<Object> result;
-
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::Call(isolate, function,
- handle(context->object_function(), isolate),
- ARRAY_SIZE(call_args), call_args, true));
- return *result;
+ return context->native_object_get_notifier();
}
-RUNTIME_FUNCTION(Runtime_ObjectNotifierPerformChangeInObjectContext) {
+RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) {
HandleScope scope(isolate);
- ASSERT(args.length() == 3);
+ ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object_info, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, change_type, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, change_fn, 2);
Handle<Context> context(object_info->GetCreationContext(), isolate);
- Handle<JSFunction>
function(context->native_object_notifier_perform_change(),
- isolate);
- Handle<Object> call_args[] = { object_info, change_type, change_fn };
- Handle<Object> result;
-
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::Call(isolate, function,
isolate->factory()->undefined_value(),
- ARRAY_SIZE(call_args), call_args, true));
- return *result;
+ return context->native_object_notifier_perform_change();
}
=======================================
--- /branches/bleeding_edge/src/runtime.h Fri May 23 12:55:57 2014 UTC
+++ /branches/bleeding_edge/src/runtime.h Wed May 28 19:13:41 2014 UTC
@@ -306,9 +306,9 @@
F(ObservationWeakMapCreate, 0, 1) \
F(ObserverObjectAndRecordHaveSameOrigin, 3, 1) \
F(ObjectWasCreatedInCurrentOrigin, 1, 1) \
- F(ObjectObserveInObjectContext, 3, 1) \
- F(ObjectGetNotifierInObjectContext, 1, 1) \
- F(ObjectNotifierPerformChangeInObjectContext, 3, 1) \
+ F(GetObjectContextObjectObserve, 1, 1) \
+ F(GetObjectContextObjectGetNotifier, 1, 1) \
+ F(GetObjectContextNotifierPerformChange, 1, 1) \
\
/* Harmony typed arrays */ \
F(ArrayBufferInitialize, 2, 1)\
--
--
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.