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

Side by Side Diff: src/objects.h

Issue 6992072: Implement set trap for proxies, and revamp class hierarchy in preparation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('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 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
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
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ 284 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \
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) \
293 V(FOREIGN_TYPE) \ 294 V(FOREIGN_TYPE) \
294 V(BYTE_ARRAY_TYPE) \ 295 V(BYTE_ARRAY_TYPE) \
295 /* Note: the order of these external array */ \ 296 /* Note: the order of these external array */ \
296 /* types is relied upon in */ \ 297 /* types is relied upon in */ \
297 /* Object::IsExternalArray(). */ \ 298 /* Object::IsExternalArray(). */ \
298 V(EXTERNAL_BYTE_ARRAY_TYPE) \ 299 V(EXTERNAL_BYTE_ARRAY_TYPE) \
299 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ 300 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
300 V(EXTERNAL_SHORT_ARRAY_TYPE) \ 301 V(EXTERNAL_SHORT_ARRAY_TYPE) \
301 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ 302 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
302 V(EXTERNAL_INT_ARRAY_TYPE) \ 303 V(EXTERNAL_INT_ARRAY_TYPE) \
(...skipping 18 matching lines...) Expand all
321 \ 322 \
322 V(JS_MESSAGE_OBJECT_TYPE) \ 323 V(JS_MESSAGE_OBJECT_TYPE) \
323 \ 324 \
324 V(JS_VALUE_TYPE) \ 325 V(JS_VALUE_TYPE) \
325 V(JS_OBJECT_TYPE) \ 326 V(JS_OBJECT_TYPE) \
326 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ 327 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
327 V(JS_GLOBAL_OBJECT_TYPE) \ 328 V(JS_GLOBAL_OBJECT_TYPE) \
328 V(JS_BUILTINS_OBJECT_TYPE) \ 329 V(JS_BUILTINS_OBJECT_TYPE) \
329 V(JS_GLOBAL_PROXY_TYPE) \ 330 V(JS_GLOBAL_PROXY_TYPE) \
330 V(JS_ARRAY_TYPE) \ 331 V(JS_ARRAY_TYPE) \
332 V(JS_PROXY_TYPE) \
331 V(JS_REGEXP_TYPE) \ 333 V(JS_REGEXP_TYPE) \
332 \ 334 \
333 V(JS_FUNCTION_TYPE) \ 335 V(JS_FUNCTION_TYPE) \
336 V(JS_FUNCTION_PROXY_TYPE) \
334 337
335 #ifdef ENABLE_DEBUGGER_SUPPORT 338 #ifdef ENABLE_DEBUGGER_SUPPORT
336 #define INSTANCE_TYPE_LIST_DEBUGGER(V) \ 339 #define INSTANCE_TYPE_LIST_DEBUGGER(V) \
337 V(DEBUG_INFO_TYPE) \ 340 V(DEBUG_INFO_TYPE) \
338 V(BREAK_POINT_INFO_TYPE) 341 V(BREAK_POINT_INFO_TYPE)
339 #else 342 #else
340 #define INSTANCE_TYPE_LIST_DEBUGGER(V) 343 #define INSTANCE_TYPE_LIST_DEBUGGER(V)
341 #endif 344 #endif
342 345
343 #define INSTANCE_TYPE_LIST(V) \ 346 #define INSTANCE_TYPE_LIST(V) \
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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_NON_CALLABLE_OBJECT_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 568 JS_REGEXP_TYPE, // LAST_NONCALLABLE_SPEC_OBJECT_TYPE
566 569
567 JS_FUNCTION_TYPE, // FIRST_FUNCTION_CLASS_TYPE 570 JS_FUNCTION_TYPE, // FIRST_CALLABLE_SPEC_OBJECT_TYPE
571 JS_FUNCTION_PROXY_TYPE, // LAST_CALLABLE_SPEC_OBJECT_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,
579 // Boundaries for testing the type is a JavaScript "object". Note that 583 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy).
580 // function objects are not counted as objects, even though they are 584 // Note that there is no range for JSObject or JSProxy, since their subtypes
581 // implemented as such; only values whose typeof is "object" are included. 585 // are not continuous in this enum! The enum ranges instead reflect the
582 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE, 586 // external class names, where proxies are treated as either ordinary objects,
583 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE, 587 // or functions.
584 // RegExp objects have [[Class]] "function" because they are callable. 588 FIRST_JS_RECEIVER_TYPE = JS_VALUE_TYPE,
585 // All types from this type and above are objects with [[Class]] "function". 589 LAST_JS_RECEIVER_TYPE = LAST_TYPE,
586 FIRST_FUNCTION_CLASS_TYPE = JS_FUNCTION_TYPE 590 // Boundaries for testing the types for which typeof is "object".
591 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_VALUE_TYPE,
592 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE,
593 // Boundaries for testing the types for which typeof is "function".
594 FIRST_CALLABLE_SPEC_OBJECT_TYPE = JS_FUNCTION_TYPE,
595 LAST_CALLABLE_SPEC_OBJECT_TYPE = JS_FUNCTION_PROXY_TYPE,
596 // Boundaries for testing whether the type is a JavaScript object.
597 FIRST_SPEC_OBJECT_TYPE = FIRST_NONCALLABLE_SPEC_OBJECT_TYPE,
598 LAST_SPEC_OBJECT_TYPE = LAST_CALLABLE_SPEC_OBJECT_TYPE
587 }; 599 };
588 600
589 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE - 601 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE -
590 FIRST_EXTERNAL_ARRAY_TYPE + 1; 602 FIRST_EXTERNAL_ARRAY_TYPE + 1;
591 603
592 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType); 604 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType);
593 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); 605 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType);
594 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType); 606 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType);
595 607
596 608
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 V(ExternalByteArray) \ 714 V(ExternalByteArray) \
703 V(ExternalUnsignedByteArray) \ 715 V(ExternalUnsignedByteArray) \
704 V(ExternalShortArray) \ 716 V(ExternalShortArray) \
705 V(ExternalUnsignedShortArray) \ 717 V(ExternalUnsignedShortArray) \
706 V(ExternalIntArray) \ 718 V(ExternalIntArray) \
707 V(ExternalUnsignedIntArray) \ 719 V(ExternalUnsignedIntArray) \
708 V(ExternalFloatArray) \ 720 V(ExternalFloatArray) \
709 V(ExternalDoubleArray) \ 721 V(ExternalDoubleArray) \
710 V(ExternalPixelArray) \ 722 V(ExternalPixelArray) \
711 V(ByteArray) \ 723 V(ByteArray) \
724 V(JSReceiver) \
712 V(JSObject) \ 725 V(JSObject) \
713 V(JSContextExtensionObject) \ 726 V(JSContextExtensionObject) \
714 V(Map) \ 727 V(Map) \
715 V(DescriptorArray) \ 728 V(DescriptorArray) \
716 V(DeoptimizationInputData) \ 729 V(DeoptimizationInputData) \
717 V(DeoptimizationOutputData) \ 730 V(DeoptimizationOutputData) \
718 V(FixedArray) \ 731 V(FixedArray) \
719 V(Context) \ 732 V(Context) \
720 V(CatchContext) \ 733 V(CatchContext) \
721 V(GlobalContext) \ 734 V(GlobalContext) \
722 V(JSFunction) \ 735 V(JSFunction) \
723 V(Code) \ 736 V(Code) \
724 V(Oddball) \ 737 V(Oddball) \
725 V(SharedFunctionInfo) \ 738 V(SharedFunctionInfo) \
726 V(JSValue) \ 739 V(JSValue) \
727 V(JSMessageObject) \ 740 V(JSMessageObject) \
728 V(StringWrapper) \ 741 V(StringWrapper) \
729 V(Foreign) \ 742 V(Foreign) \
730 V(Boolean) \ 743 V(Boolean) \
731 V(JSArray) \ 744 V(JSArray) \
732 V(JSProxy) \ 745 V(JSProxy) \
746 V(JSFunctionProxy) \
733 V(JSRegExp) \ 747 V(JSRegExp) \
734 V(HashTable) \ 748 V(HashTable) \
735 V(Dictionary) \ 749 V(Dictionary) \
736 V(SymbolTable) \ 750 V(SymbolTable) \
737 V(JSFunctionResultCache) \ 751 V(JSFunctionResultCache) \
738 V(NormalizedMapCache) \ 752 V(NormalizedMapCache) \
739 V(CompilationCacheTable) \ 753 V(CompilationCacheTable) \
740 V(CodeCacheHashTable) \ 754 V(CodeCacheHashTable) \
741 V(MapCache) \ 755 V(MapCache) \
742 V(Primitive) \ 756 V(Primitive) \
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 static const int kExponentBias = 1023; 1339 static const int kExponentBias = 1023;
1326 static const int kExponentShift = 20; 1340 static const int kExponentShift = 20;
1327 static const int kMantissaBitsInTopWord = 20; 1341 static const int kMantissaBitsInTopWord = 20;
1328 static const int kNonMantissaBitsInTopWord = 12; 1342 static const int kNonMantissaBitsInTopWord = 12;
1329 1343
1330 private: 1344 private:
1331 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); 1345 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);
1332 }; 1346 };
1333 1347
1334 1348
1349 // JSReceiver includes types on which properties can be defined, i.e.,
1350 // JSObject and JSProxy.
1351 class JSReceiver: public HeapObject {
1352 public:
1353 // Casting.
1354 static inline JSReceiver* cast(Object* obj);
1355
1356 // Can cause GC.
1357 MUST_USE_RESULT MaybeObject* SetProperty(String* key,
1358 Object* value,
1359 PropertyAttributes attributes,
1360 StrictModeFlag strict_mode);
1361 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result,
1362 String* key,
1363 Object* value,
1364 PropertyAttributes attributes,
1365 StrictModeFlag strict_mode);
1366
1367 // Returns the class name ([[Class]] property in the specification).
1368 String* class_name();
1369
1370 // Returns the constructor name (the name (possibly, inferred name) of the
1371 // function that was used to instantiate the object).
1372 String* constructor_name();
1373
1374 inline PropertyAttributes GetPropertyAttribute(String* name);
1375 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver,
1376 String* name);
1377 PropertyAttributes GetLocalPropertyAttribute(String* name);
1378
1379 // Can cause a GC.
1380 bool HasProperty(String* name) {
1381 return GetPropertyAttribute(name) != ABSENT;
1382 }
1383
1384 // Can cause a GC.
1385 bool HasLocalProperty(String* name) {
1386 return GetLocalPropertyAttribute(name) != ABSENT;
1387 }
1388
1389 // Return the object's prototype (might be Heap::null_value()).
1390 inline Object* GetPrototype();
1391
1392 // Set the object's prototype (only JSReceiver and null are allowed).
1393 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value,
1394 bool skip_hidden_prototypes);
1395
1396 // Lookup a property. If found, the result is valid and has
1397 // detailed information.
1398 void LocalLookup(String* name, LookupResult* result);
1399 void Lookup(String* name, LookupResult* result);
1400
1401 private:
1402 PropertyAttributes GetPropertyAttribute(JSReceiver* receiver,
1403 LookupResult* result,
1404 String* name,
1405 bool continue_search);
1406
1407 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
1408 };
1409
1335 // The JSObject describes real heap allocated JavaScript objects with 1410 // The JSObject describes real heap allocated JavaScript objects with
1336 // properties. 1411 // properties.
1337 // Note that the map of JSObject changes during execution to enable inline 1412 // Note that the map of JSObject changes during execution to enable inline
1338 // caching. 1413 // caching.
1339 class JSObject: public HeapObject { 1414 class JSObject: public JSReceiver {
1340 public: 1415 public:
1341 enum DeleteMode { 1416 enum DeleteMode {
1342 NORMAL_DELETION, 1417 NORMAL_DELETION,
1343 STRICT_DELETION, 1418 STRICT_DELETION,
1344 FORCE_DELETION 1419 FORCE_DELETION
1345 }; 1420 };
1346 1421
1347 enum ElementsKind { 1422 enum ElementsKind {
1348 // The only "fast" kind. 1423 // The only "fast" kind.
1349 FAST_ELEMENTS, 1424 FAST_ELEMENTS,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); 1480 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
1406 1481
1407 // Collects elements starting at index 0. 1482 // Collects elements starting at index 0.
1408 // Undefined values are placed after non-undefined values. 1483 // Undefined values are placed after non-undefined values.
1409 // Returns the number of non-undefined values. 1484 // Returns the number of non-undefined values.
1410 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); 1485 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit);
1411 // As PrepareElementsForSort, but only on objects where elements is 1486 // As PrepareElementsForSort, but only on objects where elements is
1412 // a dictionary, and it will stay a dictionary. 1487 // a dictionary, and it will stay a dictionary.
1413 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); 1488 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit);
1414 1489
1415 MUST_USE_RESULT MaybeObject* SetProperty(String* key, 1490 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, 1491 String* key,
1421 Object* value, 1492 Object* value,
1422 PropertyAttributes attributes, 1493 PropertyAttributes attributes,
1423 StrictModeFlag strict_mode); 1494 StrictModeFlag strict_mode);
1424 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( 1495 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck(
1425 LookupResult* result, 1496 LookupResult* result,
1426 String* name, 1497 String* name,
1427 Object* value, 1498 Object* value,
1428 bool check_prototype, 1499 bool check_prototype,
1429 StrictModeFlag strict_mode); 1500 StrictModeFlag strict_mode);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 // 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).
1462 // Handles the special representation of JS global objects. 1533 // Handles the special representation of JS global objects.
1463 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, 1534 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name,
1464 Object* value, 1535 Object* value,
1465 PropertyDetails details); 1536 PropertyDetails details);
1466 1537
1467 // Deletes the named property in a normalized object. 1538 // Deletes the named property in a normalized object.
1468 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, 1539 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name,
1469 DeleteMode mode); 1540 DeleteMode mode);
1470 1541
1471 // Returns the class name ([[Class]] property in the specification).
1472 String* class_name();
1473
1474 // Returns the constructor name (the name (possibly, inferred name) of the
1475 // function that was used to instantiate the object).
1476 String* constructor_name();
1477
1478 // Retrieve interceptors. 1542 // Retrieve interceptors.
1479 InterceptorInfo* GetNamedInterceptor(); 1543 InterceptorInfo* GetNamedInterceptor();
1480 InterceptorInfo* GetIndexedInterceptor(); 1544 InterceptorInfo* GetIndexedInterceptor();
1481 1545
1482 inline PropertyAttributes GetPropertyAttribute(String* name); 1546 // Used from JSReceiver.
1483 PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver, 1547 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
1484 String* name); 1548 String* name,
1485 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);
1486 1558
1487 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, 1559 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name,
1488 bool is_getter, 1560 bool is_getter,
1489 Object* fun, 1561 Object* fun,
1490 PropertyAttributes attributes); 1562 PropertyAttributes attributes);
1491 Object* LookupAccessor(String* name, bool is_getter); 1563 Object* LookupAccessor(String* name, bool is_getter);
1492 1564
1493 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); 1565 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info);
1494 1566
1495 // Used from Object::GetProperty(). 1567 // Used from Object::GetProperty().
1496 MaybeObject* GetPropertyWithFailedAccessCheck( 1568 MaybeObject* GetPropertyWithFailedAccessCheck(
1497 Object* receiver, 1569 Object* receiver,
1498 LookupResult* result, 1570 LookupResult* result,
1499 String* name, 1571 String* name,
1500 PropertyAttributes* attributes); 1572 PropertyAttributes* attributes);
1501 MaybeObject* GetPropertyWithInterceptor( 1573 MaybeObject* GetPropertyWithInterceptor(
1502 JSObject* receiver, 1574 JSReceiver* receiver,
1503 String* name, 1575 String* name,
1504 PropertyAttributes* attributes); 1576 PropertyAttributes* attributes);
1505 MaybeObject* GetPropertyPostInterceptor( 1577 MaybeObject* GetPropertyPostInterceptor(
1506 JSObject* receiver, 1578 JSReceiver* receiver,
1507 String* name, 1579 String* name,
1508 PropertyAttributes* attributes); 1580 PropertyAttributes* attributes);
1509 MaybeObject* GetLocalPropertyPostInterceptor(JSObject* receiver, 1581 MaybeObject* GetLocalPropertyPostInterceptor(JSReceiver* receiver,
1510 String* name, 1582 String* name,
1511 PropertyAttributes* attributes); 1583 PropertyAttributes* attributes);
1512 1584
1513 // 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
1514 // been modified since it was created. May give false positives. 1586 // been modified since it was created. May give false positives.
1515 bool IsDirty(); 1587 bool IsDirty();
1516 1588
1517 bool HasProperty(String* name) {
1518 return GetPropertyAttribute(name) != ABSENT;
1519 }
1520
1521 // Can cause a GC if it hits an interceptor.
1522 bool HasLocalProperty(String* name) {
1523 return GetLocalPropertyAttribute(name) != ABSENT;
1524 }
1525
1526 // 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,
1527 // otherwise the result is the receiver itself. 1590 // otherwise the result is the receiver itself.
1528 inline Object* BypassGlobalProxy(); 1591 inline Object* BypassGlobalProxy();
1529 1592
1530 // Accessors for hidden properties object. 1593 // Accessors for hidden properties object.
1531 // 1594 //
1532 // Hidden properties are not local properties of the object itself. 1595 // Hidden properties are not local properties of the object itself.
1533 // 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
1534 // property with a special name Heap::hidden_symbol(). But if the 1597 // property with a special name Heap::hidden_symbol(). But if the
1535 // 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
1553 1616
1554 // 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
1555 // capacity? 1618 // capacity?
1556 bool ShouldConvertToSlowElements(int new_capacity); 1619 bool ShouldConvertToSlowElements(int new_capacity);
1557 // 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
1558 // 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
1559 // storage would. In that case the JSObject should have fast 1622 // storage would. In that case the JSObject should have fast
1560 // elements. 1623 // elements.
1561 bool ShouldConvertToFastElements(); 1624 bool ShouldConvertToFastElements();
1562 1625
1563 // Return the object's prototype (might be Heap::null_value()).
1564 inline Object* GetPrototype();
1565
1566 // Set the object's prototype (only JSObject and null are allowed).
1567 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value,
1568 bool skip_hidden_prototypes);
1569
1570 // Tells whether the index'th element is present. 1626 // Tells whether the index'th element is present.
1571 inline bool HasElement(uint32_t index); 1627 inline bool HasElement(uint32_t index);
1572 bool HasElementWithReceiver(JSObject* receiver, uint32_t index); 1628 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index);
1573 1629
1574 // Computes the new capacity when expanding the elements of a JSObject. 1630 // Computes the new capacity when expanding the elements of a JSObject.
1575 static int NewElementsCapacity(int old_capacity) { 1631 static int NewElementsCapacity(int old_capacity) {
1576 // (old_capacity + 50%) + 16 1632 // (old_capacity + 50%) + 16
1577 return old_capacity + (old_capacity >> 1) + 16; 1633 return old_capacity + (old_capacity >> 1) + 16;
1578 } 1634 }
1579 1635
1580 // 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.
1581 enum LocalElementType { 1637 enum LocalElementType {
1582 // There is no element with given index. 1638 // There is no element with given index.
1583 UNDEFINED_ELEMENT, 1639 UNDEFINED_ELEMENT,
1584 1640
1585 // Element with given index is handled by interceptor. 1641 // Element with given index is handled by interceptor.
1586 INTERCEPTED_ELEMENT, 1642 INTERCEPTED_ELEMENT,
1587 1643
1588 // Element with given index is character in string. 1644 // Element with given index is character in string.
1589 STRING_CHARACTER_ELEMENT, 1645 STRING_CHARACTER_ELEMENT,
1590 1646
1591 // Element with given index is stored in fast backing store. 1647 // Element with given index is stored in fast backing store.
1592 FAST_ELEMENT, 1648 FAST_ELEMENT,
1593 1649
1594 // Element with given index is stored in slow backing store. 1650 // Element with given index is stored in slow backing store.
1595 DICTIONARY_ELEMENT 1651 DICTIONARY_ELEMENT
1596 }; 1652 };
1597 1653
1598 LocalElementType HasLocalElement(uint32_t index); 1654 LocalElementType HasLocalElement(uint32_t index);
1599 1655
1600 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); 1656 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index);
1601 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); 1657 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index);
1602 1658
1603 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, 1659 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index,
1604 Object* value, 1660 Object* value,
1605 StrictModeFlag strict_mode, 1661 StrictModeFlag strict_mode,
1606 bool check_prototype = true); 1662 bool check_prototype = true);
1607 1663
1608 // Set the index'th array element. 1664 // Set the index'th array element.
1609 // A Failure object is returned if GC is needed. 1665 // A Failure object is returned if GC is needed.
1610 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, 1666 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
1611 Object* value, 1667 Object* value,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 inline int GetHeaderSize(); 1700 inline int GetHeaderSize();
1645 1701
1646 inline int GetInternalFieldCount(); 1702 inline int GetInternalFieldCount();
1647 inline int GetInternalFieldOffset(int index); 1703 inline int GetInternalFieldOffset(int index);
1648 inline Object* GetInternalField(int index); 1704 inline Object* GetInternalField(int index);
1649 inline void SetInternalField(int index, Object* value); 1705 inline void SetInternalField(int index, Object* value);
1650 1706
1651 // Lookup a property. If found, the result is valid and has 1707 // Lookup a property. If found, the result is valid and has
1652 // detailed information. 1708 // detailed information.
1653 void LocalLookup(String* name, LookupResult* result); 1709 void LocalLookup(String* name, LookupResult* result);
1654 void Lookup(String* name, LookupResult* result);
1655 1710
1656 // The following lookup functions skip interceptors. 1711 // The following lookup functions skip interceptors.
1657 void LocalLookupRealNamedProperty(String* name, LookupResult* result); 1712 void LocalLookupRealNamedProperty(String* name, LookupResult* result);
1658 void LookupRealNamedProperty(String* name, LookupResult* result); 1713 void LookupRealNamedProperty(String* name, LookupResult* result);
1659 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); 1714 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result);
1660 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); 1715 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result);
1661 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( 1716 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes(
1662 uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode); 1717 uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode);
1663 void LookupCallback(String* name, LookupResult* result); 1718 void LookupCallback(String* name, LookupResult* result);
1664 1719
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index); 1942 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index);
1888 1943
1889 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, 1944 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name,
1890 DeleteMode mode); 1945 DeleteMode mode);
1891 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); 1946 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name);
1892 1947
1893 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, 1948 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index,
1894 DeleteMode mode); 1949 DeleteMode mode);
1895 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); 1950 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index);
1896 1951
1897 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
1898 String* name,
1899 bool continue_search);
1900 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver,
1901 String* name,
1902 bool continue_search);
1903 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(
1904 Object* receiver,
1905 LookupResult* result,
1906 String* name,
1907 bool continue_search);
1908 PropertyAttributes GetPropertyAttribute(JSObject* receiver,
1909 LookupResult* result,
1910 String* name,
1911 bool continue_search);
1912
1913 // Returns true if most of the elements backing storage is used. 1952 // Returns true if most of the elements backing storage is used.
1914 bool HasDenseElements(); 1953 bool HasDenseElements();
1915 1954
1916 bool CanSetCallback(String* name); 1955 bool CanSetCallback(String* name);
1917 MUST_USE_RESULT MaybeObject* SetElementCallback( 1956 MUST_USE_RESULT MaybeObject* SetElementCallback(
1918 uint32_t index, 1957 uint32_t index,
1919 Object* structure, 1958 Object* structure,
1920 PropertyAttributes attributes); 1959 PropertyAttributes attributes);
1921 MUST_USE_RESULT MaybeObject* SetPropertyCallback( 1960 MUST_USE_RESULT MaybeObject* SetPropertyCallback(
1922 String* name, 1961 String* name,
(...skipping 4236 matching lines...) Expand 10 before | Expand all | Expand 10 after
6159 // Returns the isolate/heap this cell object belongs to. 6198 // Returns the isolate/heap this cell object belongs to.
6160 inline Isolate* isolate(); 6199 inline Isolate* isolate();
6161 inline Heap* heap(); 6200 inline Heap* heap();
6162 6201
6163 private: 6202 private:
6164 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); 6203 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell);
6165 }; 6204 };
6166 6205
6167 6206
6168 // The JSProxy describes EcmaScript Harmony proxies 6207 // The JSProxy describes EcmaScript Harmony proxies
6169 class JSProxy: public HeapObject { 6208 class JSProxy: public JSReceiver {
6170 public: 6209 public:
6171 // [handler]: The handler property. 6210 // [handler]: The handler property.
6172 DECL_ACCESSORS(handler, Object) 6211 DECL_ACCESSORS(handler, Object)
6173 6212
6174 // Casting. 6213 // Casting.
6175 static inline JSProxy* cast(Object* obj); 6214 static inline JSProxy* cast(Object* obj);
6176 6215
6216 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler(
6217 String* name_raw,
6218 Object* value_raw,
6219 PropertyAttributes attributes,
6220 StrictModeFlag strict_mode);
6221
6222 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler(
6223 JSReceiver* receiver,
6224 String* name_raw,
6225 bool* has_exception);
6226
6177 // Dispatched behavior. 6227 // Dispatched behavior.
6178 #ifdef OBJECT_PRINT 6228 #ifdef OBJECT_PRINT
6179 inline void JSProxyPrint() { 6229 inline void JSProxyPrint() {
6180 JSProxyPrint(stdout); 6230 JSProxyPrint(stdout);
6181 } 6231 }
6182 void JSProxyPrint(FILE* out); 6232 void JSProxyPrint(FILE* out);
6183 #endif 6233 #endif
6184 #ifdef DEBUG 6234 #ifdef DEBUG
6185 void JSProxyVerify(); 6235 void JSProxyVerify();
6186 #endif 6236 #endif
6187 6237
6188 // Layout description. 6238 // Layout description.
6189 static const int kHandlerOffset = HeapObject::kHeaderSize; 6239 static const int kHandlerOffset = HeapObject::kHeaderSize;
6190 static const int kSize = kHandlerOffset + kPointerSize; 6240 static const int kSize = kHandlerOffset + kPointerSize;
6191 6241
6192 typedef FixedBodyDescriptor<kHandlerOffset, 6242 typedef FixedBodyDescriptor<kHandlerOffset,
6193 kHandlerOffset + kPointerSize, 6243 kHandlerOffset + kPointerSize,
6194 kSize> BodyDescriptor; 6244 kSize> BodyDescriptor;
6195 6245
6196 private: 6246 private:
6197 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); 6247 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
6198 }; 6248 };
6199 6249
6200 6250
6251 // TODO(rossberg): Only a stub for now.
6252 class JSFunctionProxy: public JSProxy {
6253 public:
6254 // Casting.
6255 static inline JSFunctionProxy* cast(Object* obj);
6256
6257 private:
6258 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy);
6259 };
6260
6201 6261
6202 // Foreign describes objects pointing from JavaScript to C structures. 6262 // Foreign describes objects pointing from JavaScript to C structures.
6203 // Since they cannot contain references to JS HeapObjects they can be 6263 // Since they cannot contain references to JS HeapObjects they can be
6204 // placed in old_data_space. 6264 // placed in old_data_space.
6205 class Foreign: public HeapObject { 6265 class Foreign: public HeapObject {
6206 public: 6266 public:
6207 // [address]: field containing the address. 6267 // [address]: field containing the address.
6208 inline Address address(); 6268 inline Address address();
6209 inline void set_address(Address value); 6269 inline void set_address(Address value);
6210 6270
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
6833 } else { 6893 } else {
6834 value &= ~(1 << bit_position); 6894 value &= ~(1 << bit_position);
6835 } 6895 }
6836 return value; 6896 return value;
6837 } 6897 }
6838 }; 6898 };
6839 6899
6840 } } // namespace v8::internal 6900 } } // namespace v8::internal
6841 6901
6842 #endif // V8_OBJECTS_H_ 6902 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698