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

Side by Side Diff: src/objects.h

Issue 6577036: [Isolates] Merge from bleeding_edge to isolates, revisions 6100-6300. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 10 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/mirror-debugger.js ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); 703 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
704 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 704 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
705 #undef DECLARE_STRUCT_PREDICATE 705 #undef DECLARE_STRUCT_PREDICATE
706 706
707 // Oddball testing. 707 // Oddball testing.
708 INLINE(bool IsUndefined()); 708 INLINE(bool IsUndefined());
709 INLINE(bool IsNull()); 709 INLINE(bool IsNull());
710 INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation. 710 INLINE(bool IsTheHole()); // Shadows MaybeObject's implementation.
711 INLINE(bool IsTrue()); 711 INLINE(bool IsTrue());
712 INLINE(bool IsFalse()); 712 INLINE(bool IsFalse());
713 inline bool IsArgumentsMarker();
713 714
714 // Extract the number. 715 // Extract the number.
715 inline double Number(); 716 inline double Number();
716 717
717 inline bool HasSpecificClassOf(String* name); 718 inline bool HasSpecificClassOf(String* name);
718 719
719 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. 720 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9.
720 Object* ToBoolean(); // ECMA-262 9.2. 721 Object* ToBoolean(); // ECMA-262 9.2.
721 722
722 // Convert to a JSObject if needed. 723 // Convert to a JSObject if needed.
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 MUST_USE_RESULT MaybeObject* SetProperty(String* key, 1344 MUST_USE_RESULT MaybeObject* SetProperty(String* key,
1344 Object* value, 1345 Object* value,
1345 PropertyAttributes attributes); 1346 PropertyAttributes attributes);
1346 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, 1347 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result,
1347 String* key, 1348 String* key,
1348 Object* value, 1349 Object* value,
1349 PropertyAttributes attributes); 1350 PropertyAttributes attributes);
1350 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( 1351 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck(
1351 LookupResult* result, 1352 LookupResult* result,
1352 String* name, 1353 String* name,
1353 Object* value); 1354 Object* value,
1355 bool check_prototype);
1354 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure, 1356 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure,
1355 String* name, 1357 String* name,
1356 Object* value, 1358 Object* value,
1357 JSObject* holder); 1359 JSObject* holder);
1358 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSFunction* setter, 1360 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSFunction* setter,
1359 Object* value); 1361 Object* value);
1360 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( 1362 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor(
1361 String* name, 1363 String* name,
1362 Object* value, 1364 Object* value,
1363 PropertyAttributes attributes); 1365 PropertyAttributes attributes);
1364 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( 1366 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor(
1365 String* name, 1367 String* name,
1366 Object* value, 1368 Object* value,
1367 PropertyAttributes attributes); 1369 PropertyAttributes attributes);
1368 MUST_USE_RESULT MaybeObject* IgnoreAttributesAndSetLocalProperty( 1370 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
1369 String* key, 1371 String* key,
1370 Object* value, 1372 Object* value,
1371 PropertyAttributes attributes); 1373 PropertyAttributes attributes);
1372 1374
1373 // Retrieve a value in a normalized object given a lookup result. 1375 // Retrieve a value in a normalized object given a lookup result.
1374 // Handles the special representation of JS global objects. 1376 // Handles the special representation of JS global objects.
1375 Object* GetNormalizedProperty(LookupResult* result); 1377 Object* GetNormalizedProperty(LookupResult* result);
1376 1378
1377 // Sets the property value in a normalized object given a lookup result. 1379 // Sets the property value in a normalized object given a lookup result.
1378 // Handles the special representation of JS global objects. 1380 // Handles the special representation of JS global objects.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 1509
1508 // Element with given index is stored in slow backing store. 1510 // Element with given index is stored in slow backing store.
1509 DICTIONARY_ELEMENT 1511 DICTIONARY_ELEMENT
1510 }; 1512 };
1511 1513
1512 LocalElementType HasLocalElement(uint32_t index); 1514 LocalElementType HasLocalElement(uint32_t index);
1513 1515
1514 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); 1516 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index);
1515 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); 1517 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index);
1516 1518
1517 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, Object* value); 1519 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index,
1520 Object* value,
1521 bool check_prototype = true);
1518 1522
1519 // Set the index'th array element. 1523 // Set the index'th array element.
1520 // A Failure object is returned if GC is needed. 1524 // A Failure object is returned if GC is needed.
1521 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, Object* value); 1525 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
1526 Object* value,
1527 bool check_prototype = true);
1522 1528
1523 // Returns the index'th element. 1529 // Returns the index'th element.
1524 // The undefined object if index is out of bounds. 1530 // The undefined object if index is out of bounds.
1525 MaybeObject* GetElementWithReceiver(JSObject* receiver, uint32_t index); 1531 MaybeObject* GetElementWithReceiver(JSObject* receiver, uint32_t index);
1526 MaybeObject* GetElementWithInterceptor(JSObject* receiver, uint32_t index); 1532 MaybeObject* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
1527 1533
1528 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity, 1534 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity,
1529 int length); 1535 int length);
1530 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length); 1536 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length);
1531 1537
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 private: 1771 private:
1766 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, 1772 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver,
1767 Object* structure, 1773 Object* structure,
1768 uint32_t index, 1774 uint32_t index,
1769 Object* holder); 1775 Object* holder);
1770 MaybeObject* SetElementWithCallback(Object* structure, 1776 MaybeObject* SetElementWithCallback(Object* structure,
1771 uint32_t index, 1777 uint32_t index,
1772 Object* value, 1778 Object* value,
1773 JSObject* holder); 1779 JSObject* holder);
1774 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(uint32_t index, 1780 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(uint32_t index,
1775 Object* value); 1781 Object* value,
1776 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor(uint32_t index, 1782 bool check_prototype);
1777 Object* value); 1783 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor(
1784 uint32_t index,
1785 Object* value,
1786 bool check_prototype);
1778 1787
1779 MaybeObject* GetElementPostInterceptor(JSObject* receiver, uint32_t index); 1788 MaybeObject* GetElementPostInterceptor(JSObject* receiver, uint32_t index);
1780 1789
1781 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, 1790 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name,
1782 DeleteMode mode); 1791 DeleteMode mode);
1783 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); 1792 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name);
1784 1793
1785 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index, 1794 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index,
1786 DeleteMode mode); 1795 DeleteMode mode);
1787 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); 1796 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index);
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 // 2346 //
2338 // No special elements in the prefix and the element size is 1 2347 // No special elements in the prefix and the element size is 1
2339 // because only the symbol itself (the key) needs to be stored. 2348 // because only the symbol itself (the key) needs to be stored.
2340 class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> { 2349 class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> {
2341 public: 2350 public:
2342 // Find symbol in the symbol table. If it is not there yet, it is 2351 // Find symbol in the symbol table. If it is not there yet, it is
2343 // added. The return value is the symbol table which might have 2352 // added. The return value is the symbol table which might have
2344 // been enlarged. If the return value is not a failure, the symbol 2353 // been enlarged. If the return value is not a failure, the symbol
2345 // pointer *s is set to the symbol found. 2354 // pointer *s is set to the symbol found.
2346 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str, Object** s); 2355 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str, Object** s);
2356 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str,
2357 Object** s);
2358 MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol(Vector<const uc16> str,
2359 Object** s);
2347 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s); 2360 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s);
2348 2361
2349 // Looks up a symbol that is equal to the given string and returns 2362 // Looks up a symbol that is equal to the given string and returns
2350 // true if it is found, assigning the symbol to the given output 2363 // true if it is found, assigning the symbol to the given output
2351 // parameter. 2364 // parameter.
2352 bool LookupSymbolIfExists(String* str, String** symbol); 2365 bool LookupSymbolIfExists(String* str, String** symbol);
2353 bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String** symbol); 2366 bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String** symbol);
2354 2367
2355 // Casting. 2368 // Casting.
2356 static inline SymbolTable* cast(Object* obj); 2369 static inline SymbolTable* cast(Object* obj);
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 3131
3119 // Casting. 3132 // Casting.
3120 static inline DeoptimizationOutputData* cast(Object* obj); 3133 static inline DeoptimizationOutputData* cast(Object* obj);
3121 3134
3122 #ifdef OBJECT_PRINT 3135 #ifdef OBJECT_PRINT
3123 void DeoptimizationOutputDataPrint(FILE* out); 3136 void DeoptimizationOutputDataPrint(FILE* out);
3124 #endif 3137 #endif
3125 }; 3138 };
3126 3139
3127 3140
3141 class SafepointEntry;
3142
3143
3128 // Code describes objects with on-the-fly generated machine code. 3144 // Code describes objects with on-the-fly generated machine code.
3129 class Code: public HeapObject { 3145 class Code: public HeapObject {
3130 public: 3146 public:
3131 // Opaque data type for encapsulating code flags like kind, inline 3147 // Opaque data type for encapsulating code flags like kind, inline
3132 // cache state, and arguments count. 3148 // cache state, and arguments count.
3133 // FLAGS_MIN_VALUE and FLAGS_MAX_VALUE are specified to ensure that 3149 // FLAGS_MIN_VALUE and FLAGS_MAX_VALUE are specified to ensure that
3134 // enumeration type has correct value range (see Issue 830 for more details). 3150 // enumeration type has correct value range (see Issue 830 for more details).
3135 enum Flags { 3151 enum Flags {
3136 FLAGS_MIN_VALUE = kMinInt, 3152 FLAGS_MIN_VALUE = kMinInt,
3137 FLAGS_MAX_VALUE = kMaxInt 3153 FLAGS_MAX_VALUE = kMaxInt
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3265 inline byte type_recording_binary_op_type(); 3281 inline byte type_recording_binary_op_type();
3266 inline void set_type_recording_binary_op_type(byte value); 3282 inline void set_type_recording_binary_op_type(byte value);
3267 inline byte type_recording_binary_op_result_type(); 3283 inline byte type_recording_binary_op_result_type();
3268 inline void set_type_recording_binary_op_result_type(byte value); 3284 inline void set_type_recording_binary_op_result_type(byte value);
3269 3285
3270 // [compare state]: For kind compare IC stubs, tells what state the 3286 // [compare state]: For kind compare IC stubs, tells what state the
3271 // stub is in. 3287 // stub is in.
3272 inline byte compare_state(); 3288 inline byte compare_state();
3273 inline void set_compare_state(byte value); 3289 inline void set_compare_state(byte value);
3274 3290
3275 // Get the safepoint entry for the given pc. Returns NULL for 3291 // Get the safepoint entry for the given pc.
3276 // non-safepoint pcs. 3292 SafepointEntry GetSafepointEntry(Address pc);
3277 uint8_t* GetSafepointEntry(Address pc);
3278 3293
3279 // Mark this code object as not having a stack check table. Assumes kind 3294 // Mark this code object as not having a stack check table. Assumes kind
3280 // is FUNCTION. 3295 // is FUNCTION.
3281 void SetNoStackCheckTable(); 3296 void SetNoStackCheckTable();
3282 3297
3283 // Find the first map in an IC stub. 3298 // Find the first map in an IC stub.
3284 Map* FindFirstMap(); 3299 Map* FindFirstMap();
3285 3300
3286 // Flags operations. 3301 // Flags operations.
3287 static inline Flags ComputeFlags(Kind kind, 3302 static inline Flags ComputeFlags(Kind kind,
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5087 bool MarkAsUndetectable(); 5102 bool MarkAsUndetectable();
5088 5103
5089 // Return a substring. 5104 // Return a substring.
5090 MUST_USE_RESULT MaybeObject* SubString(int from, 5105 MUST_USE_RESULT MaybeObject* SubString(int from,
5091 int to, 5106 int to,
5092 PretenureFlag pretenure = NOT_TENURED); 5107 PretenureFlag pretenure = NOT_TENURED);
5093 5108
5094 // String equality operations. 5109 // String equality operations.
5095 inline bool Equals(String* other); 5110 inline bool Equals(String* other);
5096 bool IsEqualTo(Vector<const char> str); 5111 bool IsEqualTo(Vector<const char> str);
5112 bool IsAsciiEqualTo(Vector<const char> str);
5113 bool IsTwoByteEqualTo(Vector<const uc16> str);
5097 5114
5098 // Return a UTF8 representation of the string. The string is null 5115 // Return a UTF8 representation of the string. The string is null
5099 // terminated but may optionally contain nulls. Length is returned 5116 // terminated but may optionally contain nulls. Length is returned
5100 // in length_output if length_output is not a null pointer The string 5117 // in length_output if length_output is not a null pointer The string
5101 // should be nearly flat, otherwise the performance of this method may 5118 // should be nearly flat, otherwise the performance of this method may
5102 // be very slow (quadratic in the length). Setting robustness_flag to 5119 // be very slow (quadratic in the length). Setting robustness_flag to
5103 // ROBUST_STRING_TRAVERSAL invokes behaviour that is robust This means it 5120 // ROBUST_STRING_TRAVERSAL invokes behaviour that is robust This means it
5104 // handles unexpected data without causing assert failures and it does not 5121 // handles unexpected data without causing assert failures and it does not
5105 // do any heap allocations. This is useful when printing stack traces. 5122 // do any heap allocations. This is useful when printing stack traces.
5106 SmartPointer<char> ToCString(AllowNullsFlag allow_nulls, 5123 SmartPointer<char> ToCString(AllowNullsFlag allow_nulls,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5258 unsigned* remaining, 5275 unsigned* remaining,
5259 unsigned* offset); 5276 unsigned* offset);
5260 5277
5261 // Helper function for flattening strings. 5278 // Helper function for flattening strings.
5262 template <typename sinkchar> 5279 template <typename sinkchar>
5263 static void WriteToFlat(String* source, 5280 static void WriteToFlat(String* source,
5264 sinkchar* sink, 5281 sinkchar* sink,
5265 int from, 5282 int from,
5266 int to); 5283 int to);
5267 5284
5285 static inline bool IsAscii(const char* chars, int length) {
5286 const char* limit = chars + length;
5287 #ifdef V8_HOST_CAN_READ_UNALIGNED
5288 ASSERT(kMaxAsciiCharCode == 0x7F);
5289 const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80;
5290 while (chars <= limit - sizeof(uintptr_t)) {
5291 if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) {
5292 return false;
5293 }
5294 chars += sizeof(uintptr_t);
5295 }
5296 #endif
5297 while (chars < limit) {
5298 if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return false;
5299 ++chars;
5300 }
5301 return true;
5302 }
5303
5304 static inline bool IsAscii(const uc16* chars, int length) {
5305 const uc16* limit = chars + length;
5306 while (chars < limit) {
5307 if (*chars > kMaxAsciiCharCodeU) return false;
5308 ++chars;
5309 }
5310 return true;
5311 }
5312
5268 protected: 5313 protected:
5269 class ReadBlockBuffer { 5314 class ReadBlockBuffer {
5270 public: 5315 public:
5271 ReadBlockBuffer(unibrow::byte* util_buffer_, 5316 ReadBlockBuffer(unibrow::byte* util_buffer_,
5272 unsigned cursor_, 5317 unsigned cursor_,
5273 unsigned capacity_, 5318 unsigned capacity_,
5274 unsigned remaining_) : 5319 unsigned remaining_) :
5275 util_buffer(util_buffer_), 5320 util_buffer(util_buffer_),
5276 cursor(cursor_), 5321 cursor(cursor_),
5277 capacity(capacity_), 5322 capacity(capacity_),
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
5696 static const int kToStringOffset = HeapObject::kHeaderSize; 5741 static const int kToStringOffset = HeapObject::kHeaderSize;
5697 static const int kToNumberOffset = kToStringOffset + kPointerSize; 5742 static const int kToNumberOffset = kToStringOffset + kPointerSize;
5698 static const int kKindOffset = kToNumberOffset + kPointerSize; 5743 static const int kKindOffset = kToNumberOffset + kPointerSize;
5699 static const int kSize = kKindOffset + kPointerSize; 5744 static const int kSize = kKindOffset + kPointerSize;
5700 5745
5701 static const byte kFalse = 0; 5746 static const byte kFalse = 0;
5702 static const byte kTrue = 1; 5747 static const byte kTrue = 1;
5703 static const byte kNotBooleanMask = ~1; 5748 static const byte kNotBooleanMask = ~1;
5704 static const byte kTheHole = 2; 5749 static const byte kTheHole = 2;
5705 static const byte kNull = 3; 5750 static const byte kNull = 3;
5706 static const byte kUndefined = 4; 5751 static const byte kArgumentMarker = 4;
5707 static const byte kOther = 5; 5752 static const byte kUndefined = 5;
5753 static const byte kOther = 6;
5708 5754
5709 typedef FixedBodyDescriptor<kToStringOffset, 5755 typedef FixedBodyDescriptor<kToStringOffset,
5710 kToNumberOffset + kPointerSize, 5756 kToNumberOffset + kPointerSize,
5711 kSize> BodyDescriptor; 5757 kSize> BodyDescriptor;
5712 5758
5713 private: 5759 private:
5714 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); 5760 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball);
5715 }; 5761 };
5716 5762
5717 5763
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
6378 } else { 6424 } else {
6379 value &= ~(1 << bit_position); 6425 value &= ~(1 << bit_position);
6380 } 6426 }
6381 return value; 6427 return value;
6382 } 6428 }
6383 }; 6429 };
6384 6430
6385 } } // namespace v8::internal 6431 } } // namespace v8::internal
6386 6432
6387 #endif // V8_OBJECTS_H_ 6433 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698