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

Side by Side Diff: src/factory.cc

Issue 2095673002: Share SharedFunctionInfo between all functions created for a FunctionTemplateInfo (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« 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 "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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 bool is_strict) { 1271 bool is_strict) {
1272 Handle<Map> map = is_strict 1272 Handle<Map> map = is_strict
1273 ? isolate()->strict_function_without_prototype_map() 1273 ? isolate()->strict_function_without_prototype_map()
1274 : isolate()->sloppy_function_without_prototype_map(); 1274 : isolate()->sloppy_function_without_prototype_map();
1275 return NewFunction(map, name, code); 1275 return NewFunction(map, name, code);
1276 } 1276 }
1277 1277
1278 1278
1279 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, 1279 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
1280 Handle<Object> prototype, 1280 Handle<Object> prototype,
1281 bool read_only_prototype,
1282 bool is_strict) { 1281 bool is_strict) {
1283 // In strict mode, readonly strict map is only available during bootstrap 1282 Handle<Map> map = is_strict ? isolate()->strict_function_map()
1284 DCHECK(!is_strict || !read_only_prototype || 1283 : isolate()->sloppy_function_map();
1285 isolate()->bootstrapper()->IsActive());
1286 Handle<Map> map =
1287 is_strict ? isolate()->strict_function_map()
1288 : read_only_prototype
1289 ? isolate()->sloppy_function_with_readonly_prototype_map()
1290 : isolate()->sloppy_function_map();
1291 Handle<JSFunction> result = NewFunction(map, name, code); 1284 Handle<JSFunction> result = NewFunction(map, name, code);
1292 result->set_prototype_or_initial_map(*prototype); 1285 result->set_prototype_or_initial_map(*prototype);
1293 return result; 1286 return result;
1294 } 1287 }
1295 1288
1296 1289
1297 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, 1290 Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
1298 Handle<Object> prototype, 1291 Handle<Object> prototype,
1299 InstanceType type, int instance_size, 1292 InstanceType type, int instance_size,
1300 bool read_only_prototype,
1301 bool install_constructor,
1302 bool is_strict) { 1293 bool is_strict) {
1303 // Allocate the function 1294 // Allocate the function
1304 Handle<JSFunction> function = 1295 Handle<JSFunction> function = NewFunction(name, code, prototype, is_strict);
1305 NewFunction(name, code, prototype, read_only_prototype, is_strict);
1306 1296
1307 ElementsKind elements_kind = 1297 ElementsKind elements_kind =
1308 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; 1298 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS;
1309 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); 1299 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind);
1310 // TODO(littledan): Why do we have this is_generator test when 1300 // TODO(littledan): Why do we have this is_generator test when
1311 // NewFunctionPrototype already handles finding an appropriately 1301 // NewFunctionPrototype already handles finding an appropriately
1312 // shared prototype? 1302 // shared prototype?
1313 if (!function->shared()->is_resumable()) { 1303 if (!function->shared()->is_resumable()) {
1314 if (prototype->IsTheHole(isolate())) { 1304 if (prototype->IsTheHole(isolate())) {
1315 prototype = NewFunctionPrototype(function); 1305 prototype = NewFunctionPrototype(function);
1316 } else if (install_constructor) {
1317 JSObject::AddProperty(Handle<JSObject>::cast(prototype),
1318 constructor_string(), function, DONT_ENUM);
1319 } 1306 }
1320 } 1307 }
1321 1308
1322 JSFunction::SetInitialMap(function, initial_map, 1309 JSFunction::SetInitialMap(function, initial_map,
1323 Handle<JSReceiver>::cast(prototype)); 1310 Handle<JSReceiver>::cast(prototype));
1324 1311
1325 return function; 1312 return function;
1326 } 1313 }
1327 1314
1328 1315
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 } 2379 }
2393 2380
2394 2381
2395 Handle<Object> Factory::ToBoolean(bool value) { 2382 Handle<Object> Factory::ToBoolean(bool value) {
2396 return value ? true_value() : false_value(); 2383 return value ? true_value() : false_value();
2397 } 2384 }
2398 2385
2399 2386
2400 } // namespace internal 2387 } // namespace internal
2401 } // namespace v8 2388 } // namespace v8
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