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

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: Renamed range constants for InstanceType enum. Created 9 years, 7 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
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) \ 294 V(JS_PROXY_TYPE) \
Kevin Millikin (Chromium) 2011/05/26 13:30:10 These aren't required by the implementation to be
rossberg 2011/05/31 14:50:24 Done.
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
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, FIRST_FUNCTION_CLASS_TYPE 568 JS_REGEXP_TYPE, // LAST_NONCALLABLE_SPEC_OBJECT_TYPE
566 569
567 JS_FUNCTION_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 // Boundaries for testing the types for which typeof is "object".
586 FIRST_FUNCTION_CLASS_TYPE = JS_REGEXP_TYPE 590 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_VALUE_TYPE,
Kevin Millikin (Chromium) 2011/05/26 13:30:10 That's not really pithy :(. How about FIRST_NONCA
rossberg 2011/05/31 14:50:24 Hm, with neither SPEC nor JS, wouldn't that name l
591 LAST_NONCALLABLE_SPEC_OBJECT_TYPE = JS_REGEXP_TYPE,
592 // Boundaries for testing the types for which typeof is "function".
593 FIRST_CALLABLE_SPEC_OBJECT_TYPE = JS_FUNCTION_TYPE,
594 LAST_CALLABLE_SPEC_OBJECT_TYPE = JS_FUNCTION_PROXY_TYPE,
595 // Boundaries for testing whether the type is a JavaScript object.
596 FIRST_SPEC_OBJECT_TYPE = FIRST_NONCALLABLE_SPEC_OBJECT_TYPE,
597 LAST_SPEC_OBJECT_TYPE = LAST_CALLABLE_SPEC_OBJECT_TYPE
587 }; 598 };
588 599
589 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE - 600 static const int kExternalArrayTypeCount = LAST_EXTERNAL_ARRAY_TYPE -
590 FIRST_EXTERNAL_ARRAY_TYPE + 1; 601 FIRST_EXTERNAL_ARRAY_TYPE + 1;
591 602
592 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType); 603 STATIC_CHECK(JS_OBJECT_TYPE == Internals::kJSObjectType);
593 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); 604 STATIC_CHECK(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType);
594 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType); 605 STATIC_CHECK(FOREIGN_TYPE == Internals::kForeignType);
595 606
596 607
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 V(ExternalByteArray) \ 713 V(ExternalByteArray) \
703 V(ExternalUnsignedByteArray) \ 714 V(ExternalUnsignedByteArray) \
704 V(ExternalShortArray) \ 715 V(ExternalShortArray) \
705 V(ExternalUnsignedShortArray) \ 716 V(ExternalUnsignedShortArray) \
706 V(ExternalIntArray) \ 717 V(ExternalIntArray) \
707 V(ExternalUnsignedIntArray) \ 718 V(ExternalUnsignedIntArray) \
708 V(ExternalFloatArray) \ 719 V(ExternalFloatArray) \
709 V(ExternalDoubleArray) \ 720 V(ExternalDoubleArray) \
710 V(ExternalPixelArray) \ 721 V(ExternalPixelArray) \
711 V(ByteArray) \ 722 V(ByteArray) \
723 V(JSReceiver) \
712 V(JSObject) \ 724 V(JSObject) \
713 V(JSContextExtensionObject) \ 725 V(JSContextExtensionObject) \
714 V(Map) \ 726 V(Map) \
715 V(DescriptorArray) \ 727 V(DescriptorArray) \
716 V(DeoptimizationInputData) \ 728 V(DeoptimizationInputData) \
717 V(DeoptimizationOutputData) \ 729 V(DeoptimizationOutputData) \
718 V(FixedArray) \ 730 V(FixedArray) \
719 V(Context) \ 731 V(Context) \
720 V(CatchContext) \ 732 V(CatchContext) \
721 V(GlobalContext) \ 733 V(GlobalContext) \
722 V(JSFunction) \ 734 V(JSFunction) \
723 V(Code) \ 735 V(Code) \
724 V(Oddball) \ 736 V(Oddball) \
725 V(SharedFunctionInfo) \ 737 V(SharedFunctionInfo) \
726 V(JSValue) \ 738 V(JSValue) \
727 V(JSMessageObject) \ 739 V(JSMessageObject) \
728 V(StringWrapper) \ 740 V(StringWrapper) \
729 V(Foreign) \ 741 V(Foreign) \
730 V(Boolean) \ 742 V(Boolean) \
731 V(JSArray) \ 743 V(JSArray) \
732 V(JSProxy) \ 744 V(JSProxy) \
745 V(JSFunctionProxy) \
733 V(JSRegExp) \ 746 V(JSRegExp) \
734 V(HashTable) \ 747 V(HashTable) \
735 V(Dictionary) \ 748 V(Dictionary) \
736 V(SymbolTable) \ 749 V(SymbolTable) \
737 V(JSFunctionResultCache) \ 750 V(JSFunctionResultCache) \
738 V(NormalizedMapCache) \ 751 V(NormalizedMapCache) \
739 V(CompilationCacheTable) \ 752 V(CompilationCacheTable) \
740 V(CodeCacheHashTable) \ 753 V(CodeCacheHashTable) \
741 V(MapCache) \ 754 V(MapCache) \
742 V(Primitive) \ 755 V(Primitive) \
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 static const int kExponentBias = 1023; 1338 static const int kExponentBias = 1023;
1326 static const int kExponentShift = 20; 1339 static const int kExponentShift = 20;
1327 static const int kMantissaBitsInTopWord = 20; 1340 static const int kMantissaBitsInTopWord = 20;
1328 static const int kNonMantissaBitsInTopWord = 12; 1341 static const int kNonMantissaBitsInTopWord = 12;
1329 1342
1330 private: 1343 private:
1331 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); 1344 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);
1332 }; 1345 };
1333 1346
1334 1347
1348 // JSReceiver includes types on which properties can be defined, i.e.,
1349 // JSObject and JSProxy.
1350 class JSReceiver: public HeapObject {
1351 public:
1352 // Casting.
1353 static inline JSReceiver* cast(Object* obj);
1354
1355 // Can cause GC.
1356 MUST_USE_RESULT MaybeObject* SetProperty(String* key,
1357 Object* value,
1358 PropertyAttributes attributes,
1359 StrictModeFlag strict_mode);
1360 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result,
1361 String* key,
1362 Object* value,
1363 PropertyAttributes attributes,
1364 StrictModeFlag strict_mode);
1365
1366 // Returns the class name ([[Class]] property in the specification).
1367 String* class_name();
1368
1369 // Returns the constructor name (the name (possibly, inferred name) of the
1370 // function that was used to instantiate the object).
1371 String* constructor_name();
1372
1373 inline PropertyAttributes GetPropertyAttribute(String* name);
1374 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver,
1375 String* name);
1376 PropertyAttributes GetLocalPropertyAttribute(String* name);
1377
1378 // Can cause a GC.
1379 bool HasProperty(String* name) {
1380 return GetPropertyAttribute(name) != ABSENT;
1381 }
1382
1383 // Can cause a GC.
1384 bool HasLocalProperty(String* name) {
1385 return GetLocalPropertyAttribute(name) != ABSENT;
1386 }
1387
1388 // Return the object's prototype (might be Heap::null_value()).
1389 inline Object* GetPrototype();
1390
1391 // Set the object's prototype (only JSReceiver and null are allowed).
1392 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value,
1393 bool skip_hidden_prototypes);
1394
1395 // Lookup a property. If found, the result is valid and has
1396 // detailed information.
1397 void LocalLookup(String* name, LookupResult* result);
1398 void Lookup(String* name, LookupResult* result);
1399
1400 private:
1401 PropertyAttributes GetPropertyAttribute(JSReceiver* receiver,
1402 LookupResult* result,
1403 String* name,
1404 bool continue_search);
1405
1406 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
1407 };
1408
1335 // The JSObject describes real heap allocated JavaScript objects with 1409 // The JSObject describes real heap allocated JavaScript objects with
1336 // properties. 1410 // properties.
1337 // Note that the map of JSObject changes during execution to enable inline 1411 // Note that the map of JSObject changes during execution to enable inline
1338 // caching. 1412 // caching.
1339 class JSObject: public HeapObject { 1413 class JSObject: public JSReceiver {
1340 public: 1414 public:
1341 enum DeleteMode { 1415 enum DeleteMode {
1342 NORMAL_DELETION, 1416 NORMAL_DELETION,
1343 STRICT_DELETION, 1417 STRICT_DELETION,
1344 FORCE_DELETION 1418 FORCE_DELETION
1345 }; 1419 };
1346 1420
1347 enum ElementsKind { 1421 enum ElementsKind {
1348 // The only "fast" kind. 1422 // The only "fast" kind.
1349 FAST_ELEMENTS, 1423 FAST_ELEMENTS,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); 1479 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
1406 1480
1407 // Collects elements starting at index 0. 1481 // Collects elements starting at index 0.
1408 // Undefined values are placed after non-undefined values. 1482 // Undefined values are placed after non-undefined values.
1409 // Returns the number of non-undefined values. 1483 // Returns the number of non-undefined values.
1410 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); 1484 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit);
1411 // As PrepareElementsForSort, but only on objects where elements is 1485 // As PrepareElementsForSort, but only on objects where elements is
1412 // a dictionary, and it will stay a dictionary. 1486 // a dictionary, and it will stay a dictionary.
1413 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); 1487 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit);
1414 1488
1415 MUST_USE_RESULT MaybeObject* SetProperty(String* key, 1489 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, 1490 String* key,
1421 Object* value, 1491 Object* value,
1422 PropertyAttributes attributes, 1492 PropertyAttributes attributes,
1423 StrictModeFlag strict_mode); 1493 StrictModeFlag strict_mode);
1424 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( 1494 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck(
1425 LookupResult* result, 1495 LookupResult* result,
1426 String* name, 1496 String* name,
1427 Object* value, 1497 Object* value,
1428 bool check_prototype); 1498 bool check_prototype);
1429 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure, 1499 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure,
(...skipping 28 matching lines...) Expand all
1458 // Sets the property value in a normalized object given (key, value, details). 1528 // Sets the property value in a normalized object given (key, value, details).
1459 // Handles the special representation of JS global objects. 1529 // Handles the special representation of JS global objects.
1460 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, 1530 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name,
1461 Object* value, 1531 Object* value,
1462 PropertyDetails details); 1532 PropertyDetails details);
1463 1533
1464 // Deletes the named property in a normalized object. 1534 // Deletes the named property in a normalized object.
1465 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, 1535 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name,
1466 DeleteMode mode); 1536 DeleteMode mode);
1467 1537
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. 1538 // Retrieve interceptors.
1476 InterceptorInfo* GetNamedInterceptor(); 1539 InterceptorInfo* GetNamedInterceptor();
1477 InterceptorInfo* GetIndexedInterceptor(); 1540 InterceptorInfo* GetIndexedInterceptor();
1478 1541
1479 inline PropertyAttributes GetPropertyAttribute(String* name); 1542 // Used from JSReceiver.
1480 PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver, 1543 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
1481 String* name); 1544 String* name,
1482 PropertyAttributes GetLocalPropertyAttribute(String* name); 1545 bool continue_search);
1546 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver,
1547 String* name,
1548 bool continue_search);
1549 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(
1550 Object* receiver,
1551 LookupResult* result,
1552 String* name,
1553 bool continue_search);
1483 1554
1484 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, 1555 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name,
1485 bool is_getter, 1556 bool is_getter,
1486 Object* fun, 1557 Object* fun,
1487 PropertyAttributes attributes); 1558 PropertyAttributes attributes);
1488 Object* LookupAccessor(String* name, bool is_getter); 1559 Object* LookupAccessor(String* name, bool is_getter);
1489 1560
1490 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); 1561 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info);
1491 1562
1492 // Used from Object::GetProperty(). 1563 // Used from Object::GetProperty().
1493 MaybeObject* GetPropertyWithFailedAccessCheck( 1564 MaybeObject* GetPropertyWithFailedAccessCheck(
1494 Object* receiver, 1565 Object* receiver,
1495 LookupResult* result, 1566 LookupResult* result,
1496 String* name, 1567 String* name,
1497 PropertyAttributes* attributes); 1568 PropertyAttributes* attributes);
1498 MaybeObject* GetPropertyWithInterceptor( 1569 MaybeObject* GetPropertyWithInterceptor(
1499 JSObject* receiver, 1570 JSReceiver* receiver,
1500 String* name, 1571 String* name,
1501 PropertyAttributes* attributes); 1572 PropertyAttributes* attributes);
1502 MaybeObject* GetPropertyPostInterceptor( 1573 MaybeObject* GetPropertyPostInterceptor(
1503 JSObject* receiver, 1574 JSReceiver* receiver,
1504 String* name, 1575 String* name,
1505 PropertyAttributes* attributes); 1576 PropertyAttributes* attributes);
1506 MaybeObject* GetLocalPropertyPostInterceptor(JSObject* receiver, 1577 MaybeObject* GetLocalPropertyPostInterceptor(JSReceiver* receiver,
1507 String* name, 1578 String* name,
1508 PropertyAttributes* attributes); 1579 PropertyAttributes* attributes);
1509 1580
1510 // Returns true if this is an instance of an api function and has 1581 // Returns true if this is an instance of an api function and has
1511 // been modified since it was created. May give false positives. 1582 // been modified since it was created. May give false positives.
1512 bool IsDirty(); 1583 bool IsDirty();
1513 1584
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, 1585 // If the receiver is a JSGlobalProxy this method will return its prototype,
1524 // otherwise the result is the receiver itself. 1586 // otherwise the result is the receiver itself.
1525 inline Object* BypassGlobalProxy(); 1587 inline Object* BypassGlobalProxy();
1526 1588
1527 // Accessors for hidden properties object. 1589 // Accessors for hidden properties object.
1528 // 1590 //
1529 // Hidden properties are not local properties of the object itself. 1591 // Hidden properties are not local properties of the object itself.
1530 // Instead they are stored on an auxiliary JSObject stored as a local 1592 // Instead they are stored on an auxiliary JSObject stored as a local
1531 // property with a special name Heap::hidden_symbol(). But if the 1593 // property with a special name Heap::hidden_symbol(). But if the
1532 // receiver is a JSGlobalProxy then the auxiliary object is a property 1594 // receiver is a JSGlobalProxy then the auxiliary object is a property
(...skipping 17 matching lines...) Expand all
1550 1612
1551 // Do we want to keep the elements in fast case when increasing the 1613 // Do we want to keep the elements in fast case when increasing the
1552 // capacity? 1614 // capacity?
1553 bool ShouldConvertToSlowElements(int new_capacity); 1615 bool ShouldConvertToSlowElements(int new_capacity);
1554 // Returns true if the backing storage for the slow-case elements of 1616 // 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 1617 // this object takes up nearly as much space as a fast-case backing
1556 // storage would. In that case the JSObject should have fast 1618 // storage would. In that case the JSObject should have fast
1557 // elements. 1619 // elements.
1558 bool ShouldConvertToFastElements(); 1620 bool ShouldConvertToFastElements();
1559 1621
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. 1622 // Tells whether the index'th element is present.
1568 inline bool HasElement(uint32_t index); 1623 inline bool HasElement(uint32_t index);
1569 bool HasElementWithReceiver(JSObject* receiver, uint32_t index); 1624 bool HasElementWithReceiver(JSReceiver* receiver, uint32_t index);
1570 1625
1571 // Computes the new capacity when expanding the elements of a JSObject. 1626 // Computes the new capacity when expanding the elements of a JSObject.
1572 static int NewElementsCapacity(int old_capacity) { 1627 static int NewElementsCapacity(int old_capacity) {
1573 // (old_capacity + 50%) + 16 1628 // (old_capacity + 50%) + 16
1574 return old_capacity + (old_capacity >> 1) + 16; 1629 return old_capacity + (old_capacity >> 1) + 16;
1575 } 1630 }
1576 1631
1577 // Tells whether the index'th element is present and how it is stored. 1632 // Tells whether the index'th element is present and how it is stored.
1578 enum LocalElementType { 1633 enum LocalElementType {
1579 // There is no element with given index. 1634 // There is no element with given index.
1580 UNDEFINED_ELEMENT, 1635 UNDEFINED_ELEMENT,
1581 1636
1582 // Element with given index is handled by interceptor. 1637 // Element with given index is handled by interceptor.
1583 INTERCEPTED_ELEMENT, 1638 INTERCEPTED_ELEMENT,
1584 1639
1585 // Element with given index is character in string. 1640 // Element with given index is character in string.
1586 STRING_CHARACTER_ELEMENT, 1641 STRING_CHARACTER_ELEMENT,
1587 1642
1588 // Element with given index is stored in fast backing store. 1643 // Element with given index is stored in fast backing store.
1589 FAST_ELEMENT, 1644 FAST_ELEMENT,
1590 1645
1591 // Element with given index is stored in slow backing store. 1646 // Element with given index is stored in slow backing store.
1592 DICTIONARY_ELEMENT 1647 DICTIONARY_ELEMENT
1593 }; 1648 };
1594 1649
1595 LocalElementType HasLocalElement(uint32_t index); 1650 LocalElementType HasLocalElement(uint32_t index);
1596 1651
1597 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); 1652 bool HasElementWithInterceptor(JSReceiver* receiver, uint32_t index);
1598 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); 1653 bool HasElementPostInterceptor(JSReceiver* receiver, uint32_t index);
1599 1654
1600 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, 1655 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index,
1601 Object* value, 1656 Object* value,
1602 StrictModeFlag strict_mode, 1657 StrictModeFlag strict_mode,
1603 bool check_prototype = true); 1658 bool check_prototype = true);
1604 1659
1605 // Set the index'th array element. 1660 // Set the index'th array element.
1606 // A Failure object is returned if GC is needed. 1661 // A Failure object is returned if GC is needed.
1607 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, 1662 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
1608 Object* value, 1663 Object* value,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 inline int GetHeaderSize(); 1696 inline int GetHeaderSize();
1642 1697
1643 inline int GetInternalFieldCount(); 1698 inline int GetInternalFieldCount();
1644 inline int GetInternalFieldOffset(int index); 1699 inline int GetInternalFieldOffset(int index);
1645 inline Object* GetInternalField(int index); 1700 inline Object* GetInternalField(int index);
1646 inline void SetInternalField(int index, Object* value); 1701 inline void SetInternalField(int index, Object* value);
1647 1702
1648 // Lookup a property. If found, the result is valid and has 1703 // Lookup a property. If found, the result is valid and has
1649 // detailed information. 1704 // detailed information.
1650 void LocalLookup(String* name, LookupResult* result); 1705 void LocalLookup(String* name, LookupResult* result);
1651 void Lookup(String* name, LookupResult* result); 1706 // void Lookup(String* name, LookupResult* result);
Kevin Millikin (Chromium) 2011/05/26 13:30:10 Can this be removed?
rossberg 2011/05/31 14:50:24 Oops.
1652 1707
1653 // The following lookup functions skip interceptors. 1708 // The following lookup functions skip interceptors.
1654 void LocalLookupRealNamedProperty(String* name, LookupResult* result); 1709 void LocalLookupRealNamedProperty(String* name, LookupResult* result);
1655 void LookupRealNamedProperty(String* name, LookupResult* result); 1710 void LookupRealNamedProperty(String* name, LookupResult* result);
1656 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); 1711 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result);
1657 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); 1712 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result);
1658 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( 1713 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes(
1659 uint32_t index, Object* value, bool* found); 1714 uint32_t index, Object* value, bool* found);
1660 void LookupCallback(String* name, LookupResult* result); 1715 void LookupCallback(String* name, LookupResult* result);
1661 1716
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index); 1938 MaybeObject* GetElementPostInterceptor(Object* receiver, uint32_t index);
1884 1939
1885 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, 1940 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name,
1886 DeleteMode mode); 1941 DeleteMode mode);
1887 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); 1942 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name);
1888 1943
1889 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, 1944 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index,
1890 DeleteMode mode); 1945 DeleteMode mode);
1891 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); 1946 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index);
1892 1947
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. 1948 // Returns true if most of the elements backing storage is used.
1910 bool HasDenseElements(); 1949 bool HasDenseElements();
1911 1950
1912 bool CanSetCallback(String* name); 1951 bool CanSetCallback(String* name);
1913 MUST_USE_RESULT MaybeObject* SetElementCallback( 1952 MUST_USE_RESULT MaybeObject* SetElementCallback(
1914 uint32_t index, 1953 uint32_t index,
1915 Object* structure, 1954 Object* structure,
1916 PropertyAttributes attributes); 1955 PropertyAttributes attributes);
1917 MUST_USE_RESULT MaybeObject* SetPropertyCallback( 1956 MUST_USE_RESULT MaybeObject* SetPropertyCallback(
1918 String* name, 1957 String* name,
(...skipping 4188 matching lines...) Expand 10 before | Expand all | Expand 10 after
6107 // Returns the isolate/heap this cell object belongs to. 6146 // Returns the isolate/heap this cell object belongs to.
6108 inline Isolate* isolate(); 6147 inline Isolate* isolate();
6109 inline Heap* heap(); 6148 inline Heap* heap();
6110 6149
6111 private: 6150 private:
6112 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); 6151 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell);
6113 }; 6152 };
6114 6153
6115 6154
6116 // The JSProxy describes EcmaScript Harmony proxies 6155 // The JSProxy describes EcmaScript Harmony proxies
6117 class JSProxy: public HeapObject { 6156 class JSProxy: public JSReceiver {
6118 public: 6157 public:
6119 // [handler]: The handler property. 6158 // [handler]: The handler property.
6120 DECL_ACCESSORS(handler, Object) 6159 DECL_ACCESSORS(handler, Object)
6121 6160
6122 // Casting. 6161 // Casting.
6123 static inline JSProxy* cast(Object* obj); 6162 static inline JSProxy* cast(Object* obj);
6124 6163
6164 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler(
6165 String* name_raw,
6166 Object* value_raw,
6167 PropertyAttributes attributes,
6168 StrictModeFlag strict_mode);
6169
6170 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler(
6171 JSReceiver* receiver,
6172 String* name_raw,
6173 bool* has_exception);
6174
6125 // Dispatched behavior. 6175 // Dispatched behavior.
6126 #ifdef OBJECT_PRINT 6176 #ifdef OBJECT_PRINT
6127 inline void JSProxyPrint() { 6177 inline void JSProxyPrint() {
6128 JSProxyPrint(stdout); 6178 JSProxyPrint(stdout);
6129 } 6179 }
6130 void JSProxyPrint(FILE* out); 6180 void JSProxyPrint(FILE* out);
6131 #endif 6181 #endif
6132 #ifdef DEBUG 6182 #ifdef DEBUG
6133 void JSProxyVerify(); 6183 void JSProxyVerify();
6134 #endif 6184 #endif
6135 6185
6136 // Layout description. 6186 // Layout description.
6137 static const int kHandlerOffset = HeapObject::kHeaderSize; 6187 static const int kHandlerOffset = HeapObject::kHeaderSize;
6138 static const int kSize = kHandlerOffset + kPointerSize; 6188 static const int kSize = kHandlerOffset + kPointerSize;
6139 6189
6140 typedef FixedBodyDescriptor<kHandlerOffset, 6190 typedef FixedBodyDescriptor<kHandlerOffset,
6141 kHandlerOffset + kPointerSize, 6191 kHandlerOffset + kPointerSize,
6142 kSize> BodyDescriptor; 6192 kSize> BodyDescriptor;
6143 6193
6144 private: 6194 private:
6145 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); 6195 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
6146 }; 6196 };
6147 6197
6148 6198
6199 // TODO(rossberg): Only a stub for now.
6200 class JSFunctionProxy: public JSProxy {
6201 public:
6202 // Casting.
6203 static inline JSFunctionProxy* cast(Object* obj);
6204
6205 private:
6206 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy);
6207 };
6208
6149 6209
6150 // Foreign describes objects pointing from JavaScript to C structures. 6210 // Foreign describes objects pointing from JavaScript to C structures.
6151 // Since they cannot contain references to JS HeapObjects they can be 6211 // Since they cannot contain references to JS HeapObjects they can be
6152 // placed in old_data_space. 6212 // placed in old_data_space.
6153 class Foreign: public HeapObject { 6213 class Foreign: public HeapObject {
6154 public: 6214 public:
6155 // [address]: field containing the address. 6215 // [address]: field containing the address.
6156 inline Address address(); 6216 inline Address address();
6157 inline void set_address(Address value); 6217 inline void set_address(Address value);
6158 6218
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
6781 } else { 6841 } else {
6782 value &= ~(1 << bit_position); 6842 value &= ~(1 << bit_position);
6783 } 6843 }
6784 return value; 6844 return value;
6785 } 6845 }
6786 }; 6846 };
6787 6847
6788 } } // namespace v8::internal 6848 } } // namespace v8::internal
6789 6849
6790 #endif // V8_OBJECTS_H_ 6850 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698