OLD | NEW |
---|---|
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 "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1249 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, | 1249 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
1250 Handle<String> name, | 1250 Handle<String> name, |
1251 MaybeHandle<Code> code) { | 1251 MaybeHandle<Code> code) { |
1252 Handle<Context> context(isolate()->native_context()); | 1252 Handle<Context> context(isolate()->native_context()); |
1253 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); | 1253 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); |
1254 DCHECK(is_sloppy(info->language_mode()) && | 1254 DCHECK(is_sloppy(info->language_mode()) && |
1255 (map.is_identical_to(isolate()->sloppy_function_map()) || | 1255 (map.is_identical_to(isolate()->sloppy_function_map()) || |
1256 map.is_identical_to( | 1256 map.is_identical_to( |
1257 isolate()->sloppy_function_without_prototype_map()) || | 1257 isolate()->sloppy_function_without_prototype_map()) || |
1258 map.is_identical_to( | 1258 map.is_identical_to( |
1259 isolate()->sloppy_function_with_readonly_prototype_map()))); | 1259 isolate()->sloppy_function_with_readonly_prototype_map()) || |
1260 map.is_identical_to(isolate()->strict_function_map()))); | |
1260 return NewFunction(map, info, context); | 1261 return NewFunction(map, info, context); |
1261 } | 1262 } |
1262 | 1263 |
1263 | 1264 |
1264 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { | 1265 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { |
1265 return NewFunction( | 1266 return NewFunction( |
1266 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); | 1267 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); |
1267 } | 1268 } |
1268 | 1269 |
1269 | 1270 |
1270 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, | 1271 Handle<JSFunction> Factory::NewFunctionWithoutPrototype( |
1271 Handle<Code> code) { | 1272 Handle<String> name, Handle<Code> code, bool use_empty_function_map) { |
1272 return NewFunction( | 1273 Handle<Map> map = use_empty_function_map |
arv (Not doing code reviews)
2015/03/26 12:46:43
What does "empty function" mean here? It does not
caitp (gmail)
2015/03/26 13:00:17
originally I was saving the map of the empty funct
arv (Not doing code reviews)
2015/03/26 13:03:30
strict sounds more correct here.
| |
1273 isolate()->sloppy_function_without_prototype_map(), name, code); | 1274 ? isolate()->strict_function_without_prototype_map() |
1275 : isolate()->sloppy_function_without_prototype_map(); | |
1276 return NewFunction(map, name, code); | |
1274 } | 1277 } |
1275 | 1278 |
1276 | 1279 |
1277 Handle<JSFunction> Factory::NewFunction(Handle<String> name, | 1280 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, |
1278 Handle<Code> code, | |
1279 Handle<Object> prototype, | 1281 Handle<Object> prototype, |
1280 bool read_only_prototype) { | 1282 bool read_only_prototype, |
1281 Handle<Map> map = read_only_prototype | 1283 bool use_empty_function_map) { |
1282 ? isolate()->sloppy_function_with_readonly_prototype_map() | 1284 DCHECK(!use_empty_function_map || !read_only_prototype); |
1283 : isolate()->sloppy_function_map(); | 1285 Handle<Map> map = use_empty_function_map |
1286 ? isolate()->strict_function_map() | |
arv (Not doing code reviews)
2015/03/26 12:46:43
Is there no strict function with readonly prototyp
caitp (gmail)
2015/03/26 13:00:17
well, technically strict_function_map() IS a reado
caitp (gmail)
2015/03/26 13:03:02
wait, I'm wrong --- it's readonly during bootstrap
arv (Not doing code reviews)
2015/03/26 13:03:30
Maybe add a DCHECK to make sure we don't get the i
caitp (gmail)
2015/03/26 13:46:01
Done --- the DCHECK is now "!strict || !readonly_p
| |
1287 : read_only_prototype | |
1288 ? isolate()->sloppy_function_with_readonly_prototype_map() | |
1289 : isolate()->sloppy_function_map(); | |
1284 Handle<JSFunction> result = NewFunction(map, name, code); | 1290 Handle<JSFunction> result = NewFunction(map, name, code); |
1285 result->set_prototype_or_initial_map(*prototype); | 1291 result->set_prototype_or_initial_map(*prototype); |
1286 return result; | 1292 return result; |
1287 } | 1293 } |
1288 | 1294 |
1289 | 1295 |
1290 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, | 1296 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, |
1291 Handle<Object> prototype, | 1297 Handle<Object> prototype, |
1292 InstanceType type, int instance_size, | 1298 InstanceType type, int instance_size, |
1293 bool read_only_prototype, | 1299 bool read_only_prototype, |
1294 bool install_constructor) { | 1300 bool install_constructor, |
1301 bool use_empty_function_map) { | |
1295 // Allocate the function | 1302 // Allocate the function |
1296 Handle<JSFunction> function = NewFunction( | 1303 Handle<JSFunction> function = NewFunction( |
1297 name, code, prototype, read_only_prototype); | 1304 name, code, prototype, read_only_prototype, use_empty_function_map); |
1298 | 1305 |
1299 ElementsKind elements_kind = | 1306 ElementsKind elements_kind = |
1300 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; | 1307 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; |
1301 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); | 1308 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); |
1302 if (!function->shared()->is_generator()) { | 1309 if (!function->shared()->is_generator()) { |
1303 if (prototype->IsTheHole()) { | 1310 if (prototype->IsTheHole()) { |
1304 prototype = NewFunctionPrototype(function); | 1311 prototype = NewFunctionPrototype(function); |
1305 } else if (install_constructor) { | 1312 } else if (install_constructor) { |
1306 JSObject::AddProperty(Handle<JSObject>::cast(prototype), | 1313 JSObject::AddProperty(Handle<JSObject>::cast(prototype), |
1307 constructor_string(), function, DONT_ENUM); | 1314 constructor_string(), function, DONT_ENUM); |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2321 return Handle<Object>::null(); | 2328 return Handle<Object>::null(); |
2322 } | 2329 } |
2323 | 2330 |
2324 | 2331 |
2325 Handle<Object> Factory::ToBoolean(bool value) { | 2332 Handle<Object> Factory::ToBoolean(bool value) { |
2326 return value ? true_value() : false_value(); | 2333 return value ? true_value() : false_value(); |
2327 } | 2334 } |
2328 | 2335 |
2329 | 2336 |
2330 } } // namespace v8::internal | 2337 } } // namespace v8::internal |
OLD | NEW |