OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // | 42 // |
43 // Most object types in the V8 JavaScript are described in this file. | 43 // Most object types in the V8 JavaScript are described in this file. |
44 // | 44 // |
45 // Inheritance hierarchy: | 45 // Inheritance hierarchy: |
46 // - MaybeObject (an object or a failure) | 46 // - MaybeObject (an object or a failure) |
47 // - Failure (immediate for marking failed operation) | 47 // - Failure (immediate for marking failed operation) |
48 // - Object | 48 // - Object |
49 // - Smi (immediate small integer) | 49 // - Smi (immediate small integer) |
50 // - HeapObject (superclass for everything allocated in the heap) | 50 // - HeapObject (superclass for everything allocated in the heap) |
51 // - JSObject | 51 // - JSReceiver (suitable for property access) |
52 // - JSArray | 52 // - JSObject |
53 // - JSRegExp | 53 // - JSArray |
54 // - JSFunction | 54 // - JSRegExp |
55 // - GlobalObject | 55 // - JSFunction |
56 // - JSGlobalObject | 56 // - GlobalObject |
57 // - JSBuiltinsObject | 57 // - JSGlobalObject |
58 // - JSGlobalProxy | 58 // - JSBuiltinsObject |
59 // - JSValue | 59 // - JSGlobalProxy |
60 // - JSMessageObject | 60 // - JSValue |
| 61 // - JSMessageObject |
| 62 // - JSProxy |
| 63 // - JSFunctionProxy |
61 // - ByteArray | 64 // - ByteArray |
62 // - ExternalArray | 65 // - ExternalArray |
63 // - ExternalPixelArray | 66 // - ExternalPixelArray |
64 // - ExternalByteArray | 67 // - ExternalByteArray |
65 // - ExternalUnsignedByteArray | 68 // - ExternalUnsignedByteArray |
66 // - ExternalShortArray | 69 // - ExternalShortArray |
67 // - ExternalUnsignedShortArray | 70 // - ExternalUnsignedShortArray |
68 // - ExternalIntArray | 71 // - ExternalIntArray |
69 // - ExternalUnsignedIntArray | 72 // - ExternalUnsignedIntArray |
70 // - ExternalFloatArray | 73 // - ExternalFloatArray |
(...skipping 13 matching lines...) Expand all Loading... |
84 // - SeqAsciiString | 87 // - SeqAsciiString |
85 // - SeqTwoByteString | 88 // - SeqTwoByteString |
86 // - ConsString | 89 // - ConsString |
87 // - ExternalString | 90 // - ExternalString |
88 // - ExternalAsciiString | 91 // - ExternalAsciiString |
89 // - ExternalTwoByteString | 92 // - ExternalTwoByteString |
90 // - HeapNumber | 93 // - HeapNumber |
91 // - Code | 94 // - Code |
92 // - Map | 95 // - Map |
93 // - Oddball | 96 // - Oddball |
94 // - JSProxy | |
95 // - Foreign | 97 // - Foreign |
96 // - SharedFunctionInfo | 98 // - SharedFunctionInfo |
97 // - Struct | 99 // - Struct |
98 // - AccessorInfo | 100 // - AccessorInfo |
99 // - AccessCheckInfo | 101 // - AccessCheckInfo |
100 // - InterceptorInfo | 102 // - InterceptorInfo |
101 // - CallHandlerInfo | 103 // - CallHandlerInfo |
102 // - TemplateInfo | 104 // - TemplateInfo |
103 // - FunctionTemplateInfo | 105 // - FunctionTemplateInfo |
104 // - ObjectTemplateInfo | 106 // - ObjectTemplateInfo |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 V(EXTERNAL_ASCII_STRING_TYPE) \ | 285 V(EXTERNAL_ASCII_STRING_TYPE) \ |
284 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 286 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
285 \ | 287 \ |
286 V(MAP_TYPE) \ | 288 V(MAP_TYPE) \ |
287 V(CODE_TYPE) \ | 289 V(CODE_TYPE) \ |
288 V(ODDBALL_TYPE) \ | 290 V(ODDBALL_TYPE) \ |
289 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 291 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
290 \ | 292 \ |
291 V(HEAP_NUMBER_TYPE) \ | 293 V(HEAP_NUMBER_TYPE) \ |
292 V(JS_PROXY_TYPE) \ | 294 V(JS_PROXY_TYPE) \ |
| 295 V(JS_FUNCTION_PROXY_TYPE) \ |
293 V(FOREIGN_TYPE) \ | 296 V(FOREIGN_TYPE) \ |
294 V(BYTE_ARRAY_TYPE) \ | 297 V(BYTE_ARRAY_TYPE) \ |
295 /* Note: the order of these external array */ \ | 298 /* Note: the order of these external array */ \ |
296 /* types is relied upon in */ \ | 299 /* types is relied upon in */ \ |
297 /* Object::IsExternalArray(). */ \ | 300 /* Object::IsExternalArray(). */ \ |
298 V(EXTERNAL_BYTE_ARRAY_TYPE) \ | 301 V(EXTERNAL_BYTE_ARRAY_TYPE) \ |
299 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ | 302 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ |
300 V(EXTERNAL_SHORT_ARRAY_TYPE) \ | 303 V(EXTERNAL_SHORT_ARRAY_TYPE) \ |
301 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ | 304 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ |
302 V(EXTERNAL_INT_ARRAY_TYPE) \ | 305 V(EXTERNAL_INT_ARRAY_TYPE) \ |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // Objects allocated in their own spaces (never in new space). | 514 // Objects allocated in their own spaces (never in new space). |
512 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 515 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
513 CODE_TYPE, | 516 CODE_TYPE, |
514 ODDBALL_TYPE, | 517 ODDBALL_TYPE, |
515 JS_GLOBAL_PROPERTY_CELL_TYPE, | 518 JS_GLOBAL_PROPERTY_CELL_TYPE, |
516 | 519 |
517 // "Data", objects that cannot contain non-map-word pointers to heap | 520 // "Data", objects that cannot contain non-map-word pointers to heap |
518 // objects. | 521 // objects. |
519 HEAP_NUMBER_TYPE, | 522 HEAP_NUMBER_TYPE, |
520 FOREIGN_TYPE, | 523 FOREIGN_TYPE, |
521 JS_PROXY_TYPE, | |
522 BYTE_ARRAY_TYPE, | 524 BYTE_ARRAY_TYPE, |
523 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 525 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
524 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | 526 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
525 EXTERNAL_SHORT_ARRAY_TYPE, | 527 EXTERNAL_SHORT_ARRAY_TYPE, |
526 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | 528 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
527 EXTERNAL_INT_ARRAY_TYPE, | 529 EXTERNAL_INT_ARRAY_TYPE, |
528 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | 530 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
529 EXTERNAL_FLOAT_ARRAY_TYPE, | 531 EXTERNAL_FLOAT_ARRAY_TYPE, |
530 EXTERNAL_DOUBLE_ARRAY_TYPE, | 532 EXTERNAL_DOUBLE_ARRAY_TYPE, |
531 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 533 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
(...skipping 15 matching lines...) Expand all Loading... |
547 // constants always having them avoids them getting different numbers | 549 // constants always having them avoids them getting different numbers |
548 // depending on whether ENABLE_DEBUGGER_SUPPORT is defined or not. | 550 // depending on whether ENABLE_DEBUGGER_SUPPORT is defined or not. |
549 DEBUG_INFO_TYPE, | 551 DEBUG_INFO_TYPE, |
550 BREAK_POINT_INFO_TYPE, | 552 BREAK_POINT_INFO_TYPE, |
551 | 553 |
552 FIXED_ARRAY_TYPE, | 554 FIXED_ARRAY_TYPE, |
553 SHARED_FUNCTION_INFO_TYPE, | 555 SHARED_FUNCTION_INFO_TYPE, |
554 | 556 |
555 JS_MESSAGE_OBJECT_TYPE, | 557 JS_MESSAGE_OBJECT_TYPE, |
556 | 558 |
557 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE | 559 JS_VALUE_TYPE, // FIRST_OBJECT_CLASS_TYPE, FIRST_JS_RECEIVER_TYPE |
558 JS_OBJECT_TYPE, | 560 JS_OBJECT_TYPE, |
559 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 561 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
560 JS_GLOBAL_OBJECT_TYPE, | 562 JS_GLOBAL_OBJECT_TYPE, |
561 JS_BUILTINS_OBJECT_TYPE, | 563 JS_BUILTINS_OBJECT_TYPE, |
562 JS_GLOBAL_PROXY_TYPE, | 564 JS_GLOBAL_PROXY_TYPE, |
563 JS_ARRAY_TYPE, | 565 JS_ARRAY_TYPE, |
| 566 JS_PROXY_TYPE, |
564 | 567 |
565 JS_REGEXP_TYPE, // LAST_JS_OBJECT_TYPE, FIRST_FUNCTION_CLASS_TYPE | 568 JS_REGEXP_TYPE, // LAST_OBJECT_CLASS_TYPE |
566 | 569 |
567 JS_FUNCTION_TYPE, | 570 JS_FUNCTION_TYPE, // FIRST_FUNCTION_CLASS_TYPE |
| 571 JS_FUNCTION_PROXY_TYPE, // LAST_FUNCTION_CLASS_TYPE |
568 | 572 |
569 // Pseudo-types | 573 // Pseudo-types |
570 FIRST_TYPE = 0x0, | 574 FIRST_TYPE = 0x0, |
571 LAST_TYPE = JS_FUNCTION_TYPE, | 575 LAST_TYPE = JS_FUNCTION_PROXY_TYPE, |
572 INVALID_TYPE = FIRST_TYPE - 1, | 576 INVALID_TYPE = FIRST_TYPE - 1, |
573 FIRST_NONSTRING_TYPE = MAP_TYPE, | 577 FIRST_NONSTRING_TYPE = MAP_TYPE, |
574 // Boundaries for testing for an external array. | 578 // Boundaries for testing for an external array. |
575 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, | 579 FIRST_EXTERNAL_ARRAY_TYPE = EXTERNAL_BYTE_ARRAY_TYPE, |
576 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, | 580 LAST_EXTERNAL_ARRAY_TYPE = EXTERNAL_PIXEL_ARRAY_TYPE, |
577 // Boundary for promotion to old data space/old pointer space. | 581 // Boundary for promotion to old data space/old pointer space. |
578 LAST_DATA_TYPE = FILLER_TYPE, | 582 LAST_DATA_TYPE = FILLER_TYPE, |
| 583 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). |
| 584 // Note that there is no range for JSObject or JSProxy, since their subtypes |
| 585 // are not continuous in this enum! The enum ranges instead reflect the |
| 586 // external class names, where proxies are treated as either ordinary objects, |
| 587 // or functions. |
| 588 FIRST_JS_RECEIVER_TYPE = JS_VALUE_TYPE, |
| 589 |
579 // Boundaries for testing the type is a JavaScript "object". Note that | 590 // Boundaries for testing the type is a JavaScript "object". Note that |
580 // function objects are not counted as objects, even though they are | 591 // function objects are not counted as objects, even though they are |
581 // implemented as such; only values whose typeof is "object" are included. | 592 // implemented as such; only values whose typeof is "object" are included. |
582 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, | 593 FIRST_OBJECT_CLASS_TYPE = JS_VALUE_TYPE, |
583 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE, | 594 LAST_OBJECT_CLASS_TYPE = JS_REGEXP_TYPE, |
584 // RegExp objects have [[Class]] "function" because they are callable. | 595 // RegExp objects have [[Class]] "function" because they are callable. |
585 // All types from this type and above are objects with [[Class]] "function". | 596 // All types from this type and above are objects with [[Class]] "function". |
586 FIRST_FUNCTION_CLASS_TYPE = JS_REGEXP_TYPE | 597 FIRST_FUNCTION_CLASS_TYPE = JS_FUNCTION_TYPE, |
| 598 LAST_FUNCTION_CLASS_TYPE = JS_FUNCTION_PROXY_TYPE, |
| 599 // Objects that are either "object" or "function". |
| 600 FIRST_OBJECT_OR_FUNCTION_CLASS_TYPE = FIRST_OBJECT_CLASS_TYPE, |
| 601 LAST_OBJECT_OR_FUNCTION_CLASS_TYPE = LAST_FUNCTION_CLASS_TYPE |
587 }; | 602 }; |
588 | 603 |
589 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE - | 604 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE - |
590 FIRST_EXTERNAL_ARRAY_TYPE + 1; | 605 FIRST_EXTERNAL_ARRAY_TYPE + 1; |
591 | 606 |
592 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType); | 607 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType); |
593 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); | 608 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); |
594 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType); | 609 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType); |
595 | 610 |
596 | 611 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 V(ExternalByteArray) \ | 717 V(ExternalByteArray) \ |
703 V(ExternalUnsignedByteArray) \ | 718 V(ExternalUnsignedByteArray) \ |
704 V(ExternalShortArray) \ | 719 V(ExternalShortArray) \ |
705 V(ExternalUnsignedShortArray) \ | 720 V(ExternalUnsignedShortArray) \ |
706 V(ExternalIntArray) \ | 721 V(ExternalIntArray) \ |
707 V(ExternalUnsignedIntArray) \ | 722 V(ExternalUnsignedIntArray) \ |
708 V(ExternalFloatArray) \ | 723 V(ExternalFloatArray) \ |
709 V(ExternalDoubleArray) \ | 724 V(ExternalDoubleArray) \ |
710 V(ExternalPixelArray) \ | 725 V(ExternalPixelArray) \ |
711 V(ByteArray) \ | 726 V(ByteArray) \ |
| 727 V(JSReceiver) \ |
712 V(JSObject) \ | 728 V(JSObject) \ |
713 V(JSContextExtensionObject) \ | 729 V(JSContextExtensionObject) \ |
714 V(Map) \ | 730 V(Map) \ |
715 V(DescriptorArray) \ | 731 V(DescriptorArray) \ |
716 V(DeoptimizationInputData) \ | 732 V(DeoptimizationInputData) \ |
717 V(DeoptimizationOutputData) \ | 733 V(DeoptimizationOutputData) \ |
718 V(FixedArray) \ | 734 V(FixedArray) \ |
719 V(Context) \ | 735 V(Context) \ |
720 V(CatchContext) \ | 736 V(CatchContext) \ |
721 V(GlobalContext) \ | 737 V(GlobalContext) \ |
722 V(JSFunction) \ | 738 V(JSFunction) \ |
723 V(Code) \ | 739 V(Code) \ |
724 V(Oddball) \ | 740 V(Oddball) \ |
725 V(SharedFunctionInfo) \ | 741 V(SharedFunctionInfo) \ |
726 V(JSValue) \ | 742 V(JSValue) \ |
727 V(JSMessageObject) \ | 743 V(JSMessageObject) \ |
728 V(StringWrapper) \ | 744 V(StringWrapper) \ |
729 V(Foreign) \ | 745 V(Foreign) \ |
730 V(Boolean) \ | 746 V(Boolean) \ |
731 V(JSArray) \ | 747 V(JSArray) \ |
732 V(JSProxy) \ | 748 V(JSProxy) \ |
| 749 V(JSFunctionProxy) \ |
733 V(JSRegExp) \ | 750 V(JSRegExp) \ |
734 V(HashTable) \ | 751 V(HashTable) \ |
735 V(Dictionary) \ | 752 V(Dictionary) \ |
736 V(SymbolTable) \ | 753 V(SymbolTable) \ |
737 V(JSFunctionResultCache) \ | 754 V(JSFunctionResultCache) \ |
738 V(NormalizedMapCache) \ | 755 V(NormalizedMapCache) \ |
739 V(CompilationCacheTable) \ | 756 V(CompilationCacheTable) \ |
740 V(CodeCacheHashTable) \ | 757 V(CodeCacheHashTable) \ |
741 V(MapCache) \ | 758 V(MapCache) \ |
742 V(Primitive) \ | 759 V(Primitive) \ |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 static const int kExponentBias = 1023; | 1342 static const int kExponentBias = 1023; |
1326 static const int kExponentShift = 20; | 1343 static const int kExponentShift = 20; |
1327 static const int kMantissaBitsInTopWord = 20; | 1344 static const int kMantissaBitsInTopWord = 20; |
1328 static const int kNonMantissaBitsInTopWord = 12; | 1345 static const int kNonMantissaBitsInTopWord = 12; |
1329 | 1346 |
1330 private: | 1347 private: |
1331 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); | 1348 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); |
1332 }; | 1349 }; |
1333 | 1350 |
1334 | 1351 |
| 1352 // JSReceiver includes types on which properties can be defined, i.e., |
| 1353 // JSObject and JSProxy. |
| 1354 class JSReceiver: public HeapObject { |
| 1355 public: |
| 1356 // Casting. |
| 1357 static inline JSReceiver* cast(Object* obj); |
| 1358 |
| 1359 // Can cause GC. |
| 1360 MUST_USE_RESULT MaybeObject* SetProperty(String* key, |
| 1361 Object* value, |
| 1362 PropertyAttributes attributes, |
| 1363 StrictModeFlag strict_mode); |
| 1364 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, |
| 1365 String* key, |
| 1366 Object* value, |
| 1367 PropertyAttributes attributes, |
| 1368 StrictModeFlag strict_mode); |
| 1369 |
| 1370 // Returns the class name ([[Class]] property in the specification). |
| 1371 String* class_name(); |
| 1372 |
| 1373 // Returns the constructor name (the name (possibly, inferred name) of the |
| 1374 // function that was used to instantiate the object). |
| 1375 String* constructor_name(); |
| 1376 |
| 1377 inline PropertyAttributes GetPropertyAttribute(String* name); |
| 1378 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, |
| 1379 String* name); |
| 1380 PropertyAttributes GetLocalPropertyAttribute(String* name); |
| 1381 |
| 1382 // Can cause a GC. |
| 1383 bool HasProperty(String* name) { |
| 1384 return GetPropertyAttribute(name) != ABSENT; |
| 1385 } |
| 1386 |
| 1387 // Can cause a GC. |
| 1388 bool HasLocalProperty(String* name) { |
| 1389 return GetLocalPropertyAttribute(name) != ABSENT; |
| 1390 } |
| 1391 |
| 1392 // Return the object's prototype (might be Heap::null_value()). |
| 1393 inline Object* GetPrototype(); |
| 1394 |
| 1395 // Set the object's prototype (only JSReceiver and null are allowed). |
| 1396 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, |
| 1397 bool skip_hidden_prototypes); |
| 1398 |
| 1399 // Lookup a property. If found, the result is valid and has |
| 1400 // detailed information. |
| 1401 void LocalLookup(String* name, LookupResult* result); |
| 1402 void Lookup(String* name, LookupResult* result); |
| 1403 |
| 1404 private: |
| 1405 PropertyAttributes GetPropertyAttribute(JSReceiver* receiver, |
| 1406 LookupResult* result, |
| 1407 String* name, |
| 1408 bool continue_search); |
| 1409 |
| 1410 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
| 1411 }; |
| 1412 |
1335 // The JSObject describes real heap allocated JavaScript objects with | 1413 // The JSObject describes real heap allocated JavaScript objects with |
1336 // properties. | 1414 // properties. |
1337 // Note that the map of JSObject changes during execution to enable inline | 1415 // Note that the map of JSObject changes during execution to enable inline |
1338 // caching. | 1416 // caching. |
1339 class JSObject: public HeapObject { | 1417 class JSObject: public JSReceiver { |
1340 public: | 1418 public: |
1341 enum DeleteMode { | 1419 enum DeleteMode { |
1342 NORMAL_DELETION, | 1420 NORMAL_DELETION, |
1343 STRICT_DELETION, | 1421 STRICT_DELETION, |
1344 FORCE_DELETION | 1422 FORCE_DELETION |
1345 }; | 1423 }; |
1346 | 1424 |
1347 enum ElementsKind { | 1425 enum ElementsKind { |
1348 // The only "fast" kind. | 1426 // The only "fast" kind. |
1349 FAST_ELEMENTS, | 1427 FAST_ELEMENTS, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); | 1483 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); |
1406 | 1484 |
1407 // Collects elements starting at index 0. | 1485 // Collects elements starting at index 0. |
1408 // Undefined values are placed after non-undefined values. | 1486 // Undefined values are placed after non-undefined values. |
1409 // Returns the number of non-undefined values. | 1487 // Returns the number of non-undefined values. |
1410 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); | 1488 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); |
1411 // As PrepareElementsForSort, but only on objects where elements is | 1489 // As PrepareElementsForSort, but only on objects where elements is |
1412 // a dictionary, and it will stay a dictionary. | 1490 // a dictionary, and it will stay a dictionary. |
1413 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); | 1491 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); |
1414 | 1492 |
1415 MUST_USE_RESULT MaybeObject* SetProperty(String* key, | 1493 MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result, |
1416 Object* value, | |
1417 PropertyAttributes attributes, | |
1418 StrictModeFlag strict_mode); | |
1419 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, | |
1420 String* key, | 1494 String* key, |
1421 Object* value, | 1495 Object* value, |
1422 PropertyAttributes attributes, | 1496 PropertyAttributes attributes, |
1423 StrictModeFlag strict_mode); | 1497 StrictModeFlag strict_mode); |
1424 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( | 1498 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( |
1425 LookupResult* result, | 1499 LookupResult* result, |
1426 String* name, | 1500 String* name, |
1427 Object* value, | 1501 Object* value, |
1428 bool check_prototype); | 1502 bool check_prototype); |
1429 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure, | 1503 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure, |
(...skipping 28 matching lines...) Expand all Loading... |
1458 // Sets the property value in a normalized object given (key, value, details). | 1532 // Sets the property value in a normalized object given (key, value, details). |
1459 // Handles the special representation of JS global objects. | 1533 // Handles the special representation of JS global objects. |
1460 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, | 1534 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, |
1461 Object* value, | 1535 Object* value, |
1462 PropertyDetails details); | 1536 PropertyDetails details); |
1463 | 1537 |
1464 // Deletes the named property in a normalized object. | 1538 // Deletes the named property in a normalized object. |
1465 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, | 1539 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, |
1466 DeleteMode mode); | 1540 DeleteMode mode); |
1467 | 1541 |
1468 // Returns the class name ([[Class]] property in the specification). | |
1469 String* class_name(); | |
1470 | |
1471 // Returns the constructor name (the name (possibly, inferred name) of the | |
1472 // function that was used to instantiate the object). | |
1473 String* constructor_name(); | |
1474 | |
1475 // Retrieve interceptors. | 1542 // Retrieve interceptors. |
1476 InterceptorInfo* GetNamedInterceptor(); | 1543 InterceptorInfo* GetNamedInterceptor(); |
1477 InterceptorInfo* GetIndexedInterceptor(); | 1544 InterceptorInfo* GetIndexedInterceptor(); |
1478 | 1545 |
1479 inline PropertyAttributes GetPropertyAttribute(String* name); | 1546 // Used from JSReceiver. |
1480 PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver, | 1547 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, |
1481 String* name); | 1548 String* name, |
1482 PropertyAttributes GetLocalPropertyAttribute(String* name); | 1549 bool continue_search); |
| 1550 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, |
| 1551 String* name, |
| 1552 bool continue_search); |
| 1553 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( |
| 1554 Object* receiver, |
| 1555 LookupResult* result, |
| 1556 String* name, |
| 1557 bool continue_search); |
1483 | 1558 |
1484 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, | 1559 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, |
1485 bool is_getter, | 1560 bool is_getter, |
1486 Object* fun, | 1561 Object* fun, |
1487 PropertyAttributes attributes); | 1562 PropertyAttributes attributes); |
1488 Object* LookupAccessor(String* name, bool is_getter); | 1563 Object* LookupAccessor(String* name, bool is_getter); |
1489 | 1564 |
1490 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1565 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
1491 | 1566 |
1492 // Used from Object::GetProperty(). | 1567 // Used from Object::GetProperty(). |
1493 MaybeObject* GetPropertyWithFailedAccessCheck( | 1568 MaybeObject* GetPropertyWithFailedAccessCheck( |
1494 Object* receiver, | 1569 Object* receiver, |
1495 LookupResult* result, | 1570 LookupResult* result, |
1496 String* name, | 1571 String* name, |
1497 PropertyAttributes* attributes); | 1572 PropertyAttributes* attributes); |
1498 MaybeObject* GetPropertyWithInterceptor( | 1573 MaybeObject* GetPropertyWithInterceptor( |
1499 JSObject* receiver, | 1574 JSReceiver* receiver, |
1500 String* name, | 1575 String* name, |
1501 PropertyAttributes* attributes); | 1576 PropertyAttributes* attributes); |
1502 MaybeObject* GetPropertyPostInterceptor( | 1577 MaybeObject* GetPropertyPostInterceptor( |
1503 JSObject* receiver, | 1578 JSReceiver* receiver, |
1504 String* name, | 1579 String* name, |
1505 PropertyAttributes* attributes); | 1580 PropertyAttributes* attributes); |
1506 MaybeObject* GetLocalPropertyPostInterceptor(JSObject* receiver, | 1581 MaybeObject* GetLocalPropertyPostInterceptor(JSReceiver* receiver, |
1507 String* name, | 1582 String* name, |
1508 PropertyAttributes* attributes); | 1583 PropertyAttributes* attributes); |
1509 | 1584 |
1510 // Returns true if this is an instance of an api function and has | 1585 // Returns true if this is an instance of an api function and has |
1511 // been modified since it was created. May give false positives. | 1586 // been modified since it was created. May give false positives. |
1512 bool IsDirty(); | 1587 bool IsDirty(); |
1513 | 1588 |
1514 bool HasProperty(String* name) { | |
1515 return GetPropertyAttribute(name) != ABSENT; | |
1516 } | |
1517 | |
1518 // Can cause a GC if it hits an interceptor. | |
1519 bool HasLocalProperty(String* name) { | |
1520 return GetLocalPropertyAttribute(name) != ABSENT; | |
1521 } | |
1522 | |
1523 // If the receiver is a JSGlobalProxy this method will return its prototype, | 1589 // If the receiver is a JSGlobalProxy this method will return its prototype, |
1524 // otherwise the result is the receiver itself. | 1590 // otherwise the result is the receiver itself. |
1525 inline Object* BypassGlobalProxy(); | 1591 inline Object* BypassGlobalProxy(); |
1526 | 1592 |
1527 // Accessors for hidden properties object. | 1593 // Accessors for hidden properties object. |
1528 // | 1594 // |
1529 // Hidden properties are not local properties of the object itself. | 1595 // Hidden properties are not local properties of the object itself. |
1530 // Instead they are stored on an auxiliary JSObject stored as a local | 1596 // Instead they are stored on an auxiliary JSObject stored as a local |
1531 // property with a special name Heap::hidden_symbol(). But if the | 1597 // property with a special name Heap::hidden_symbol(). But if the |
1532 // receiver is a JSGlobalProxy then the auxiliary object is a property | 1598 // receiver is a JSGlobalProxy then the auxiliary object is a property |
(...skipping 17 matching lines...) Expand all Loading... |
1550 | 1616 |
1551 // Do we want to keep the elements in fast case when increasing the | 1617 // Do we want to keep the elements in fast case when increasing the |
1552 // capacity? | 1618 // capacity? |
1553 bool ShouldConvertToSlowElements(int new_capacity); | 1619 bool ShouldConvertToSlowElements(int new_capacity); |
1554 // Returns true if the backing storage for the slow-case elements of | 1620 // Returns true if the backing storage for the slow-case elements of |
1555 // this object takes up nearly as much space as a fast-case backing | 1621 // this object takes up nearly as much space as a fast-case backing |
1556 // storage would. In that case the JSObject should have fast | 1622 // storage would. In that case the JSObject should have fast |
1557 // elements. | 1623 // elements. |
1558 bool ShouldConvertToFastElements(); | 1624 bool ShouldConvertToFastElements(); |
1559 | 1625 |
1560 // Return the object's prototype (might be Heap::null_value()). | |
1561 inline Object* GetPrototype(); | |
1562 | |
1563 // Set the object's prototype (only JSObject and null are allowed). | |
1564 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, | |
1565 bool skip_hidden_prototypes); | |
1566 | |
1567 // Tells whether the index'th element is present. | 1626 // Tells whether the index'th element is present. |
1568 inline bool HasElement(uint32_t index); | 1627 inline bool HasElement(uint32_t index); |
1569 bool HasElementWithReceiver(JSObject* receiver, uint32_t index); | 1628 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index); |
1570 | 1629 |
1571 // Computes the new capacity when expanding the elements of a JSObject. | 1630 // Computes the new capacity when expanding the elements of a JSObject. |
1572 static int NewElementsCapacity(int old_capacity) { | 1631 static int NewElementsCapacity(int old_capacity) { |
1573 // (old_capacity + 50%) + 16 | 1632 // (old_capacity + 50%) + 16 |
1574 return old_capacity + (old_capacity >> 1) + 16; | 1633 return old_capacity + (old_capacity >> 1) + 16; |
1575 } | 1634 } |
1576 | 1635 |
1577 // Tells whether the index'th element is present and how it is stored. | 1636 // Tells whether the index'th element is present and how it is stored. |
1578 enum LocalElementType { | 1637 enum LocalElementType { |
1579 // There is no element with given index. | 1638 // There is no element with given index. |
1580 UNDEFINED_ELEMENT, | 1639 UNDEFINED_ELEMENT, |
1581 | 1640 |
1582 // Element with given index is handled by interceptor. | 1641 // Element with given index is handled by interceptor. |
1583 INTERCEPTED_ELEMENT, | 1642 INTERCEPTED_ELEMENT, |
1584 | 1643 |
1585 // Element with given index is character in string. | 1644 // Element with given index is character in string. |
1586 STRING_CHARACTER_ELEMENT, | 1645 STRING_CHARACTER_ELEMENT, |
1587 | 1646 |
1588 // Element with given index is stored in fast backing store. | 1647 // Element with given index is stored in fast backing store. |
1589 FAST_ELEMENT, | 1648 FAST_ELEMENT, |
1590 | 1649 |
1591 // Element with given index is stored in slow backing store. | 1650 // Element with given index is stored in slow backing store. |
1592 DICTIONARY_ELEMENT | 1651 DICTIONARY_ELEMENT |
1593 }; | 1652 }; |
1594 | 1653 |
1595 LocalElementType HasLocalElement(uint32_t index); | 1654 LocalElementType HasLocalElement(uint32_t index); |
1596 | 1655 |
1597 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); | 1656 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index); |
1598 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); | 1657 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index); |
1599 | 1658 |
1600 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 1659 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
1601 Object* value, | 1660 Object* value, |
1602 StrictModeFlag strict_mode, | 1661 StrictModeFlag strict_mode, |
1603 bool check_prototype = true); | 1662 bool check_prototype = true); |
1604 | 1663 |
1605 // Set the index'th array element. | 1664 // Set the index'th array element. |
1606 // A Failure object is returned if GC is needed. | 1665 // A Failure object is returned if GC is needed. |
1607 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, | 1666 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
1608 Object* value, | 1667 Object* value, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 inline int GetHeaderSize(); | 1700 inline int GetHeaderSize(); |
1642 | 1701 |
1643 inline int GetInternalFieldCount(); | 1702 inline int GetInternalFieldCount(); |
1644 inline int GetInternalFieldOffset(int index); | 1703 inline int GetInternalFieldOffset(int index); |
1645 inline Object* GetInternalField(int index); | 1704 inline Object* GetInternalField(int index); |
1646 inline void SetInternalField(int index, Object* value); | 1705 inline void SetInternalField(int index, Object* value); |
1647 | 1706 |
1648 // Lookup a property. If found, the result is valid and has | 1707 // Lookup a property. If found, the result is valid and has |
1649 // detailed information. | 1708 // detailed information. |
1650 void LocalLookup(String* name, LookupResult* result); | 1709 void LocalLookup(String* name, LookupResult* result); |
1651 void Lookup(String* name, LookupResult* result); | 1710 // void Lookup(String* name, LookupResult* result); |
1652 | 1711 |
1653 // The following lookup functions skip interceptors. | 1712 // The following lookup functions skip interceptors. |
1654 void LocalLookupRealNamedProperty(String* name, LookupResult* result); | 1713 void LocalLookupRealNamedProperty(String* name, LookupResult* result); |
1655 void LookupRealNamedProperty(String* name, LookupResult* result); | 1714 void LookupRealNamedProperty(String* name, LookupResult* result); |
1656 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); | 1715 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); |
1657 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); | 1716 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); |
1658 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( | 1717 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( |
1659 uint32_t index, Object* value, bool* found); | 1718 uint32_t index, Object* value, bool* found); |
1660 void LookupCallback(String* name, LookupResult* result); | 1719 void LookupCallback(String* name, LookupResult* result); |
1661 | 1720 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index); | 1942 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index); |
1884 | 1943 |
1885 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, | 1944 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, |
1886 DeleteMode mode); | 1945 DeleteMode mode); |
1887 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); | 1946 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); |
1888 | 1947 |
1889 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, | 1948 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, |
1890 DeleteMode mode); | 1949 DeleteMode mode); |
1891 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); | 1950 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); |
1892 | 1951 |
1893 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, | |
1894 String* name, | |
1895 bool continue_search); | |
1896 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, | |
1897 String* name, | |
1898 bool continue_search); | |
1899 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( | |
1900 Object* receiver, | |
1901 LookupResult* result, | |
1902 String* name, | |
1903 bool continue_search); | |
1904 PropertyAttributes GetPropertyAttribute(JSObject* receiver, | |
1905 LookupResult* result, | |
1906 String* name, | |
1907 bool continue_search); | |
1908 | |
1909 // Returns true if most of the elements backing storage is used. | 1952 // Returns true if most of the elements backing storage is used. |
1910 bool HasDenseElements(); | 1953 bool HasDenseElements(); |
1911 | 1954 |
1912 bool CanSetCallback(String* name); | 1955 bool CanSetCallback(String* name); |
1913 MUST_USE_RESULT MaybeObject* SetElementCallback( | 1956 MUST_USE_RESULT MaybeObject* SetElementCallback( |
1914 uint32_t index, | 1957 uint32_t index, |
1915 Object* structure, | 1958 Object* structure, |
1916 PropertyAttributes attributes); | 1959 PropertyAttributes attributes); |
1917 MUST_USE_RESULT MaybeObject* SetPropertyCallback( | 1960 MUST_USE_RESULT MaybeObject* SetPropertyCallback( |
1918 String* name, | 1961 String* name, |
(...skipping 4188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6107 // Returns the isolate/heap this cell object belongs to. | 6150 // Returns the isolate/heap this cell object belongs to. |
6108 inline Isolate* isolate(); | 6151 inline Isolate* isolate(); |
6109 inline Heap* heap(); | 6152 inline Heap* heap(); |
6110 | 6153 |
6111 private: | 6154 private: |
6112 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); | 6155 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); |
6113 }; | 6156 }; |
6114 | 6157 |
6115 | 6158 |
6116 // The JSProxy describes EcmaScript Harmony proxies | 6159 // The JSProxy describes EcmaScript Harmony proxies |
6117 class JSProxy: public HeapObject { | 6160 class JSProxy: public JSReceiver { |
6118 public: | 6161 public: |
6119 // [handler]: The handler property. | 6162 // [handler]: The handler property. |
6120 DECL_ACCESSORS(handler, Object) | 6163 DECL_ACCESSORS(handler, Object) |
6121 | 6164 |
6122 // Casting. | 6165 // Casting. |
6123 static inline JSProxy* cast(Object* obj); | 6166 static inline JSProxy* cast(Object* obj); |
6124 | 6167 |
| 6168 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( |
| 6169 String* name_raw, |
| 6170 Object* value_raw, |
| 6171 PropertyAttributes attributes, |
| 6172 StrictModeFlag strict_mode); |
| 6173 |
| 6174 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler( |
| 6175 JSReceiver* receiver, |
| 6176 String* name_raw, |
| 6177 bool* has_exception); |
| 6178 |
6125 // Dispatched behavior. | 6179 // Dispatched behavior. |
6126 #ifdef OBJECT_PRINT | 6180 #ifdef OBJECT_PRINT |
6127 inline void JSProxyPrint() { | 6181 inline void JSProxyPrint() { |
6128 JSProxyPrint(stdout); | 6182 JSProxyPrint(stdout); |
6129 } | 6183 } |
6130 void JSProxyPrint(FILE* out); | 6184 void JSProxyPrint(FILE* out); |
6131 #endif | 6185 #endif |
6132 #ifdef DEBUG | 6186 #ifdef DEBUG |
6133 void JSProxyVerify(); | 6187 void JSProxyVerify(); |
6134 #endif | 6188 #endif |
6135 | 6189 |
6136 // Layout description. | 6190 // Layout description. |
6137 static const int kHandlerOffset = HeapObject::kHeaderSize; | 6191 static const int kHandlerOffset = HeapObject::kHeaderSize; |
6138 static const int kSize = kHandlerOffset + kPointerSize; | 6192 static const int kSize = kHandlerOffset + kPointerSize; |
6139 | 6193 |
6140 typedef FixedBodyDescriptor<kHandlerOffset, | 6194 typedef FixedBodyDescriptor<kHandlerOffset, |
6141 kHandlerOffset + kPointerSize, | 6195 kHandlerOffset + kPointerSize, |
6142 kSize> BodyDescriptor; | 6196 kSize> BodyDescriptor; |
6143 | 6197 |
6144 private: | 6198 private: |
6145 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 6199 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
6146 }; | 6200 }; |
6147 | 6201 |
6148 | 6202 |
| 6203 // TODO(rossberg): Only a stub for now. |
| 6204 class JSFunctionProxy: public JSProxy { |
| 6205 public: |
| 6206 // Casting. |
| 6207 static inline JSFunctionProxy* cast(Object* obj); |
| 6208 |
| 6209 private: |
| 6210 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); |
| 6211 }; |
| 6212 |
6149 | 6213 |
6150 // Foreign describes objects pointing from JavaScript to C structures. | 6214 // Foreign describes objects pointing from JavaScript to C structures. |
6151 // Since they cannot contain references to JS HeapObjects they can be | 6215 // Since they cannot contain references to JS HeapObjects they can be |
6152 // placed in old_data_space. | 6216 // placed in old_data_space. |
6153 class Foreign: public HeapObject { | 6217 class Foreign: public HeapObject { |
6154 public: | 6218 public: |
6155 // [address]: field containing the address. | 6219 // [address]: field containing the address. |
6156 inline Address address(); | 6220 inline Address address(); |
6157 inline void set_address(Address value); | 6221 inline void set_address(Address value); |
6158 | 6222 |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6781 } else { | 6845 } else { |
6782 value &= ~(1 << bit_position); | 6846 value &= ~(1 << bit_position); |
6783 } | 6847 } |
6784 return value; | 6848 return value; |
6785 } | 6849 } |
6786 }; | 6850 }; |
6787 | 6851 |
6788 } } // namespace v8::internal | 6852 } } // namespace v8::internal |
6789 | 6853 |
6790 #endif // V8_OBJECTS_H_ | 6854 #endif // V8_OBJECTS_H_ |
OLD | NEW |