Revision: 21243
Author:   [email protected]
Date:     Fri May  9 17:59:15 2014 UTC
Log: Directly create API functions with readonly prototypes rather than converting. Remove FunctionSetReadOnlyPrototype.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/274463003
http://code.google.com/p/v8/source/detail?r=21243

Deleted:
/branches/bleeding_edge/test/mjsunit/runtime-gen/functionsetreadonlyprototype.js
Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/apinatives.js
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/src/contexts.h
 /branches/bleeding_edge/src/factory.cc
 /branches/bleeding_edge/src/factory.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/runtime.h

=======================================
--- /branches/bleeding_edge/test/mjsunit/runtime-gen/functionsetreadonlyprototype.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 _function = function() {};
-%FunctionSetReadOnlyPrototype(_function);
=======================================
--- /branches/bleeding_edge/include/v8.h        Fri May  9 15:36:51 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Fri May  9 17:59:15 2014 UTC
@@ -5530,7 +5530,7 @@
   static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
   static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
   static const int kContextHeaderSize = 2 * kApiPointerSize;
-  static const int kContextEmbedderDataIndex = 74;
+  static const int kContextEmbedderDataIndex = 75;
   static const int kFullStringRepresentationMask = 0x07;
   static const int kStringEncodingMask = 0x4;
   static const int kExternalTwoByteRepresentationTag = 0x02;
=======================================
--- /branches/bleeding_edge/src/apinatives.js   Tue Apr 29 17:48:07 2014 UTC
+++ /branches/bleeding_edge/src/apinatives.js   Fri May  9 17:59:15 2014 UTC
@@ -49,9 +49,8 @@
   if (!isFunctionCached) {
     try {
       var flags = %GetTemplateField(data, kApiFlagOffset);
-      var has_proto = !(flags & (1 << kRemovePrototypeBit));
       var prototype;
-      if (has_proto) {
+      if (!(flags & (1 << kRemovePrototypeBit))) {
var template = %GetTemplateField(data, kApiPrototypeTemplateOffset);
         prototype = typeof template === 'undefined'
             ?  {} : Instantiate(template);
@@ -68,9 +67,6 @@
       if (name) %FunctionSetName(fun, name);
       var doNotCache = flags & (1 << kDoNotCacheBit);
       if (!doNotCache) cache[serialNumber] = fun;
-      if (has_proto && flags & (1 << kReadOnlyPrototypeBit)) {
-        %FunctionSetReadOnlyPrototype(fun);
-      }
       ConfigureTemplateInstance(fun, data);
       if (doNotCache) return fun;
     } catch (e) {
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Fri May  9 17:39:54 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Fri May  9 17:59:15 2014 UTC
@@ -451,6 +451,8 @@
// Later the map is replaced with writable prototype map, allocated below.
   Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
   native_context()->set_sloppy_function_map(*function_map);
+  native_context()->set_sloppy_function_with_readonly_prototype_map(
+      *function_map);

   // The final map for functions. Writeable prototype.
   // This map is installed in MakeFunctionInstancePrototypeWritable.
=======================================
--- /branches/bleeding_edge/src/contexts.h      Fri May  2 16:13:10 2014 UTC
+++ /branches/bleeding_edge/src/contexts.h      Fri May  9 17:59:15 2014 UTC
@@ -123,6 +123,8 @@
       uint8_clamped_array_external_map) \
   V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \
   V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map) \
+  V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \
+    sloppy_function_with_readonly_prototype_map) \
   V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \
   V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
     sloppy_function_without_prototype_map) \
@@ -265,6 +267,7 @@
     STRICT_ARGUMENTS_BOILERPLATE_INDEX,
     REGEXP_RESULT_MAP_INDEX,
     SLOPPY_FUNCTION_MAP_INDEX,
+    SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX,
     STRICT_FUNCTION_MAP_INDEX,
     SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
     STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
=======================================
--- /branches/bleeding_edge/src/factory.cc      Fri May  9 17:39:54 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc      Fri May  9 17:59:15 2014 UTC
@@ -1210,7 +1210,9 @@
   ASSERT((info->strict_mode() == SLOPPY) &&
          (map.is_identical_to(isolate()->sloppy_function_map()) ||
           map.is_identical_to(
-              isolate()->sloppy_function_without_prototype_map())));
+              isolate()->sloppy_function_without_prototype_map()) ||
+          map.is_identical_to(
+              isolate()->sloppy_function_with_readonly_prototype_map())));
   return NewFunction(map, info, context);
 }

@@ -1230,9 +1232,12 @@

 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
                                         Handle<Code> code,
-                                        Handle<Object> prototype) {
-  Handle<JSFunction> result = NewFunction(
-      isolate()->sloppy_function_map(), name, code);
+                                        Handle<Object> prototype,
+                                        bool read_only_prototype) {
+  Handle<Map> map = read_only_prototype
+      ? isolate()->sloppy_function_with_readonly_prototype_map()
+      : isolate()->sloppy_function_map();
+  Handle<JSFunction> result = NewFunction(map, name, code);
   result->set_prototype_or_initial_map(*prototype);
   return result;
 }
@@ -1242,9 +1247,11 @@
                                         Handle<Code> code,
                                         Handle<Object> prototype,
                                         InstanceType type,
-                                        int instance_size) {
+                                        int instance_size,
+                                        bool read_only_prototype) {
   // Allocate the function
-  Handle<JSFunction> function = NewFunction(name, code, prototype);
+  Handle<JSFunction> function = NewFunction(
+      name, code, prototype, read_only_prototype);

   Handle<Map> initial_map = NewMap(
       type, instance_size, GetInitialFastElementsKind());
@@ -2101,7 +2108,8 @@
         break;
     }

