Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/runtime.cc

Issue 274463003: Directly create API functions with readonly prototypes rather than converting. Remove FunctionSetRe… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove test Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/runtime-gen/functionsetreadonlyprototype.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "v8.h" 8 #include "v8.h"
9 9
10 #include "accessors.h" 10 #include "accessors.h"
(...skipping 3024 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 ASSERT(args.length() == 2); 3035 ASSERT(args.length() == 2);
3036 3036
3037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 3037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
3038 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 3038 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
3039 ASSERT(fun->should_have_prototype()); 3039 ASSERT(fun->should_have_prototype());
3040 Accessors::FunctionSetPrototype(fun, value); 3040 Accessors::FunctionSetPrototype(fun, value);
3041 return args[0]; // return TOS 3041 return args[0]; // return TOS
3042 } 3042 }
3043 3043
3044 3044
3045 RUNTIME_FUNCTION(Runtime_FunctionSetReadOnlyPrototype) {
3046 HandleScope shs(isolate);
3047 RUNTIME_ASSERT(args.length() == 1);
3048 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
3049
3050 Handle<String> name = isolate->factory()->prototype_string();
3051
3052 if (function->HasFastProperties()) {
3053 // Construct a new field descriptor with updated attributes.
3054 Handle<DescriptorArray> instance_desc =
3055 handle(function->map()->instance_descriptors());
3056
3057 int index = instance_desc->SearchWithCache(*name, function->map());
3058 ASSERT(index != DescriptorArray::kNotFound);
3059 PropertyDetails details = instance_desc->GetDetails(index);
3060
3061 CallbacksDescriptor new_desc(
3062 name,
3063 handle(instance_desc->GetValue(index), isolate),
3064 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY));
3065
3066 // Create a new map featuring the new field descriptors array.
3067 Handle<Map> map = handle(function->map());
3068 Handle<Map> new_map = Map::CopyReplaceDescriptor(
3069 map, instance_desc, &new_desc, index, OMIT_TRANSITION);
3070
3071 JSObject::MigrateToMap(function, new_map);
3072 } else { // Dictionary properties.
3073 // Directly manipulate the property details.
3074 DisallowHeapAllocation no_gc;
3075 int entry = function->property_dictionary()->FindEntry(name);
3076 ASSERT(entry != NameDictionary::kNotFound);
3077 PropertyDetails details = function->property_dictionary()->DetailsAt(entry);
3078 PropertyDetails new_details(
3079 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),
3080 details.type(),
3081 details.dictionary_index());
3082 function->property_dictionary()->DetailsAtPut(entry, new_details);
3083 }
3084 return *function;
3085 }
3086
3087
3088 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { 3045 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) {
3089 SealHandleScope shs(isolate); 3046 SealHandleScope shs(isolate);
3090 ASSERT(args.length() == 1); 3047 ASSERT(args.length() == 1);
3091 3048
3092 CONVERT_ARG_CHECKED(JSFunction, f, 0); 3049 CONVERT_ARG_CHECKED(JSFunction, f, 0);
3093 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); 3050 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction());
3094 } 3051 }
3095 3052
3096 3053
3097 RUNTIME_FUNCTION(Runtime_FunctionIsBuiltin) { 3054 RUNTIME_FUNCTION(Runtime_FunctionIsBuiltin) {
(...skipping 12161 matching lines...) Expand 10 before | Expand all | Expand 10 after
15259 } 15216 }
15260 return NULL; 15217 return NULL;
15261 } 15218 }
15262 15219
15263 15220
15264 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15221 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15265 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15222 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15266 } 15223 }
15267 15224
15268 } } // namespace v8::internal 15225 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/runtime-gen/functionsetreadonlyprototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698