Added Extensible property to objects and made methods for extracting and setting it.
authorricow@chromium.org <ricow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Jan 2010 12:56:36 +0000 (12:56 +0000)
committerricow@chromium.org <ricow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Jan 2010 12:56:36 +0000 (12:56 +0000)
Also added one method to runtime to get the extensible value
Additionally, added a check on the number of arguments in the start of GetOwnProperty.

Review URL: http://codereview.chromium.org/545116

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3646 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/objects.h
src/runtime.cc
src/runtime.h

index 5d088e5..40be0df 100644 (file)
@@ -2889,6 +2889,14 @@ class Map: public HeapObject {
     return ((1 << kHasInstanceCallHandler) & bit_field()) != 0;
   }
 
+  inline void set_is_extensible() {
+    set_bit_field2(bit_field2() | (1 << kIsExtensible));
+  }
+
+  inline bool is_extensible() {
+    return ((1 << kIsExtensible) & bit_field2()) != 0;
+  }
+
   // Tells whether the instance needs security checks when accessing its
   // properties.
   inline void set_is_access_check_needed(bool access_check_needed);
@@ -3006,6 +3014,7 @@ class Map: public HeapObject {
 
   // Bit positions for bit field 2
   static const int kNeedsLoading = 0;
+  static const int kIsExtensible = 1;
 
  private:
   DISALLOW_IMPLICIT_CONSTRUCTORS(Map);
index 5c45692..a26ca56 100644 (file)
@@ -583,6 +583,7 @@ static void GetOwnPropertyImplementation(JSObject* obj,
 //  if args[1] is an accessor on args[0]
 //         [true, GetFunction, SetFunction, Enumerable, Configurable]
 static Object* Runtime_GetOwnProperty(Arguments args) {
+  ASSERT(args.lenght() == 2);
   HandleScope scope;
   Handle<FixedArray> elms = Factory::NewFixedArray(5);
   Handle<JSArray> desc = Factory::NewJSArrayWithElements(elms);
@@ -626,6 +627,14 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
 }
 
 
+static Object* Runtime_IsExtensible(Arguments args) {
+  ASSERT(args.length() == 1);
+  CONVERT_CHECKED(JSObject, obj, args[0]);
+  return obj->map()->is_extensible() ?  Heap::true_value()
+                                     : Heap::false_value();
+}
+
+
 static Object* Runtime_RegExpCompile(Arguments args) {
   HandleScope scope;
   ASSERT(args.length() == 3);
index 59b5f30..efef7db 100644 (file)
@@ -68,6 +68,8 @@ namespace internal {
   \
   F(GetOwnProperty, 2, 1) \
   \
+  F(IsExtensible, 1, 1) \
+  \
   /* Utilities */ \
   F(GetCalledFunction, 0, 1) \
   F(GetFunctionDelegate, 1, 1) \