Revision: 12819
Author: [email protected]
Date: Thu Oct 25 07:53:26 2012
Log: Initial JS stub implementation of Object.observe. Adds support
for .object/.unobserve/.notify/.deliverChangeRecords. No delivery mechanism
is implemented for end-of-microtask.
Review URL: https://codereview.chromium.org/11225058
Patch from Rafael Weinstein <[email protected]>.
http://code.google.com/p/v8/source/detail?r=12819
Modified:
/branches/bleeding_edge/src/array.js
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/messages.js
/branches/bleeding_edge/src/proxy.js
/branches/bleeding_edge/tools/gyp/v8.gyp
=======================================
--- /branches/bleeding_edge/src/array.js Fri Oct 19 05:30:18 2012
+++ /branches/bleeding_edge/src/array.js Thu Oct 25 07:53:26 2012
@@ -1549,9 +1549,11 @@
// exposed to user code.
// Adding only the functions that are actually used.
SetUpLockedPrototype(InternalArray, $Array(), $Array(
+ "indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop),
- "push", getFunction("push", ArrayPush)
+ "push", getFunction("push", ArrayPush),
+ "splice", getFunction("splice", ArraySplice)
));
}
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Wed Oct 17 06:04:49 2012
+++ /branches/bleeding_edge/src/bootstrapper.cc Thu Oct 25 07:53:26 2012
@@ -1828,6 +1828,11 @@
"native collection.js") == 0) {
if (!CompileExperimentalBuiltin(isolate(), i)) return false;
}
+ if (FLAG_harmony_object_observe &&
+ strcmp(ExperimentalNatives::GetScriptName(i).start(),
+ "native object-observe.js") == 0) {
+ if (!CompileExperimentalBuiltin(isolate(), i)) return false;
+ }
}
InstallExperimentalNativeFunctions();
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Thu Oct 18 05:21:42 2012
+++ /branches/bleeding_edge/src/flag-definitions.h Thu Oct 25 07:53:26 2012
@@ -144,12 +144,16 @@
DEFINE_bool(harmony_proxies, false, "enable harmony proxies")
DEFINE_bool(harmony_collections, false,
"enable harmony collections (sets, maps, and weak maps)")
+DEFINE_bool(harmony_object_observe, false,
+ "enable harmony object observation (implies harmony
collections")
DEFINE_bool(harmony, false, "enable all harmony features (except typeof)")
DEFINE_implication(harmony, harmony_scoping)
DEFINE_implication(harmony, harmony_modules)
DEFINE_implication(harmony, harmony_proxies)
DEFINE_implication(harmony, harmony_collections)
+DEFINE_implication(harmony, harmony_object_observe)
DEFINE_implication(harmony_modules, harmony_scoping)
+DEFINE_implication(harmony_object_observe, harmony_collections)
// Flags for experimental implementation features.
DEFINE_bool(packed_arrays, true, "optimizes arrays that have no holes")
=======================================
--- /branches/bleeding_edge/src/messages.js Thu Oct 11 04:40:10 2012
+++ /branches/bleeding_edge/src/messages.js Thu Oct 25 07:53:26 2012
@@ -203,6 +203,10 @@
"proxy_repeated_prop_name", ["Trap '", "%1", "' returned
repeated property name '", "%2", "'"],
"invalid_weakmap_key", ["Invalid value used as weak map
key"],
"not_date_object", ["this is not a Date object."],
+ "observe_non_object", ["Object.", "%0", "
cannot ", "%0", " non-object"],
+ "observe_non_function", ["Object.", "%0", " cannot deliver
to non-function"],
+ "observe_callback_frozen", ["Object.observe cannot deliver to a
frozen function object"],
+ "observe_type_non_string", ["Object.notify provided
changeRecord with non-string 'type' property"],
// RangeError
"invalid_array_length", ["Invalid array length"],
"stack_overflow", ["Maximum call stack size exceeded"],
=======================================
--- /branches/bleeding_edge/src/proxy.js Mon Feb 20 05:48:24 2012
+++ /branches/bleeding_edge/src/proxy.js Thu Oct 25 07:53:26 2012
@@ -31,7 +31,7 @@
var $Proxy = global.Proxy
-$Proxy.create = function(handler, proto) {
+function ProxyCreate(handler, proto) {
if (!IS_SPEC_OBJECT(handler))
throw MakeTypeError("handler_non_object", ["create"])
if (IS_UNDEFINED(proto))
@@ -41,7 +41,7 @@
return %CreateJSProxy(handler, proto)
}
-$Proxy.createFunction = function(handler, callTrap, constructTrap) {
+function ProxyCreateFunction(handler, callTrap, constructTrap) {
if (!IS_SPEC_OBJECT(handler))
throw MakeTypeError("handler_non_object", ["create"])
if (!IS_SPEC_FUNCTION(callTrap))
@@ -62,6 +62,10 @@
handler, callTrap, constructTrap, $Function.prototype)
}
+%InstallFunctions($Proxy, DONT_ENUM, [
+ "create", ProxyCreate,
+ "createFunction", ProxyCreateFunction
+])
////////////////////////////////////////////////////////////////////////////////
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp Wed Oct 24 02:56:01 2012
+++ /branches/bleeding_edge/tools/gyp/v8.gyp Thu Oct 25 07:53:26 2012
@@ -780,6 +780,7 @@
'../../src/macros.py',
'../../src/proxy.js',
'../../src/collection.js',
+ '../../src/object-observe.js'
],
},
'actions': [
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev