OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 bool IsMonomorphic() const { return !receiver_type_.is_null(); } | 1346 bool IsMonomorphic() const { return !receiver_type_.is_null(); } |
1347 Handle<Map> GetReceiverType() const { return receiver_type_; } | 1347 Handle<Map> GetReceiverType() const { return receiver_type_; } |
1348 | 1348 |
1349 bool IsCompileTimeValue() const; | 1349 bool IsCompileTimeValue() const; |
1350 | 1350 |
1351 void set_emit_store(bool emit_store); | 1351 void set_emit_store(bool emit_store); |
1352 bool emit_store() const; | 1352 bool emit_store() const; |
1353 | 1353 |
1354 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } | 1354 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } |
1355 | 1355 |
1356 bool IsNullPrototype() const { | |
1357 if (!IsPrototype()) return false; | |
1358 return value()->IsNullLiteral(); | |
adamk
2017/03/13 18:10:44
Nit:
return IsPrototype() && value()->IsNullLiter
Camillo Bruni
2017/03/17 16:40:55
uhm, right, used to be more complex ;)
| |
1359 } | |
1360 bool IsPrototype() const { return kind() == PROTOTYPE; } | |
1361 | |
1356 private: | 1362 private: |
1357 friend class AstNodeFactory; | 1363 friend class AstNodeFactory; |
1358 | 1364 |
1359 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, | 1365 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, |
1360 bool is_computed_name); | 1366 bool is_computed_name); |
1361 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, | 1367 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, |
1362 Expression* value, bool is_computed_name); | 1368 Expression* value, bool is_computed_name); |
1363 | 1369 |
1364 Kind kind_; | 1370 Kind kind_; |
1365 bool emit_store_; | 1371 bool emit_store_; |
(...skipping 17 matching lines...) Expand all Loading... | |
1383 bool may_store_doubles() const { | 1389 bool may_store_doubles() const { |
1384 return MayStoreDoublesField::decode(bit_field_); | 1390 return MayStoreDoublesField::decode(bit_field_); |
1385 } | 1391 } |
1386 bool has_elements() const { return HasElementsField::decode(bit_field_); } | 1392 bool has_elements() const { return HasElementsField::decode(bit_field_); } |
1387 bool has_shallow_properties() const { | 1393 bool has_shallow_properties() const { |
1388 return depth() == 1 && !has_elements() && !may_store_doubles(); | 1394 return depth() == 1 && !has_elements() && !may_store_doubles(); |
1389 } | 1395 } |
1390 bool has_rest_property() const { | 1396 bool has_rest_property() const { |
1391 return HasRestPropertyField::decode(bit_field_); | 1397 return HasRestPropertyField::decode(bit_field_); |
1392 } | 1398 } |
1393 | 1399 bool HasNullPrototype() const { |
1400 for (int i = 0; i < properties()->length(); i++) { | |
1401 const ObjectLiteral::Property* property = properties()->at(i); | |
1402 if (property->IsNullPrototype()) return true; | |
1403 } | |
1404 return false; | |
1405 } | |
1394 // Decide if a property should be in the object boilerplate. | 1406 // Decide if a property should be in the object boilerplate. |
1395 static bool IsBoilerplateProperty(Property* property); | 1407 static bool IsBoilerplateProperty(Property* property); |
1396 | 1408 |
1397 // Populate the depth field and flags. | 1409 // Populate the depth field and flags. |
1398 void InitDepthAndFlags(); | 1410 void InitDepthAndFlags(); |
1399 | 1411 |
1400 // Get the constant properties fixed array, populating it if necessary. | 1412 // Get the constant properties fixed array, populating it if necessary. |
1401 Handle<BoilerplateDescription> GetOrBuildConstantProperties( | 1413 Handle<BoilerplateDescription> GetOrBuildConstantProperties( |
1402 Isolate* isolate) { | 1414 Isolate* isolate) { |
1403 if (constant_properties_.is_null()) { | 1415 if (constant_properties_.is_null()) { |
1404 BuildConstantProperties(isolate); | 1416 BuildConstantProperties(isolate); |
1405 } | 1417 } |
1406 return constant_properties(); | 1418 return constant_properties(); |
1407 } | 1419 } |
1408 | 1420 |
1409 // Populate the constant properties fixed array. | 1421 // Populate the constant properties fixed array. |
1410 void BuildConstantProperties(Isolate* isolate); | 1422 void BuildConstantProperties(Isolate* isolate); |
1411 | 1423 |
1412 // Mark all computed expressions that are bound to a key that | 1424 // Mark all computed expressions that are bound to a key that |
1413 // is shadowed by a later occurrence of the same key. For the | 1425 // is shadowed by a later occurrence of the same key. For the |
1414 // marked expressions, no store code is emitted. | 1426 // marked expressions, no store code is emitted. |
1415 void CalculateEmitStore(Zone* zone); | 1427 void CalculateEmitStore(Zone* zone); |
1416 | 1428 |
1417 // Determines whether the {FastCloneShallowObject} builtin can be used. | 1429 // Determines whether the {FastCloneShallowObject} builtin can be used. |
1418 bool IsFastCloningSupported() const; | 1430 bool IsFastCloningSupported() const; |
1419 | 1431 |
1420 // Assemble bitfield of flags for the CreateObjectLiteral helper. | 1432 // Assemble bitfield of flags for the CreateObjectLiteral helper. |
1421 int ComputeFlags(bool disable_mementos = false) const { | 1433 int ComputeFlags(bool disable_mementos = false) const { |
1422 int flags = fast_elements() ? kFastElements : kNoFlags; | 1434 int flags = fast_elements() ? kFastElements : kNoFlags; |
1423 if (has_shallow_properties()) { | 1435 if (HasNullPrototype()) flags |= kHasNullPrototype; |
1424 flags |= kShallowProperties; | 1436 if (has_shallow_properties()) flags |= kShallowProperties; |
1425 } | 1437 if (disable_mementos) flags |= kDisableMementos; |
1426 if (disable_mementos) { | |
1427 flags |= kDisableMementos; | |
1428 } | |
1429 return flags; | 1438 return flags; |
1430 } | 1439 } |
1431 | 1440 |
1432 enum Flags { | 1441 enum Flags { |
1433 kNoFlags = 0, | 1442 kNoFlags = 0, |
1434 kFastElements = 1, | 1443 kFastElements = 1, |
1435 kShallowProperties = 1 << 1, | 1444 kShallowProperties = 1 << 1, |
1436 kDisableMementos = 1 << 2, | 1445 kDisableMementos = 1 << 2, |
1437 kHasRestProperty = 1 << 3, | 1446 kHasRestProperty = 1 << 3, |
1447 kHasNullPrototype = 1 << 4, | |
1438 }; | 1448 }; |
1439 | 1449 |
1440 struct Accessors: public ZoneObject { | 1450 struct Accessors: public ZoneObject { |
1441 Accessors() : getter(NULL), setter(NULL), bailout_id(BailoutId::None()) {} | 1451 Accessors() : getter(NULL), setter(NULL), bailout_id(BailoutId::None()) {} |
1442 ObjectLiteralProperty* getter; | 1452 ObjectLiteralProperty* getter; |
1443 ObjectLiteralProperty* setter; | 1453 ObjectLiteralProperty* setter; |
1444 BailoutId bailout_id; | 1454 BailoutId bailout_id; |
1445 }; | 1455 }; |
1446 | 1456 |
1447 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } | 1457 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } |
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3637 : NULL; \ | 3647 : NULL; \ |
3638 } | 3648 } |
3639 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3649 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3640 #undef DECLARE_NODE_FUNCTIONS | 3650 #undef DECLARE_NODE_FUNCTIONS |
3641 | 3651 |
3642 | 3652 |
3643 } // namespace internal | 3653 } // namespace internal |
3644 } // namespace v8 | 3654 } // namespace v8 |
3645 | 3655 |
3646 #endif // V8_AST_AST_H_ | 3656 #endif // V8_AST_AST_H_ |
OLD | NEW |