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

Side by Side Diff: src/factory.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/factory.h ('k') | src/objects.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "factory.h" 5 #include "factory.h"
6 6
7 #include "conversions.h" 7 #include "conversions.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 10
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1203
1204 1204
1205 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1205 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1206 Handle<String> name, 1206 Handle<String> name,
1207 MaybeHandle<Code> code) { 1207 MaybeHandle<Code> code) {
1208 Handle<Context> context(isolate()->context()->native_context()); 1208 Handle<Context> context(isolate()->context()->native_context());
1209 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); 1209 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code);
1210 ASSERT((info->strict_mode() == SLOPPY) && 1210 ASSERT((info->strict_mode() == SLOPPY) &&
1211 (map.is_identical_to(isolate()->sloppy_function_map()) || 1211 (map.is_identical_to(isolate()->sloppy_function_map()) ||
1212 map.is_identical_to( 1212 map.is_identical_to(
1213 isolate()->sloppy_function_without_prototype_map()))); 1213 isolate()->sloppy_function_without_prototype_map()) ||
1214 map.is_identical_to(
1215 isolate()->sloppy_function_with_readonly_prototype_map())));
1214 return NewFunction(map, info, context); 1216 return NewFunction(map, info, context);
1215 } 1217 }
1216 1218
1217 1219
1218 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { 1220 Handle<JSFunction> Factory::NewFunction(Handle<String> name) {
1219 return NewFunction( 1221 return NewFunction(
1220 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); 1222 isolate()->sloppy_function_map(), name, MaybeHandle<Code>());
1221 } 1223 }
1222 1224
1223 1225
1224 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, 1226 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
1225 Handle<Code> code) { 1227 Handle<Code> code) {
1226 return NewFunction( 1228 return NewFunction(
1227 isolate()->sloppy_function_without_prototype_map(), name, code); 1229 isolate()->sloppy_function_without_prototype_map(), name, code);
1228 } 1230 }
1229 1231
1230 1232
1231 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 1233 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1232 Handle<Code> code, 1234 Handle<Code> code,
1233 Handle<Object> prototype) { 1235 Handle<Object> prototype,
1234 Handle<JSFunction> result = NewFunction( 1236 bool read_only_prototype) {
1235 isolate()->sloppy_function_map(), name, code); 1237 Handle<Map> map = read_only_prototype
1238 ? isolate()->sloppy_function_with_readonly_prototype_map()
1239 : isolate()->sloppy_function_map();
1240 Handle<JSFunction> result = NewFunction(map, name, code);
1236 result->set_prototype_or_initial_map(*prototype); 1241 result->set_prototype_or_initial_map(*prototype);
1237 return result; 1242 return result;
1238 } 1243 }
1239 1244
1240 1245
1241 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 1246 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1242 Handle<Code> code, 1247 Handle<Code> code,
1243 Handle<Object> prototype, 1248 Handle<Object> prototype,
1244 InstanceType type, 1249 InstanceType type,
1245 int instance_size) { 1250 int instance_size,
1251 bool read_only_prototype) {
1246 // Allocate the function 1252 // Allocate the function
1247 Handle<JSFunction> function = NewFunction(name, code, prototype); 1253 Handle<JSFunction> function = NewFunction(
1254 name, code, prototype, read_only_prototype);
1248 1255
1249 Handle<Map> initial_map = NewMap( 1256 Handle<Map> initial_map = NewMap(
1250 type, instance_size, GetInitialFastElementsKind()); 1257 type, instance_size, GetInitialFastElementsKind());
1251 if (prototype->IsTheHole() && !function->shared()->is_generator()) { 1258 if (prototype->IsTheHole() && !function->shared()->is_generator()) {
1252 prototype = NewFunctionPrototype(function); 1259 prototype = NewFunctionPrototype(function);
1253 } 1260 }
1254 initial_map->set_prototype(*prototype); 1261 initial_map->set_prototype(*prototype);
1255 function->set_initial_map(*initial_map); 1262 function->set_initial_map(*initial_map);
1256 initial_map->set_constructor(*function); 1263 initial_map->set_constructor(*function);
1257 1264
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 case OuterGlobalObject: 2101 case OuterGlobalObject:
2095 type = JS_GLOBAL_PROXY_TYPE; 2102 type = JS_GLOBAL_PROXY_TYPE;
2096 instance_size += JSGlobalProxy::kSize; 2103 instance_size += JSGlobalProxy::kSize;
2097 break; 2104 break;
2098 default: 2105 default:
2099 UNREACHABLE(); 2106 UNREACHABLE();
2100 type = JS_OBJECT_TYPE; // Keep the compiler happy. 2107 type = JS_OBJECT_TYPE; // Keep the compiler happy.
2101 break; 2108 break;
2102 } 2109 }
2103 2110
2104 result = NewFunction(empty_string(), code, prototype, type, instance_size); 2111 result = NewFunction(empty_string(), code, prototype, type,
2112 instance_size, obj->read_only_prototype());
2105 } 2113 }
2106 2114
2107 result->shared()->set_length(obj->length()); 2115 result->shared()->set_length(obj->length());
2108 Handle<Object> class_name(obj->class_name(), isolate()); 2116 Handle<Object> class_name(obj->class_name(), isolate());
2109 if (class_name->IsString()) { 2117 if (class_name->IsString()) {
2110 result->shared()->set_instance_class_name(*class_name); 2118 result->shared()->set_instance_class_name(*class_name);
2111 result->shared()->set_name(*class_name); 2119 result->shared()->set_name(*class_name);
2112 } 2120 }
2113 result->shared()->set_function_data(*obj); 2121 result->shared()->set_function_data(*obj);
2114 result->shared()->set_construct_stub(*construct_stub); 2122 result->shared()->set_construct_stub(*construct_stub);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 return Handle<Object>::null(); 2330 return Handle<Object>::null();
2323 } 2331 }
2324 2332
2325 2333
2326 Handle<Object> Factory::ToBoolean(bool value) { 2334 Handle<Object> Factory::ToBoolean(bool value) {
2327 return value ? true_value() : false_value(); 2335 return value ? true_value() : false_value();
2328 } 2336 }
2329 2337
2330 2338
2331 } } // namespace v8::internal 2339 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698