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 is_strict) { |
1272 return NewFunction( | 1273 Handle<Map> map = is_strict |
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 is_strict) { |
1282 ? isolate()->sloppy_function_with_readonly_prototype_map() | 1284 // In strict mode, readonly strict map is only available during bootstrap |
arv (Not doing code reviews)
2015/03/26 13:59:14
I still find this confusing :-)
strict map with r
caitp (gmail)
2015/03/26 14:08:46
That seems to happen in Runtime_DefineClass --- th
| |
1283 : isolate()->sloppy_function_map(); | 1285 DCHECK(!is_strict || !read_only_prototype || |
1286 isolate()->bootstrapper()->IsActive()); | |
1287 Handle<Map> map = is_strict | |
1288 ? isolate()->strict_function_map() | |
1289 : read_only_prototype | |
1290 ? isolate()->sloppy_function_with_readonly_prototype_map() | |
1291 : isolate()->sloppy_function_map(); | |
1284 Handle<JSFunction> result = NewFunction(map, name, code); | 1292 Handle<JSFunction> result = NewFunction(map, name, code); |
1285 result->set_prototype_or_initial_map(*prototype); | 1293 result->set_prototype_or_initial_map(*prototype); |
1286 return result; | 1294 return result; |
1287 } | 1295 } |
1288 | 1296 |
1289 | 1297 |
1290 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, | 1298 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, |
1291 Handle<Object> prototype, | 1299 Handle<Object> prototype, |
1292 InstanceType type, int instance_size, | 1300 InstanceType type, int instance_size, |
1293 bool read_only_prototype, | 1301 bool read_only_prototype, |
1294 bool install_constructor) { | 1302 bool install_constructor, |
1303 bool is_strict) { | |
1295 // Allocate the function | 1304 // Allocate the function |
1296 Handle<JSFunction> function = NewFunction( | 1305 Handle<JSFunction> function = NewFunction( |
1297 name, code, prototype, read_only_prototype); | 1306 name, code, prototype, read_only_prototype, is_strict); |
1298 | 1307 |
1299 ElementsKind elements_kind = | 1308 ElementsKind elements_kind = |
1300 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; | 1309 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; |
1301 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); | 1310 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); |
1302 if (!function->shared()->is_generator()) { | 1311 if (!function->shared()->is_generator()) { |
1303 if (prototype->IsTheHole()) { | 1312 if (prototype->IsTheHole()) { |
1304 prototype = NewFunctionPrototype(function); | 1313 prototype = NewFunctionPrototype(function); |
1305 } else if (install_constructor) { | 1314 } else if (install_constructor) { |
1306 JSObject::AddProperty(Handle<JSObject>::cast(prototype), | 1315 JSObject::AddProperty(Handle<JSObject>::cast(prototype), |
1307 constructor_string(), function, DONT_ENUM); | 1316 constructor_string(), function, DONT_ENUM); |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2321 return Handle<Object>::null(); | 2330 return Handle<Object>::null(); |
2322 } | 2331 } |
2323 | 2332 |
2324 | 2333 |
2325 Handle<Object> Factory::ToBoolean(bool value) { | 2334 Handle<Object> Factory::ToBoolean(bool value) { |
2326 return value ? true_value() : false_value(); | 2335 return value ? true_value() : false_value(); |
2327 } | 2336 } |
2328 | 2337 |
2329 | 2338 |
2330 } } // namespace v8::internal | 2339 } } // namespace v8::internal |
OLD | NEW |