Revision: 12866
Author: [email protected]
Date: Tue Nov 6 04:30:22 2012
Log: Object.observe: implement map bit and functions to access it.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/11276028
http://code.google.com/p/v8/source/detail?r=12866
Modified:
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/runtime.h
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Mon Nov 5 02:25:32 2012
+++ /branches/bleeding_edge/src/objects-inl.h Tue Nov 6 04:30:22 2012
@@ -3157,6 +3157,16 @@
bool Map::owns_descriptors() {
return OwnsDescriptors::decode(bit_field3());
}
+
+
+void Map::set_is_observed(bool is_observed) {
+ set_bit_field3(IsObserved::update(bit_field3(), is_observed));
+}
+
+
+bool Map::is_observed() {
+ return IsObserved::decode(bit_field3());
+}
void Code::set_flags(Code::Flags flags) {
=======================================
--- /branches/bleeding_edge/src/objects.h Mon Nov 5 02:25:32 2012
+++ /branches/bleeding_edge/src/objects.h Tue Nov 6 04:30:22 2012
@@ -4704,6 +4704,7 @@
class FunctionWithPrototype: public BitField<bool, 23, 1> {};
class DictionaryMap: public BitField<bool, 24, 1> {};
class OwnsDescriptors: public BitField<bool, 25, 1> {};
+ class IsObserved: public BitField<bool, 26, 1> {};
// Tells whether the object in the prototype property will be used
// for instances created from this function. If the prototype
@@ -4971,6 +4972,8 @@
inline bool owns_descriptors();
inline void set_owns_descriptors(bool is_shared);
+ inline bool is_observed();
+ inline void set_is_observed(bool is_observed);
MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
=======================================
--- /branches/bleeding_edge/src/runtime.cc Mon Nov 5 02:53:56 2012
+++ /branches/bleeding_edge/src/runtime.cc Tue Nov 6 04:30:22 2012
@@ -13221,6 +13221,29 @@
CONVERT_ARG_CHECKED(JSObject, obj2, 1);
return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) {
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
+ return isolate->heap()->ToBoolean(obj->map()->is_observed());
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
+ ASSERT(args.length() == 2);
+ CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
+ CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1);
+ if (obj->map()->is_observed() != is_observed) {
+ MaybeObject* maybe = obj->map()->Copy();
+ Map* map;
+ if (!maybe->To<Map>(&map)) return maybe;
+ map->set_is_observed(is_observed);
+ obj->set_map(map);
+ }
+ return isolate->heap()->undefined_value();
+}
+
//
----------------------------------------------------------------------------
// Implementation of Runtime
=======================================
--- /branches/bleeding_edge/src/runtime.h Mon Oct 22 07:22:58 2012
+++ /branches/bleeding_edge/src/runtime.h Tue Nov 6 04:30:22 2012
@@ -317,6 +317,10 @@
F(WeakMapDelete, 2, 1) \
F(WeakMapSet, 3, 1) \
\
+ /* Harmony observe */ \
+ F(IsObserved, 1, 1) \
+ F(SetIsObserved, 2, 1) \
+ \
/* Statements */ \
F(NewClosure, 3, 1) \
F(NewObject, 1, 1) \
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev