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

Side by Side Diff: src/factory.cc

Issue 2372373002: Remove getters that duplicate FunctionKind in SharedFunctionInfo and ParseInfo (Closed)
Patch Set: Remove SharedFunctionInfo::is_resumable and FunctionState stuff Created 4 years, 2 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/debug/liveedit.cc ('k') | src/heap/objects-visiting-inl.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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 bool is_strict) { 1351 bool is_strict) {
1352 // Allocate the function 1352 // Allocate the function
1353 Handle<JSFunction> function = NewFunction(name, code, prototype, is_strict); 1353 Handle<JSFunction> function = NewFunction(name, code, prototype, is_strict);
1354 1354
1355 ElementsKind elements_kind = 1355 ElementsKind elements_kind =
1356 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS; 1356 type == JS_ARRAY_TYPE ? FAST_SMI_ELEMENTS : FAST_HOLEY_SMI_ELEMENTS;
1357 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind); 1357 Handle<Map> initial_map = NewMap(type, instance_size, elements_kind);
1358 // TODO(littledan): Why do we have this is_generator test when 1358 // TODO(littledan): Why do we have this is_generator test when
1359 // NewFunctionPrototype already handles finding an appropriately 1359 // NewFunctionPrototype already handles finding an appropriately
1360 // shared prototype? 1360 // shared prototype?
1361 if (!function->shared()->is_resumable()) { 1361 if (!IsResumableFunction(function->shared()->kind())) {
1362 if (prototype->IsTheHole(isolate())) { 1362 if (prototype->IsTheHole(isolate())) {
1363 prototype = NewFunctionPrototype(function); 1363 prototype = NewFunctionPrototype(function);
1364 } 1364 }
1365 } 1365 }
1366 1366
1367 JSFunction::SetInitialMap(function, initial_map, 1367 JSFunction::SetInitialMap(function, initial_map,
1368 Handle<JSReceiver>::cast(prototype)); 1368 Handle<JSReceiver>::cast(prototype));
1369 1369
1370 return function; 1370 return function;
1371 } 1371 }
1372 1372
1373 1373
1374 Handle<JSFunction> Factory::NewFunction(Handle<String> name, 1374 Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1375 Handle<Code> code, 1375 Handle<Code> code,
1376 InstanceType type, 1376 InstanceType type,
1377 int instance_size) { 1377 int instance_size) {
1378 return NewFunction(name, code, the_hole_value(), type, instance_size); 1378 return NewFunction(name, code, the_hole_value(), type, instance_size);
1379 } 1379 }
1380 1380
1381 1381
1382 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { 1382 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
1383 // Make sure to use globals from the function's context, since the function 1383 // Make sure to use globals from the function's context, since the function
1384 // can be from a different context. 1384 // can be from a different context.
1385 Handle<Context> native_context(function->context()->native_context()); 1385 Handle<Context> native_context(function->context()->native_context());
1386 Handle<Map> new_map; 1386 Handle<Map> new_map;
1387 if (function->shared()->is_resumable()) { 1387 if (IsResumableFunction(function->shared()->kind())) {
1388 // Generator and async function prototypes can share maps since they 1388 // Generator and async function prototypes can share maps since they
1389 // don't have "constructor" properties. 1389 // don't have "constructor" properties.
1390 new_map = handle(native_context->generator_object_prototype_map()); 1390 new_map = handle(native_context->generator_object_prototype_map());
1391 } else { 1391 } else {
1392 CHECK(!function->shared()->is_async());
1393 // Each function prototype gets a fresh map to avoid unwanted sharing of 1392 // Each function prototype gets a fresh map to avoid unwanted sharing of
1394 // maps between prototypes of different constructors. 1393 // maps between prototypes of different constructors.
1395 Handle<JSFunction> object_function(native_context->object_function()); 1394 Handle<JSFunction> object_function(native_context->object_function());
1396 DCHECK(object_function->has_initial_map()); 1395 DCHECK(object_function->has_initial_map());
1397 new_map = handle(object_function->initial_map()); 1396 new_map = handle(object_function->initial_map());
1398 } 1397 }
1399 1398
1400 DCHECK(!new_map->is_prototype_map()); 1399 DCHECK(!new_map->is_prototype_map());
1401 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); 1400 Handle<JSObject> prototype = NewJSObjectFromMap(new_map);
1402 1401
1403 if (!function->shared()->is_resumable()) { 1402 if (!IsResumableFunction(function->shared()->kind())) {
1404 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); 1403 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM);
1405 } 1404 }
1406 1405
1407 return prototype; 1406 return prototype;
1408 } 1407 }
1409 1408
1410 1409
1411 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( 1410 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
1412 Handle<SharedFunctionInfo> info, 1411 Handle<SharedFunctionInfo> info,
1413 Handle<Context> context, 1412 Handle<Context> context,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 } 1731 }
1733 } 1732 }
1734 1733
1735 array->set_elements(*elms); 1734 array->set_elements(*elms);
1736 array->set_length(Smi::FromInt(length)); 1735 array->set_length(Smi::FromInt(length));
1737 } 1736 }
1738 1737
1739 1738
1740 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( 1739 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
1741 Handle<JSFunction> function) { 1740 Handle<JSFunction> function) {
1742 DCHECK(function->shared()->is_resumable()); 1741 DCHECK(IsResumableFunction(function->shared()->kind()));
1743 JSFunction::EnsureHasInitialMap(function); 1742 JSFunction::EnsureHasInitialMap(function);
1744 Handle<Map> map(function->initial_map()); 1743 Handle<Map> map(function->initial_map());
1745 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); 1744 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type());
1746 CALL_HEAP_FUNCTION( 1745 CALL_HEAP_FUNCTION(
1747 isolate(), 1746 isolate(),
1748 isolate()->heap()->AllocateJSObjectFromMap(*map), 1747 isolate()->heap()->AllocateJSObjectFromMap(*map),
1749 JSGeneratorObject); 1748 JSGeneratorObject);
1750 } 1749 }
1751 1750
1752 Handle<Module> Factory::NewModule(Handle<SharedFunctionInfo> code) { 1751 Handle<Module> Factory::NewModule(Handle<SharedFunctionInfo> code) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 Handle<AccessorInfo> prototype = 2603 Handle<AccessorInfo> prototype =
2605 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2604 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2606 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2605 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2607 prototype, attribs); 2606 prototype, attribs);
2608 map->AppendDescriptor(&d); 2607 map->AppendDescriptor(&d);
2609 } 2608 }
2610 } 2609 }
2611 2610
2612 } // namespace internal 2611 } // namespace internal
2613 } // namespace v8 2612 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/liveedit.cc ('k') | src/heap/objects-visiting-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698