- result = NewFunction(empty_string(), code, prototype, type, instance_size);
+    result = NewFunction(empty_string(), code, prototype, type,
+                         instance_size, obj->read_only_prototype());
   }

   result->shared()->set_length(obj->length());
=======================================
--- /branches/bleeding_edge/src/factory.h       Fri May  9 17:39:54 2014 UTC
+++ /branches/bleeding_edge/src/factory.h       Fri May  9 17:59:15 2014 UTC
@@ -453,7 +453,8 @@

   Handle<JSFunction> NewFunction(Handle<String> name,
                                  Handle<Code> code,
-                                 Handle<Object> prototype);
+                                 Handle<Object> prototype,
+                                 bool read_only_prototype = false);
   Handle<JSFunction> NewFunction(Handle<String> name);
   Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
                                                  Handle<Code> code);
@@ -467,7 +468,8 @@
                                  Handle<Code> code,
                                  Handle<Object> prototype,
                                  InstanceType type,
-                                 int instance_size);
+                                 int instance_size,
+                                 bool read_only_prototype = false);
   Handle<JSFunction> NewFunction(Handle<String> name,
                                  Handle<Code> code,
                                  InstanceType type,
=======================================
--- /branches/bleeding_edge/src/objects.cc      Fri May  9 16:18:58 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Fri May  9 17:59:15 2014 UTC
@@ -7562,7 +7562,7 @@
   Isolate* isolate = map->GetIsolate();
Handle<DescriptorArray> new_desc = DescriptorArray::CopyUpToAddAttributes( handle(map->instance_descriptors(), isolate), num_descriptors, FROZEN);
-  Handle<Map> new_map = Map::CopyReplaceDescriptors(
+  Handle<Map> new_map = CopyReplaceDescriptors(
map, new_desc, INSERT_TRANSITION, isolate->factory()->frozen_symbol());
   new_map->freeze();
   new_map->set_is_extensible(false);
=======================================
--- /branches/bleeding_edge/src/objects.h       Fri May  9 16:18:58 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Fri May  9 17:59:15 2014 UTC
@@ -6305,11 +6305,6 @@
   static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
                                           Descriptor* descriptor,
                                           TransitionFlag flag);
-  static Handle<Map> CopyReplaceDescriptor(Handle<Map> map,
- Handle<DescriptorArray> descriptors,
-                                           Descriptor* descriptor,
-                                           int index,
-                                           TransitionFlag flag);

   MUST_USE_RESULT static MaybeHandle<Map> CopyWithField(
       Handle<Map> map,
@@ -6582,6 +6577,11 @@
       TransitionFlag flag,
       MaybeHandle<Name> maybe_name,
       SimpleTransitionFlag simple_flag = FULL_TRANSITION);
+  static Handle<Map> CopyReplaceDescriptor(Handle<Map> map,
+ Handle<DescriptorArray> descriptors,
+                                           Descriptor* descriptor,
+                                           int index,
+                                           TransitionFlag flag);

   static Handle<Map> CopyNormalized(Handle<Map> map,
                                     PropertyNormalizationMode mode,
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Fri May  9 17:39:54 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Fri May  9 17:59:15 2014 UTC
@@ -3040,49 +3040,6 @@
   Accessors::FunctionSetPrototype(fun, value);
   return args[0];  // return TOS
 }
-
-
-RUNTIME_FUNCTION(Runtime_FunctionSetReadOnlyPrototype) {
-  HandleScope shs(isolate);
-  RUNTIME_ASSERT(args.length() == 1);
-  CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
-
-  Handle<String> name = isolate->factory()->prototype_string();
-
-  if (function->HasFastProperties()) {
-    // Construct a new field descriptor with updated attributes.
-    Handle<DescriptorArray> instance_desc =
-        handle(function->map()->instance_descriptors());
-
-    int index = instance_desc->SearchWithCache(*name, function->map());
-    ASSERT(index != DescriptorArray::kNotFound);
-    PropertyDetails details = instance_desc->GetDetails(index);
-
-    CallbacksDescriptor new_desc(
-        name,
-        handle(instance_desc->GetValue(index), isolate),
-        static_cast<PropertyAttributes>(details.attributes() | READ_ONLY));
-
-    // Create a new map featuring the new field descriptors array.
-    Handle<Map> map = handle(function->map());
-    Handle<Map> new_map = Map::CopyReplaceDescriptor(
-        map, instance_desc, &new_desc, index, OMIT_TRANSITION);
-
-    JSObject::MigrateToMap(function, new_map);
-  } else {  // Dictionary properties.
-    // Directly manipulate the property details.
-    DisallowHeapAllocation no_gc;
-    int entry = function->property_dictionary()->FindEntry(name);
-    ASSERT(entry != NameDictionary::kNotFound);
- PropertyDetails details = function->property_dictionary()->DetailsAt(entry);
-    PropertyDetails new_details(
-        static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),
-        details.type(),
-        details.dictionary_index());
-    function->property_dictionary()->DetailsAtPut(entry, new_details);
-  }
-  return *function;
-}


 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) {
=======================================
--- /branches/bleeding_edge/src/runtime.h       Tue May  6 09:28:08 2014 UTC
+++ /branches/bleeding_edge/src/runtime.h       Fri May  9 17:59:15 2014 UTC
@@ -180,7 +180,6 @@
   F(FunctionSetInstanceClassName, 2, 1) \
   F(FunctionSetLength, 2, 1) \
   F(FunctionSetPrototype, 2, 1) \
-  F(FunctionSetReadOnlyPrototype, 1, 1) \
   F(FunctionGetName, 1, 1) \
   F(FunctionSetName, 2, 1) \
   F(FunctionNameShouldPrintAsAnonymous, 1, 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.

Reply via email to