00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef V8_OBJECTS_H_
00029 #define V8_OBJECTS_H_
00030
00031 #include "builtins.h"
00032 #include "code-stubs.h"
00033 #include "smart-pointer.h"
00034 #include "unicode-inl.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 enum PropertyAttributes {
00101 NONE = v8::None,
00102 READ_ONLY = v8::ReadOnly,
00103 DONT_ENUM = v8::DontEnum,
00104 DONT_DELETE = v8::DontDelete,
00105 ABSENT = 16
00106
00107
00108
00109 };
00110
00111 namespace v8 { namespace internal {
00112
00113
00114
00115
00116 class PropertyDetails BASE_EMBEDDED {
00117 public:
00118
00119 PropertyDetails(PropertyAttributes attributes,
00120 PropertyType type,
00121 int index = 0) {
00122 ASSERT(TypeField::is_valid(type));
00123 ASSERT(AttributesField::is_valid(attributes));
00124 ASSERT(IndexField::is_valid(index));
00125
00126 value_ = TypeField::encode(type)
00127 | AttributesField::encode(attributes)
00128 | IndexField::encode(index);
00129
00130 ASSERT(type == this->type());
00131 ASSERT(attributes == this->attributes());
00132 ASSERT(index == this->index());
00133 }
00134
00135
00136 inline PropertyDetails(Smi* smi);
00137 inline Smi* AsSmi();
00138
00139 PropertyType type() { return TypeField::decode(value_); }
00140
00141 bool IsTransition() {
00142 PropertyType t = type();
00143 ASSERT(t != INTERCEPTOR);
00144 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION;
00145 }
00146
00147 PropertyAttributes attributes() { return AttributesField::decode(value_); }
00148
00149 int index() { return IndexField::decode(value_); }
00150
00151 static bool IsValidIndex(int index) { return IndexField::is_valid(index); }
00152
00153 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; }
00154 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; }
00155 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; }
00156
00157
00158
00159 class TypeField: public BitField<PropertyType, 0, 3> {};
00160 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
00161 class IndexField: public BitField<uint32_t, 6, 32-6> {};
00162
00163 static const int kInitialIndex = 1;
00164
00165 private:
00166 uint32_t value_;
00167 };
00168
00169
00170 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER };
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 #define INSTANCE_TYPE_LIST(V) \
00197 V(SHORT_SYMBOL_TYPE) \
00198 V(MEDIUM_SYMBOL_TYPE) \
00199 V(LONG_SYMBOL_TYPE) \
00200 V(SHORT_ASCII_SYMBOL_TYPE) \
00201 V(MEDIUM_ASCII_SYMBOL_TYPE) \
00202 V(LONG_ASCII_SYMBOL_TYPE) \
00203 V(SHORT_CONS_SYMBOL_TYPE) \
00204 V(MEDIUM_CONS_SYMBOL_TYPE) \
00205 V(LONG_CONS_SYMBOL_TYPE) \
00206 V(SHORT_CONS_ASCII_SYMBOL_TYPE) \
00207 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE) \
00208 V(LONG_CONS_ASCII_SYMBOL_TYPE) \
00209 V(SHORT_SLICED_SYMBOL_TYPE) \
00210 V(MEDIUM_SLICED_SYMBOL_TYPE) \
00211 V(LONG_SLICED_SYMBOL_TYPE) \
00212 V(SHORT_SLICED_ASCII_SYMBOL_TYPE) \
00213 V(MEDIUM_SLICED_ASCII_SYMBOL_TYPE) \
00214 V(LONG_SLICED_ASCII_SYMBOL_TYPE) \
00215 V(SHORT_EXTERNAL_SYMBOL_TYPE) \
00216 V(MEDIUM_EXTERNAL_SYMBOL_TYPE) \
00217 V(LONG_EXTERNAL_SYMBOL_TYPE) \
00218 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE) \
00219 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE) \
00220 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE) \
00221 V(SHORT_STRING_TYPE) \
00222 V(MEDIUM_STRING_TYPE) \
00223 V(LONG_STRING_TYPE) \
00224 V(SHORT_ASCII_STRING_TYPE) \
00225 V(MEDIUM_ASCII_STRING_TYPE) \
00226 V(LONG_ASCII_STRING_TYPE) \
00227 V(SHORT_CONS_STRING_TYPE) \
00228 V(MEDIUM_CONS_STRING_TYPE) \
00229 V(LONG_CONS_STRING_TYPE) \
00230 V(SHORT_CONS_ASCII_STRING_TYPE) \
00231 V(MEDIUM_CONS_ASCII_STRING_TYPE) \
00232 V(LONG_CONS_ASCII_STRING_TYPE) \
00233 V(SHORT_SLICED_STRING_TYPE) \
00234 V(MEDIUM_SLICED_STRING_TYPE) \
00235 V(LONG_SLICED_STRING_TYPE) \
00236 V(SHORT_SLICED_ASCII_STRING_TYPE) \
00237 V(MEDIUM_SLICED_ASCII_STRING_TYPE) \
00238 V(LONG_SLICED_ASCII_STRING_TYPE) \
00239 V(SHORT_EXTERNAL_STRING_TYPE) \
00240 V(MEDIUM_EXTERNAL_STRING_TYPE) \
00241 V(LONG_EXTERNAL_STRING_TYPE) \
00242 V(SHORT_EXTERNAL_ASCII_STRING_TYPE) \
00243 V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE) \
00244 V(LONG_EXTERNAL_ASCII_STRING_TYPE) \
00245 V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \
00246 \
00247 V(MAP_TYPE) \
00248 V(HEAP_NUMBER_TYPE) \
00249 V(FIXED_ARRAY_TYPE) \
00250 V(CODE_TYPE) \
00251 V(ODDBALL_TYPE) \
00252 V(PROXY_TYPE) \
00253 V(BYTE_ARRAY_TYPE) \
00254 V(FILLER_TYPE) \
00255 \
00256 V(ACCESSOR_INFO_TYPE) \
00257 V(ACCESS_CHECK_INFO_TYPE) \
00258 V(INTERCEPTOR_INFO_TYPE) \
00259 V(SHARED_FUNCTION_INFO_TYPE) \
00260 V(CALL_HANDLER_INFO_TYPE) \
00261 V(FUNCTION_TEMPLATE_INFO_TYPE) \
00262 V(OBJECT_TEMPLATE_INFO_TYPE) \
00263 V(SIGNATURE_INFO_TYPE) \
00264 V(TYPE_SWITCH_INFO_TYPE) \
00265 V(DEBUG_INFO_TYPE) \
00266 V(BREAK_POINT_INFO_TYPE) \
00267 V(SCRIPT_TYPE) \
00268 \
00269 V(JS_VALUE_TYPE) \
00270 V(JS_OBJECT_TYPE) \
00271 V(JS_GLOBAL_OBJECT_TYPE) \
00272 V(JS_BUILTINS_OBJECT_TYPE) \
00273 V(JS_GLOBAL_PROXY_TYPE) \
00274 V(JS_ARRAY_TYPE) \
00275 V(JS_REGEXP_TYPE) \
00276 \
00277 V(JS_FUNCTION_TYPE) \
00278
00279
00280
00281
00282 #define STRING_TYPE_LIST(V) \
00283 V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, short_symbol) \
00284 V(MEDIUM_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, medium_symbol) \
00285 V(LONG_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, long_symbol) \
00286 V(SHORT_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, short_ascii_symbol) \
00287 V(MEDIUM_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_symbol)\
00288 V(LONG_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, long_ascii_symbol) \
00289 V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol) \
00290 V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol) \
00291 V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol) \
00292 V(SHORT_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, short_cons_ascii_symbol) \
00293 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, medium_cons_ascii_symbol)\
00294 V(LONG_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, long_cons_ascii_symbol) \
00295 V(SHORT_SLICED_SYMBOL_TYPE, SlicedString::kSize, short_sliced_symbol) \
00296 V(MEDIUM_SLICED_SYMBOL_TYPE, SlicedString::kSize, medium_sliced_symbol) \
00297 V(LONG_SLICED_SYMBOL_TYPE, SlicedString::kSize, long_sliced_symbol) \
00298 V(SHORT_SLICED_ASCII_SYMBOL_TYPE, \
00299 SlicedString::kSize, \
00300 short_sliced_ascii_symbol) \
00301 V(MEDIUM_SLICED_ASCII_SYMBOL_TYPE, \
00302 SlicedString::kSize, \
00303 medium_sliced_ascii_symbol) \
00304 V(LONG_SLICED_ASCII_SYMBOL_TYPE, \
00305 SlicedString::kSize, \
00306 long_sliced_ascii_symbol) \
00307 V(SHORT_EXTERNAL_SYMBOL_TYPE, \
00308 ExternalTwoByteString::kSize, \
00309 short_external_symbol) \
00310 V(MEDIUM_EXTERNAL_SYMBOL_TYPE, \
00311 ExternalTwoByteString::kSize, \
00312 medium_external_symbol) \
00313 V(LONG_EXTERNAL_SYMBOL_TYPE, \
00314 ExternalTwoByteString::kSize, \
00315 long_external_symbol) \
00316 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \
00317 ExternalAsciiString::kSize, \
00318 short_external_ascii_symbol) \
00319 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE, \
00320 ExternalAsciiString::kSize, \
00321 medium_external_ascii_symbol) \
00322 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \
00323 ExternalAsciiString::kSize, \
00324 long_external_ascii_symbol) \
00325 V(SHORT_STRING_TYPE, SeqTwoByteString::kHeaderSize, short_string) \
00326 V(MEDIUM_STRING_TYPE, SeqTwoByteString::kHeaderSize, medium_string) \
00327 V(LONG_STRING_TYPE, SeqTwoByteString::kHeaderSize, long_string) \
00328 V(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, short_ascii_string) \
00329 V(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_string)\
00330 V(LONG_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, long_ascii_string) \
00331 V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string) \
00332 V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string) \
00333 V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string) \
00334 V(SHORT_CONS_ASCII_STRING_TYPE, ConsString::kSize, short_cons_ascii_string) \
00335 V(MEDIUM_CONS_ASCII_STRING_TYPE, ConsString::kSize, medium_cons_ascii_string)\
00336 V(LONG_CONS_ASCII_STRING_TYPE, ConsString::kSize, long_cons_ascii_string) \
00337 V(SHORT_SLICED_STRING_TYPE, SlicedString::kSize, short_sliced_string) \
00338 V(MEDIUM_SLICED_STRING_TYPE, SlicedString::kSize, medium_sliced_string) \
00339 V(LONG_SLICED_STRING_TYPE, SlicedString::kSize, long_sliced_string) \
00340 V(SHORT_SLICED_ASCII_STRING_TYPE, \
00341 SlicedString::kSize, \
00342 short_sliced_ascii_string) \
00343 V(MEDIUM_SLICED_ASCII_STRING_TYPE, \
00344 SlicedString::kSize, \
00345 medium_sliced_ascii_string) \
00346 V(LONG_SLICED_ASCII_STRING_TYPE, \
00347 SlicedString::kSize, \
00348 long_sliced_ascii_string) \
00349 V(SHORT_EXTERNAL_STRING_TYPE, \
00350 ExternalTwoByteString::kSize, \
00351 short_external_string) \
00352 V(MEDIUM_EXTERNAL_STRING_TYPE, \
00353 ExternalTwoByteString::kSize, \
00354 medium_external_string) \
00355 V(LONG_EXTERNAL_STRING_TYPE, \
00356 ExternalTwoByteString::kSize, \
00357 long_external_string) \
00358 V(SHORT_EXTERNAL_ASCII_STRING_TYPE, \
00359 ExternalAsciiString::kSize, \
00360 short_external_ascii_string) \
00361 V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE, \
00362 ExternalAsciiString::kSize, \
00363 medium_external_ascii_string) \
00364 V(LONG_EXTERNAL_ASCII_STRING_TYPE, \
00365 ExternalAsciiString::kSize, \
00366 long_external_ascii_string)
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377 #define STRUCT_LIST(V) \
00378 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \
00379 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
00380 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
00381 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
00382 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
00383 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
00384 V(SIGNATURE_INFO, SignatureInfo, signature_info) \
00385 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
00386 V(DEBUG_INFO, DebugInfo, debug_info) \
00387 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \
00388 V(SCRIPT, Script, script)
00389
00390
00391
00392
00393
00394 const uint32_t kIsNotStringMask = 0x80;
00395 const uint32_t kStringTag = 0x0;
00396 const uint32_t kNotStringTag = 0x80;
00397
00398
00399
00400 const uint32_t kIsSymbolMask = 0x20;
00401 const uint32_t kNotSymbolTag = 0x0;
00402 const uint32_t kSymbolTag = 0x20;
00403
00404
00405
00406
00407
00408 const uint32_t kStringSizeMask = 0x18;
00409 const uint32_t kShortStringTag = 0x18;
00410 const uint32_t kMediumStringTag = 0x10;
00411 const uint32_t kLongStringTag = 0x00;
00412
00413
00414
00415 const uint32_t kStringEncodingMask = 0x4;
00416 const uint32_t kTwoByteStringTag = 0x0;
00417 const uint32_t kAsciiStringTag = 0x4;
00418
00419
00420
00421 const uint32_t kStringRepresentationMask = 0x03;
00422 enum StringRepresentationTag {
00423 kSeqStringTag = 0x0,
00424 kConsStringTag = 0x1,
00425 kSlicedStringTag = 0x2,
00426 kExternalStringTag = 0x3
00427 };
00428
00429 enum InstanceType {
00430 SHORT_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSeqStringTag,
00431 MEDIUM_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSeqStringTag,
00432 LONG_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kSeqStringTag,
00433 SHORT_ASCII_SYMBOL_TYPE =
00434 kShortStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag,
00435 MEDIUM_ASCII_SYMBOL_TYPE =
00436 kMediumStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag,
00437 LONG_ASCII_SYMBOL_TYPE =
00438 kLongStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag,
00439 SHORT_CONS_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kConsStringTag,
00440 MEDIUM_CONS_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kConsStringTag,
00441 LONG_CONS_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kConsStringTag,
00442 SHORT_CONS_ASCII_SYMBOL_TYPE =
00443 kShortStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag,
00444 MEDIUM_CONS_ASCII_SYMBOL_TYPE =
00445 kMediumStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag,
00446 LONG_CONS_ASCII_SYMBOL_TYPE =
00447 kLongStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag,
00448 SHORT_SLICED_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSlicedStringTag,
00449 MEDIUM_SLICED_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSlicedStringTag,
00450 LONG_SLICED_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kSlicedStringTag,
00451 SHORT_SLICED_ASCII_SYMBOL_TYPE =
00452 kShortStringTag | kAsciiStringTag | kSymbolTag | kSlicedStringTag,
00453 MEDIUM_SLICED_ASCII_SYMBOL_TYPE =
00454 kMediumStringTag | kAsciiStringTag | kSymbolTag | kSlicedStringTag,
00455 LONG_SLICED_ASCII_SYMBOL_TYPE =
00456 kLongStringTag | kAsciiStringTag | kSymbolTag | kSlicedStringTag,
00457 SHORT_EXTERNAL_SYMBOL_TYPE =
00458 kShortStringTag | kSymbolTag | kExternalStringTag,
00459 MEDIUM_EXTERNAL_SYMBOL_TYPE =
00460 kMediumStringTag | kSymbolTag | kExternalStringTag,
00461 LONG_EXTERNAL_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kExternalStringTag,
00462 SHORT_EXTERNAL_ASCII_SYMBOL_TYPE =
00463 kShortStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag,
00464 MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE =
00465 kMediumStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag,
00466 LONG_EXTERNAL_ASCII_SYMBOL_TYPE =
00467 kLongStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag,
00468 SHORT_STRING_TYPE = kShortStringTag | kSeqStringTag,
00469 MEDIUM_STRING_TYPE = kMediumStringTag | kSeqStringTag,
00470 LONG_STRING_TYPE = kLongStringTag | kSeqStringTag,
00471 SHORT_ASCII_STRING_TYPE = kShortStringTag | kAsciiStringTag | kSeqStringTag,
00472 MEDIUM_ASCII_STRING_TYPE = kMediumStringTag | kAsciiStringTag | kSeqStringTag,
00473 LONG_ASCII_STRING_TYPE = kLongStringTag | kAsciiStringTag | kSeqStringTag,
00474 SHORT_CONS_STRING_TYPE = kShortStringTag | kConsStringTag,
00475 MEDIUM_CONS_STRING_TYPE = kMediumStringTag | kConsStringTag,
00476 LONG_CONS_STRING_TYPE = kLongStringTag | kConsStringTag,
00477 SHORT_CONS_ASCII_STRING_TYPE =
00478 kShortStringTag | kAsciiStringTag | kConsStringTag,
00479 MEDIUM_CONS_ASCII_STRING_TYPE =
00480 kMediumStringTag | kAsciiStringTag | kConsStringTag,
00481 LONG_CONS_ASCII_STRING_TYPE =
00482 kLongStringTag | kAsciiStringTag | kConsStringTag,
00483 SHORT_SLICED_STRING_TYPE = kShortStringTag | kSlicedStringTag,
00484 MEDIUM_SLICED_STRING_TYPE = kMediumStringTag | kSlicedStringTag,
00485 LONG_SLICED_STRING_TYPE = kLongStringTag | kSlicedStringTag,
00486 SHORT_SLICED_ASCII_STRING_TYPE =
00487 kShortStringTag | kAsciiStringTag | kSlicedStringTag,
00488 MEDIUM_SLICED_ASCII_STRING_TYPE =
00489 kMediumStringTag | kAsciiStringTag | kSlicedStringTag,
00490 LONG_SLICED_ASCII_STRING_TYPE =
00491 kLongStringTag | kAsciiStringTag | kSlicedStringTag,
00492 SHORT_EXTERNAL_STRING_TYPE = kShortStringTag | kExternalStringTag,
00493 MEDIUM_EXTERNAL_STRING_TYPE = kMediumStringTag | kExternalStringTag,
00494 LONG_EXTERNAL_STRING_TYPE = kLongStringTag | kExternalStringTag,
00495 SHORT_EXTERNAL_ASCII_STRING_TYPE =
00496 kShortStringTag | kAsciiStringTag | kExternalStringTag,
00497 MEDIUM_EXTERNAL_ASCII_STRING_TYPE =
00498 kMediumStringTag | kAsciiStringTag | kExternalStringTag,
00499 LONG_EXTERNAL_ASCII_STRING_TYPE =
00500 kLongStringTag | kAsciiStringTag | kExternalStringTag,
00501 LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE = LONG_EXTERNAL_ASCII_STRING_TYPE,
00502
00503 MAP_TYPE = kNotStringTag,
00504 HEAP_NUMBER_TYPE,
00505 FIXED_ARRAY_TYPE,
00506 CODE_TYPE,
00507 ODDBALL_TYPE,
00508 PROXY_TYPE,
00509 BYTE_ARRAY_TYPE,
00510 FILLER_TYPE,
00511 SMI_TYPE,
00512
00513 ACCESSOR_INFO_TYPE,
00514 ACCESS_CHECK_INFO_TYPE,
00515 INTERCEPTOR_INFO_TYPE,
00516 SHARED_FUNCTION_INFO_TYPE,
00517 CALL_HANDLER_INFO_TYPE,
00518 FUNCTION_TEMPLATE_INFO_TYPE,
00519 OBJECT_TEMPLATE_INFO_TYPE,
00520 SIGNATURE_INFO_TYPE,
00521 TYPE_SWITCH_INFO_TYPE,
00522 DEBUG_INFO_TYPE,
00523 BREAK_POINT_INFO_TYPE,
00524 SCRIPT_TYPE,
00525
00526 JS_VALUE_TYPE,
00527 JS_OBJECT_TYPE,
00528 JS_GLOBAL_OBJECT_TYPE,
00529 JS_BUILTINS_OBJECT_TYPE,
00530 JS_GLOBAL_PROXY_TYPE,
00531 JS_ARRAY_TYPE,
00532 JS_REGEXP_TYPE,
00533
00534 JS_FUNCTION_TYPE,
00535
00536
00537 FIRST_NONSTRING_TYPE = MAP_TYPE,
00538 FIRST_TYPE = 0x0,
00539 INVALID_TYPE = FIRST_TYPE - 1,
00540 LAST_TYPE = JS_FUNCTION_TYPE,
00541
00542
00543
00544 FIRST_JS_OBJECT_TYPE = JS_VALUE_TYPE,
00545 LAST_JS_OBJECT_TYPE = JS_REGEXP_TYPE
00546 };
00547
00548
00549 enum CompareResult {
00550 LESS = -1,
00551 EQUAL = 0,
00552 GREATER = 1,
00553
00554 NOT_EQUAL = GREATER
00555 };
00556
00557
00558 #define DECL_BOOLEAN_ACCESSORS(name) \
00559 inline bool name(); \
00560 inline void set_##name(bool value); \
00561
00562
00563 #define DECL_ACCESSORS(name, type) \
00564 inline type* name(); \
00565 inline void set_##name(type* value, \
00566 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
00567
00568
00569 class StringStream;
00570 class ObjectVisitor;
00571
00572 struct ValueInfo : public Malloced {
00573 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { }
00574 InstanceType type;
00575 Object* ptr;
00576 const char* str;
00577 double number;
00578 };
00579
00580
00581
00582 template <class C> static inline bool Is(Object* obj);
00583
00584
00585
00586
00587
00588
00589
00590
00591 class Object BASE_EMBEDDED {
00592 public:
00593
00594 inline bool IsSmi();
00595 inline bool IsHeapObject();
00596 inline bool IsHeapNumber();
00597 inline bool IsString();
00598 inline bool IsSeqString();
00599 inline bool IsAsciiStringRepresentation();
00600 inline bool IsTwoByteStringRepresentation();
00601 inline bool IsSeqAsciiString();
00602 inline bool IsSeqTwoByteString();
00603 inline bool IsConsString();
00604 inline bool IsSlicedString();
00605 inline bool IsExternalString();
00606 inline bool IsExternalAsciiString();
00607 inline bool IsExternalTwoByteString();
00608 inline bool IsShortString();
00609 inline bool IsMediumString();
00610 inline bool IsLongString();
00611 inline bool IsSymbol();
00612 inline bool IsNumber();
00613 inline bool IsByteArray();
00614 inline bool IsFailure();
00615 inline bool IsRetryAfterGC();
00616 inline bool IsOutOfMemoryFailure();
00617 inline bool IsException();
00618 inline bool IsJSObject();
00619 inline bool IsMap();
00620 inline bool IsFixedArray();
00621 inline bool IsDescriptorArray();
00622 inline bool IsContext();
00623 inline bool IsGlobalContext();
00624 inline bool IsJSFunction();
00625 inline bool IsCode();
00626 inline bool IsOddball();
00627 inline bool IsSharedFunctionInfo();
00628 inline bool IsJSValue();
00629 inline bool IsStringWrapper();
00630 inline bool IsProxy();
00631 inline bool IsBoolean();
00632 inline bool IsJSArray();
00633 inline bool IsJSRegExp();
00634 inline bool IsHashTable();
00635 inline bool IsDictionary();
00636 inline bool IsSymbolTable();
00637 inline bool IsCompilationCacheTable();
00638 inline bool IsMapCache();
00639 inline bool IsLookupCache();
00640 inline bool IsPrimitive();
00641 inline bool IsGlobalObject();
00642 inline bool IsJSGlobalObject();
00643 inline bool IsJSBuiltinsObject();
00644 inline bool IsJSGlobalProxy();
00645 inline bool IsUndetectableObject();
00646 inline bool IsAccessCheckNeeded();
00647
00648
00649
00650 bool IsInstanceOf(FunctionTemplateInfo* type);
00651
00652 inline bool IsStruct();
00653 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
00654 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
00655 #undef DECLARE_STRUCT_PREDICATE
00656
00657
00658 INLINE(bool IsUndefined());
00659 INLINE(bool IsTheHole());
00660 INLINE(bool IsNull());
00661 INLINE(bool IsTrue());
00662 INLINE(bool IsFalse());
00663
00664
00665 inline double Number();
00666
00667 inline bool HasSpecificClassOf(String* name);
00668
00669 Object* ToObject();
00670 Object* ToBoolean();
00671
00672
00673
00674 Object* ToObject(Context* global_context);
00675
00676
00677
00678 inline Object* ToSmi();
00679
00680 void Lookup(String* name, LookupResult* result);
00681
00682
00683 inline Object* GetProperty(String* key);
00684 inline Object* GetProperty(String* key, PropertyAttributes* attributes);
00685 Object* GetPropertyWithReceiver(Object* receiver,
00686 String* key,
00687 PropertyAttributes* attributes);
00688 Object* GetProperty(Object* receiver,
00689 LookupResult* result,
00690 String* key,
00691 PropertyAttributes* attributes);
00692 Object* GetPropertyWithCallback(Object* receiver,
00693 Object* structure,
00694 String* name,
00695 Object* holder);
00696
00697 inline Object* GetElement(uint32_t index);
00698 Object* GetElementWithReceiver(Object* receiver, uint32_t index);
00699
00700
00701 Object* GetPrototype();
00702
00703
00704
00705 inline bool IsStringObjectWithCharacterAt(uint32_t index);
00706
00707 #ifdef DEBUG
00708
00709 void Print();
00710 void PrintLn();
00711
00712 void Verify();
00713
00714
00715 static void VerifyPointer(Object* p);
00716 #endif
00717
00718
00719 void ShortPrint();
00720
00721
00722 void ShortPrint(StringStream* accumulator);
00723
00724
00725 static Object* cast(Object* value) { return value; }
00726
00727
00728 static const int kHeaderSize = 0;
00729
00730 private:
00731 DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
00732 };
00733
00734
00735
00736
00737
00738
00739 class Smi: public Object {
00740 public:
00741
00742 inline int value();
00743
00744
00745 static inline Smi* FromInt(int value);
00746
00747
00748 static inline bool IsValid(int value);
00749
00750
00751 static inline Smi* cast(Object* object);
00752
00753
00754 void SmiPrint();
00755 void SmiPrint(StringStream* accumulator);
00756 #ifdef DEBUG
00757 void SmiVerify();
00758 #endif
00759
00760
00761 static const int kMinValue = -(1 << (kBitsPerPointer - (kSmiTagSize + 1)));
00762 static const int kMaxValue = (1 << (kBitsPerPointer - (kSmiTagSize + 1))) - 1;
00763
00764 private:
00765 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi);
00766 };
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801 const int kFailureTypeTagSize = 2;
00802 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1;
00803
00804 class Failure: public Object {
00805 public:
00806
00807 enum Type {
00808 RETRY_AFTER_GC = 0,
00809 EXCEPTION = 1,
00810
00811 INTERNAL_ERROR = 2,
00812 OUT_OF_MEMORY_EXCEPTION = 3
00813 };
00814
00815 inline Type type() const;
00816
00817
00818 inline AllocationSpace allocation_space() const;
00819
00820
00821
00822 inline int requested() const;
00823
00824 inline bool IsInternalError() const;
00825 inline bool IsOutOfMemoryException() const;
00826
00827 static Failure* RetryAfterGC(int requested_bytes, AllocationSpace space);
00828 static inline Failure* RetryAfterGC(int requested_bytes);
00829 static inline Failure* Exception();
00830 static inline Failure* InternalError();
00831 static inline Failure* OutOfMemoryException();
00832
00833 static inline Failure* cast(Object* object);
00834
00835
00836 void FailurePrint();
00837 void FailurePrint(StringStream* accumulator);
00838 #ifdef DEBUG
00839 void FailureVerify();
00840 #endif
00841
00842 private:
00843 inline int value() const;
00844 static inline Failure* Construct(Type type, int value = 0);
00845
00846 DISALLOW_IMPLICIT_CONSTRUCTORS(Failure);
00847 };
00848
00849
00850
00851
00852
00853
00854 class MapWord BASE_EMBEDDED {
00855 public:
00856
00857
00858
00859 static inline MapWord FromMap(Map* map);
00860
00861
00862 inline Map* ToMap();
00863
00864
00865
00866
00867
00868
00869
00870
00871 inline bool IsForwardingAddress();
00872
00873
00874 static inline MapWord FromForwardingAddress(HeapObject* object);
00875
00876
00877 inline HeapObject* ToForwardingAddress();
00878
00879
00880
00881
00882
00883
00884
00885
00886 inline bool IsMarked();
00887
00888
00889 inline void SetMark();
00890
00891
00892 inline void ClearMark();
00893
00894
00895 inline bool IsOverflowed();
00896
00897
00898 inline void SetOverflow();
00899
00900
00901 inline void ClearOverflow();
00902
00903
00904
00905
00906
00907
00908
00909
00910 static inline MapWord EncodeAddress(Address map_address, int offset);
00911
00912
00913 inline Address DecodeMapAddress(MapSpace* map_space);
00914
00915
00916 inline int DecodeOffset();
00917
00918
00919
00920
00921
00922
00923
00924 static inline MapWord FromEncodedAddress(Address address);
00925
00926 inline Address ToEncodedAddress();
00927
00928 private:
00929
00930 friend class HeapObject;
00931
00932 explicit MapWord(uintptr_t value) : value_(value) {}
00933
00934 uintptr_t value_;
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945 static const int kMarkingBit = 0;
00946 static const int kMarkingMask = (1 << kMarkingBit);
00947 static const int kOverflowBit = 1;
00948 static const int kOverflowMask = (1 << kOverflowBit);
00949
00950
00951
00952
00953
00954
00955
00956 static const int kMapPageIndexBits = 10;
00957 static const int kMapPageOffsetBits = 11;
00958 static const int kForwardingOffsetBits = 11;
00959
00960 static const int kMapPageIndexShift = 0;
00961 static const int kMapPageOffsetShift =
00962 kMapPageIndexShift + kMapPageIndexBits;
00963 static const int kForwardingOffsetShift =
00964 kMapPageOffsetShift + kMapPageOffsetBits;
00965
00966
00967 static const uint32_t kMapPageIndexMask =
00968 (1 << kMapPageOffsetShift) - 1;
00969
00970
00971 static const uint32_t kMapPageOffsetMask =
00972 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask;
00973
00974
00975 static const uint32_t kForwardingOffsetMask =
00976 ~(kMapPageIndexMask | kMapPageOffsetMask);
00977 };
00978
00979
00980
00981
00982 class HeapObject: public Object {
00983 public:
00984
00985
00986 inline Map* map();
00987 inline void set_map(Map* value);
00988
00989
00990
00991 inline MapWord map_word();
00992 inline void set_map_word(MapWord map_word);
00993
00994
00995 static inline HeapObject* FromAddress(Address address);
00996
00997
00998 inline Address address();
00999
01000
01001 void Iterate(ObjectVisitor* v);
01002
01003
01004
01005
01006
01007 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v);
01008
01009
01010
01011 void IterateStructBody(int object_size, ObjectVisitor* v);
01012
01013
01014 inline int Size();
01015
01016
01017
01018
01019 inline int SizeFromMap(Map* map);
01020
01021
01022
01023 inline bool IsMarked();
01024
01025
01026 inline void SetMark();
01027
01028
01029
01030 inline void ClearMark();
01031
01032
01033
01034
01035
01036 inline bool IsOverflowed();
01037
01038
01039
01040 inline void SetOverflow();
01041
01042
01043
01044 inline void ClearOverflow();
01045
01046
01047
01048
01049
01050 static inline Object** RawField(HeapObject* obj, int offset);
01051
01052
01053 static inline HeapObject* cast(Object* obj);
01054
01055
01056 inline WriteBarrierMode GetWriteBarrierMode();
01057
01058
01059 void HeapObjectShortPrint(StringStream* accumulator);
01060 #ifdef DEBUG
01061 void HeapObjectPrint();
01062 void HeapObjectVerify();
01063 inline void VerifyObjectField(int offset);
01064
01065 void PrintHeader(const char* id);
01066
01067
01068
01069 static void VerifyHeapPointer(Object* p);
01070 #endif
01071
01072
01073
01074 static const int kMapOffset = Object::kHeaderSize;
01075 static const int kHeaderSize = kMapOffset + kPointerSize;
01076
01077 protected:
01078
01079
01080 inline void IteratePointers(ObjectVisitor* v, int start, int end);
01081
01082 inline void IteratePointer(ObjectVisitor* v, int offset);
01083
01084
01085
01086 int SlowSizeFromMap(Map* map);
01087
01088 private:
01089 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject);
01090 };
01091
01092
01093
01094
01095 class HeapNumber: public HeapObject {
01096 public:
01097
01098 inline double value();
01099 inline void set_value(double value);
01100
01101
01102 static inline HeapNumber* cast(Object* obj);
01103
01104
01105 Object* HeapNumberToBoolean();
01106 void HeapNumberPrint();
01107 void HeapNumberPrint(StringStream* accumulator);
01108 #ifdef DEBUG
01109 void HeapNumberVerify();
01110 #endif
01111
01112
01113 static const int kValueOffset = HeapObject::kHeaderSize;
01114 static const int kSize = kValueOffset + kDoubleSize;
01115
01116 private:
01117 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);
01118 };
01119
01120
01121
01122
01123
01124
01125 class JSObject: public HeapObject {
01126 public:
01127
01128
01129
01130 DECL_ACCESSORS(properties, FixedArray)
01131 inline void initialize_properties();
01132 inline bool HasFastProperties();
01133 inline Dictionary* property_dictionary();
01134
01135
01136
01137
01138 DECL_ACCESSORS(elements, FixedArray)
01139 inline void initialize_elements();
01140 inline bool HasFastElements();
01141 inline Dictionary* element_dictionary();
01142
01143 Object* SetProperty(String* key,
01144 Object* value,
01145 PropertyAttributes attributes);
01146 Object* SetProperty(LookupResult* result,
01147 String* key,
01148 Object* value,
01149 PropertyAttributes attributes);
01150 Object* SetPropertyWithFailedAccessCheck(LookupResult* result,
01151 String* name,
01152 Object* value);
01153 Object* SetPropertyWithCallback(Object* structure,
01154 String* name,
01155 Object* value,
01156 JSObject* holder);
01157 Object* SetPropertyWithInterceptor(String* name,
01158 Object* value,
01159 PropertyAttributes attributes);
01160 Object* SetPropertyPostInterceptor(String* name,
01161 Object* value,
01162 PropertyAttributes attributes);
01163 Object* IgnoreAttributesAndSetLocalProperty(String* key,
01164 Object* value,
01165 PropertyAttributes attributes);
01166
01167
01168 Object* SetLazyProperty(LookupResult* result,
01169 String* name,
01170 Object* value,
01171 PropertyAttributes attributes);
01172
01173
01174 String* class_name();
01175
01176
01177 InterceptorInfo* GetNamedInterceptor();
01178 InterceptorInfo* GetIndexedInterceptor();
01179
01180 inline PropertyAttributes GetPropertyAttribute(String* name);
01181 PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver,
01182 String* name);
01183 PropertyAttributes GetLocalPropertyAttribute(String* name);
01184
01185 Object* DefineAccessor(String* name, bool is_getter, JSFunction* fun,
01186 PropertyAttributes attributes);
01187 Object* LookupAccessor(String* name, bool is_getter);
01188
01189
01190 Object* GetPropertyWithFailedAccessCheck(Object* receiver,
01191 LookupResult* result,
01192 String* name);
01193 Object* GetPropertyWithInterceptor(JSObject* receiver,
01194 String* name,
01195 PropertyAttributes* attributes);
01196 Object* GetPropertyPostInterceptor(JSObject* receiver,
01197 String* name,
01198 PropertyAttributes* attributes);
01199 Object* GetLazyProperty(Object* receiver,
01200 LookupResult* result,
01201 String* name,
01202 PropertyAttributes* attributes);
01203
01204 bool HasProperty(String* name) {
01205 return GetPropertyAttribute(name) != ABSENT;
01206 }
01207
01208 bool HasLocalProperty(String* name) {
01209 return GetLocalPropertyAttribute(name) != ABSENT;
01210 }
01211
01212 Object* DeleteProperty(String* name);
01213 Object* DeleteElement(uint32_t index);
01214 Object* DeleteLazyProperty(LookupResult* result, String* name);
01215
01216
01217 bool IsSimpleEnum();
01218
01219
01220
01221 bool ShouldConvertToSlowElements(int new_capacity);
01222
01223
01224
01225
01226 bool ShouldConvertToFastElements();
01227
01228
01229 inline Object* GetPrototype();
01230
01231
01232 inline bool HasElement(uint32_t index);
01233 bool HasElementWithReceiver(JSObject* receiver, uint32_t index);
01234 bool HasLocalElement(uint32_t index);
01235
01236 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index);
01237 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index);
01238
01239 Object* SetFastElement(uint32_t index, Object* value);
01240
01241
01242
01243 Object* SetElement(uint32_t index, Object* value);
01244
01245
01246
01247 Object* GetElementWithReceiver(JSObject* receiver, uint32_t index);
01248
01249 void SetFastElements(FixedArray* elements);
01250 Object* SetSlowElements(Object* length);
01251
01252
01253
01254 inline bool HasNamedInterceptor();
01255 inline bool HasIndexedInterceptor();
01256
01257
01258 bool HasRealNamedProperty(String* key);
01259 bool HasRealElementProperty(uint32_t index);
01260 bool HasRealNamedCallbackProperty(String* key);
01261
01262
01263 Object* SetElementsLength(Object* length);
01264
01265
01266
01267 inline int GetHeaderSize();
01268
01269 inline int GetInternalFieldCount();
01270 inline Object* GetInternalField(int index);
01271 inline void SetInternalField(int index, Object* value);
01272
01273
01274
01275 void LocalLookup(String* name, LookupResult* result);
01276 void Lookup(String* name, LookupResult* result);
01277
01278
01279 void LocalLookupRealNamedProperty(String* name, LookupResult* result);
01280 void LookupRealNamedProperty(String* name, LookupResult* result);
01281 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result);
01282 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result);
01283
01284
01285
01286 int NumberOfLocalProperties(PropertyAttributes filter);
01287
01288 int NumberOfEnumProperties();
01289
01290 void GetLocalPropertyNames(FixedArray* storage);
01291
01292
01293
01294 int NumberOfLocalElements(PropertyAttributes filter);
01295
01296 int NumberOfEnumElements();
01297
01298
01299 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter);
01300
01301
01302
01303
01304
01305 int GetEnumElementKeys(FixedArray* storage);
01306
01307
01308
01309 Object* AddFastPropertyUsingMap(Map* new_map,
01310 String* name,
01311 Object* value);
01312
01313
01314
01315
01316
01317
01318
01319 Object* AddConstantFunctionProperty(String* name,
01320 JSFunction* function,
01321 PropertyAttributes attributes);
01322
01323 Object* ReplaceSlowProperty(String* name,
01324 Object* value,
01325 PropertyAttributes attributes);
01326
01327
01328
01329
01330
01331
01332 Object* ConvertDescriptorToFieldAndMapTransition(
01333 String* name,
01334 Object* new_value,
01335 PropertyAttributes attributes);
01336
01337
01338
01339
01340 Object* ConvertDescriptorToField(String* name,
01341 Object* new_value,
01342 PropertyAttributes attributes);
01343
01344
01345 Object* AddFastProperty(String* name,
01346 Object* value,
01347 PropertyAttributes attributes);
01348
01349
01350 Object* AddSlowProperty(String* name,
01351 Object* value,
01352 PropertyAttributes attributes);
01353
01354
01355 Object* AddProperty(String* name,
01356 Object* value,
01357 PropertyAttributes attributes);
01358
01359
01360
01361 Object* NormalizeProperties();
01362 Object* NormalizeElements();
01363
01364
01365
01366 Object* TransformToFastProperties(int unused_property_fields);
01367
01368
01369 inline Object* FastPropertyAt(int index);
01370 inline Object* FastPropertyAtPut(int index, Object* value);
01371
01372
01373 inline Object* InObjectPropertyAtPut(int index,
01374 Object* value,
01375 WriteBarrierMode mode
01376 = UPDATE_WRITE_BARRIER);
01377
01378
01379
01380
01381
01382 inline void InitializeBody(int object_size);
01383
01384
01385 bool ReferencesObject(Object* obj);
01386
01387
01388 static inline JSObject* cast(Object* obj);
01389
01390
01391 void JSObjectIterateBody(int object_size, ObjectVisitor* v);
01392 void JSObjectShortPrint(StringStream* accumulator);
01393 #ifdef DEBUG
01394 void JSObjectPrint();
01395 void JSObjectVerify();
01396 void PrintProperties();
01397 void PrintElements();
01398
01399
01400 class SpillInformation {
01401 public:
01402 void Clear();
01403 void Print();
01404 int number_of_objects_;
01405 int number_of_objects_with_fast_properties_;
01406 int number_of_objects_with_fast_elements_;
01407 int number_of_fast_used_fields_;
01408 int number_of_fast_unused_fields_;
01409 int number_of_slow_used_properties_;
01410 int number_of_slow_unused_properties_;
01411 int number_of_fast_used_elements_;
01412 int number_of_fast_unused_elements_;
01413 int number_of_slow_used_elements_;
01414 int number_of_slow_unused_elements_;
01415 };
01416
01417 void IncrementSpillStatistics(SpillInformation* info);
01418 #endif
01419 Object* SlowReverseLookup(Object* value);
01420
01421 static const uint32_t kMaxGap = 1024;
01422 static const int kMaxFastElementsLength = 5000;
01423 static const int kMaxFastProperties = 8;
01424 static const int kMaxInstanceSize = 255 * kPointerSize;
01425
01426
01427
01428 static const int kFieldsAdded = 3;
01429
01430
01431 static const int kPropertiesOffset = HeapObject::kHeaderSize;
01432 static const int kElementsOffset = kPropertiesOffset + kPointerSize;
01433 static const int kHeaderSize = kElementsOffset + kPointerSize;
01434
01435 Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
01436
01437 private:
01438 Object* SetElementWithInterceptor(uint32_t index, Object* value);
01439 Object* SetElementPostInterceptor(uint32_t index, Object* value);
01440
01441 Object* GetElementPostInterceptor(JSObject* receiver, uint32_t index);
01442
01443 Object* DeletePropertyPostInterceptor(String* name);
01444 Object* DeletePropertyWithInterceptor(String* name);
01445
01446 Object* DeleteElementPostInterceptor(uint32_t index);
01447 Object* DeleteElementWithInterceptor(uint32_t index);
01448
01449 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
01450 String* name,
01451 bool continue_search);
01452 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver,
01453 String* name,
01454 bool continue_search);
01455 PropertyAttributes GetPropertyAttribute(JSObject* receiver,
01456 LookupResult* result,
01457 String* name,
01458 bool continue_search);
01459
01460
01461 bool HasDenseElements();
01462
01463 Object* DefineGetterSetter(String* name, PropertyAttributes attributes);
01464
01465 void LookupInDescriptor(String* name, LookupResult* result);
01466
01467 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
01468 };
01469
01470
01471
01472 class Array: public HeapObject {
01473 public:
01474
01475 inline int length();
01476 inline void set_length(int value);
01477
01478
01479
01480 static inline bool IndexFromObject(Object* object, uint32_t* index);
01481
01482
01483 static const int kLengthOffset = HeapObject::kHeaderSize;
01484 static const int kHeaderSize = kLengthOffset + kIntSize;
01485
01486 private:
01487 DISALLOW_IMPLICIT_CONSTRUCTORS(Array);
01488 };
01489
01490
01491
01492
01493
01494 class FixedArray: public Array {
01495 public:
01496
01497
01498 inline Object* get(int index);
01499 inline void set(int index, Object* value);
01500
01501
01502 inline void set(int index, Object* value, WriteBarrierMode mode);
01503
01504
01505 inline void set_undefined(int index);
01506 inline void set_null(int index);
01507 inline void set_the_hole(int index);
01508
01509
01510 inline Object* Copy();
01511 Object* CopySize(int new_length);
01512
01513
01514 Object* AddKeysFromJSArray(JSArray* array);
01515
01516
01517 Object* UnionOfKeys(FixedArray* other);
01518
01519
01520 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
01521
01522
01523 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }
01524
01525
01526 static inline FixedArray* cast(Object* obj);
01527
01528
01529 int FixedArraySize() { return SizeFor(length()); }
01530 void FixedArrayIterateBody(ObjectVisitor* v);
01531 #ifdef DEBUG
01532 void FixedArrayPrint();
01533 void FixedArrayVerify();
01534
01535 bool IsEqualTo(FixedArray* other);
01536 #endif
01537
01538
01539 void Swap(int i, int j);
01540
01541
01542 void SortPairs(FixedArray* smis);
01543
01544 protected:
01545
01546 static inline void fast_set(FixedArray* array, int index, Object* value);
01547
01548 private:
01549 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);
01550 };
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562 class DescriptorArray: public FixedArray {
01563 public:
01564
01565 inline bool IsEmpty();
01566
01567 int number_of_descriptors() {
01568 return IsEmpty() ? 0 : length() - kFirstIndex;
01569 }
01570
01571 int NextEnumerationIndex() {
01572 if (IsEmpty()) return PropertyDetails::kInitialIndex;
01573 Object* obj = get(kEnumerationIndexIndex);
01574 if (obj->IsSmi()) {
01575 return Smi::cast(obj)->value();
01576 } else {
01577 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeEnumIndex);
01578 return Smi::cast(index)->value();
01579 }
01580 }
01581
01582
01583 void SetNextEnumerationIndex(int value) {
01584 if (!IsEmpty()) {
01585 fast_set(this, kEnumerationIndexIndex, Smi::FromInt(value));
01586 }
01587 }
01588 bool HasEnumCache() {
01589 return !IsEmpty() && !get(kEnumerationIndexIndex)->IsSmi();
01590 }
01591
01592 Object* GetEnumCache() {
01593 ASSERT(HasEnumCache());
01594 FixedArray* bridge = FixedArray::cast(get(kEnumerationIndexIndex));
01595 return bridge->get(kEnumCacheBridgeCacheIndex);
01596 }
01597
01598
01599
01600 void SetEnumCache(FixedArray* bridge_storage, FixedArray* new_cache);
01601
01602
01603 inline String* GetKey(int descriptor_number);
01604 inline Object* GetValue(int descriptor_number);
01605 inline Smi* GetDetails(int descriptor_number);
01606
01607
01608 inline void Get(int descriptor_number, Descriptor* desc);
01609 inline void Set(int descriptor_number, Descriptor* desc);
01610
01611
01612
01613
01614
01615
01616
01617 Object* CopyInsert(Descriptor* descriptor, TransitionFlag transition_flag);
01618
01619
01620
01621 Object* RemoveTransitions();
01622
01623
01624 void Sort();
01625
01626
01627 inline int Search(String* name);
01628
01629
01630 bool Contains(String* name) { return kNotFound != Search(name); }
01631
01632
01633
01634
01635
01636 int BinarySearch(String* name, int low, int high);
01637
01638
01639
01640
01641 int LinearSearch(String* name, int len);
01642
01643
01644
01645 static Object* Allocate(int number_of_descriptors);
01646
01647
01648 static inline DescriptorArray* cast(Object* obj);
01649
01650
01651 static const int kNotFound = -1;
01652
01653 static const int kContentArrayIndex = 0;
01654 static const int kEnumerationIndexIndex = 1;
01655 static const int kFirstIndex = 2;
01656
01657
01658 static const int kEnumCacheBridgeLength = 2;
01659 static const int kEnumCacheBridgeEnumIndex = 0;
01660 static const int kEnumCacheBridgeCacheIndex = 1;
01661
01662
01663 static const int kContentArrayOffset = FixedArray::kHeaderSize;
01664 static const int kEnumerationIndexOffset = kContentArrayOffset + kPointerSize;
01665 static const int kFirstOffset = kEnumerationIndexOffset + kPointerSize;
01666
01667
01668 static const int kEnumCacheBridgeEnumOffset = FixedArray::kHeaderSize;
01669 static const int kEnumCacheBridgeCacheOffset =
01670 kEnumCacheBridgeEnumOffset + kPointerSize;
01671
01672 #ifdef DEBUG
01673
01674 void PrintDescriptors();
01675
01676
01677 bool IsSortedNoDuplicates();
01678
01679
01680 bool IsEqualTo(DescriptorArray* other);
01681 #endif
01682
01683
01684
01685 static const int kMaxNumberOfDescriptors = 1024 + 512;
01686
01687 private:
01688
01689 static int ToKeyIndex(int descriptor_number) {
01690 return descriptor_number+kFirstIndex;
01691 }
01692 static int ToValueIndex(int descriptor_number) {
01693 return descriptor_number << 1;
01694 }
01695 static int ToDetailsIndex(int descriptor_number) {
01696 return( descriptor_number << 1) + 1;
01697 }
01698
01699
01700 static inline void fast_swap(FixedArray* array, int first, int second);
01701
01702
01703 inline void Swap(int first, int second);
01704
01705 FixedArray* GetContentArray() {
01706 return FixedArray::cast(get(kContentArrayIndex));
01707 }
01708 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray);
01709 };
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730 class HashTableKey {
01731 public:
01732
01733 virtual bool IsMatch(Object* other) = 0;
01734 typedef uint32_t (*HashFunction)(Object* obj);
01735
01736 virtual HashFunction GetHashFunction() = 0;
01737
01738 virtual uint32_t Hash() = 0;
01739
01740
01741 virtual Object* GetObject() = 0;
01742 virtual bool IsStringKey() = 0;
01743
01744 virtual ~HashTableKey() {}
01745 };
01746
01747
01748 template<int prefix_size, int element_size>
01749 class HashTable: public FixedArray {
01750 public:
01751
01752 int NumberOfElements() {
01753 return Smi::cast(get(kNumberOfElementsIndex))->value();
01754 }
01755
01756
01757 int Capacity() {
01758 return Smi::cast(get(kCapacityIndex))->value();
01759 }
01760
01761
01762
01763 void ElementAdded() { SetNumberOfElements(NumberOfElements() + 1); }
01764
01765
01766
01767 void ElementRemoved() { SetNumberOfElements(NumberOfElements() - 1); }
01768 void ElementsRemoved(int n) { SetNumberOfElements(NumberOfElements() - n); }
01769
01770
01771 static Object* Allocate(int at_least_space_for);
01772
01773
01774 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
01775
01776
01777
01778 bool IsKey(Object* k) {
01779 return !k->IsNull() && !k->IsUndefined();
01780 }
01781
01782
01783 void IteratePrefix(ObjectVisitor* visitor);
01784 void IterateElements(ObjectVisitor* visitor);
01785
01786
01787 static inline HashTable* cast(Object* obj);
01788
01789
01790 INLINE(static uint32_t GetProbeOffset(uint32_t n)) {
01791 return (n + n * n) >> 1;
01792 }
01793
01794 static const int kNumberOfElementsIndex = 0;
01795 static const int kCapacityIndex = 1;
01796 static const int kPrefixStartIndex = 2;
01797 static const int kElementsStartIndex = kPrefixStartIndex + prefix_size;
01798 static const int kElementSize = element_size;
01799 static const int kElementsStartOffset =
01800 kHeaderSize + kElementsStartIndex * kPointerSize;
01801
01802 protected:
01803
01804 int FindEntry(HashTableKey* key);
01805
01806
01807
01808 uint32_t FindInsertionEntry(Object* key, uint32_t hash);
01809
01810
01811 static inline int EntryToIndex(int entry) {
01812 return (entry * kElementSize) + kElementsStartIndex;
01813 }
01814
01815
01816 void SetNumberOfElements(int nof) {
01817 fast_set(this, kNumberOfElementsIndex, Smi::FromInt(nof));
01818 }
01819
01820
01821 void SetCapacity(int capacity) {
01822
01823
01824
01825 ASSERT(capacity > 0);
01826 fast_set(this, kCapacityIndex, Smi::FromInt(capacity));
01827 }
01828
01829
01830
01831 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) {
01832 ASSERT(IsPowerOf2(size));
01833 return (hash + GetProbeOffset(number)) & (size - 1);
01834 }
01835
01836
01837 Object* EnsureCapacity(int n, HashTableKey* key);
01838 };
01839
01840
01841
01842
01843
01844
01845 class SymbolTable: public HashTable<0, 1> {
01846 public:
01847
01848
01849
01850
01851 Object* LookupSymbol(Vector<const char> str, Object** s);
01852 Object* LookupString(String* key, Object** s);
01853
01854
01855
01856
01857 bool LookupSymbolIfExists(String* str, String** symbol);
01858
01859
01860 static inline SymbolTable* cast(Object* obj);
01861
01862 private:
01863 Object* LookupKey(HashTableKey* key, Object** s);
01864
01865 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable);
01866 };
01867
01868
01869
01870
01871
01872
01873 class MapCache: public HashTable<0, 2> {
01874 public:
01875
01876 Object* Lookup(FixedArray* key);
01877 Object* Put(FixedArray* key, Map* value);
01878 static inline MapCache* cast(Object* obj);
01879
01880 private:
01881 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache);
01882 };
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892 class LookupCache: public HashTable<0, 2> {
01893 public:
01894 int Lookup(Map* map, String* name);
01895 Object* Put(Map* map, String* name, int offset);
01896 static inline LookupCache* cast(Object* obj);
01897
01898
01899 static const int kNotFound = -1;
01900
01901 private:
01902 DISALLOW_IMPLICIT_CONSTRUCTORS(LookupCache);
01903 };
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915 class DictionaryBase: public HashTable<2, 3> {};
01916
01917 class Dictionary: public DictionaryBase {
01918 public:
01919
01920 Object* ValueAt(int entry) { return get(EntryToIndex(entry)+1); }
01921
01922
01923 void ValueAtPut(int entry, Object* value) {
01924 set(EntryToIndex(entry)+1, value);
01925 }
01926
01927
01928 PropertyDetails DetailsAt(int entry) {
01929 return PropertyDetails(Smi::cast(get(EntryToIndex(entry) + 2)));
01930 }
01931
01932
01933 void DetailsAtPut(int entry, PropertyDetails value) {
01934 set(EntryToIndex(entry) + 2, value.AsSmi());
01935 }
01936
01937
01938 void RemoveNumberEntries(uint32_t from, uint32_t to);
01939
01940
01941 Object* RemoveHoles();
01942 void CopyValuesTo(FixedArray* elements);
01943
01944
01945 static inline Dictionary* cast(Object* obj);
01946
01947
01948 int FindStringEntry(String* key);
01949
01950
01951 int FindNumberEntry(uint32_t index);
01952
01953
01954 Object* DeleteProperty(int entry);
01955
01956
01957 Object* AtStringPut(String* key, Object* value);
01958 Object* AtNumberPut(uint32_t key, Object* value);
01959
01960 Object* AddStringEntry(String* key, Object* value, PropertyDetails details);
01961 Object* AddNumberEntry(uint32_t key, Object* value, PropertyDetails details);
01962
01963
01964 Object* SetOrAddStringEntry(String* key,
01965 Object* value,
01966 PropertyDetails details);
01967
01968
01969
01970 int NumberOfElementsFilterAttributes(PropertyAttributes filter);
01971
01972
01973 int NumberOfEnumElements();
01974
01975
01976 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter);
01977
01978 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array);
01979
01980 void CopyKeysTo(FixedArray* storage);
01981
01982
01983 Object* TransformPropertiesToFastFor(JSObject* obj,
01984 int unused_property_fields);
01985
01986
01987
01988
01989
01990 inline bool requires_slow_elements();
01991
01992
01993
01994
01995 inline uint32_t max_number_key();
01996
01997
01998 void SetNextEnumerationIndex(int index) {
01999 fast_set(this, kNextEnumerationIndexIndex, Smi::FromInt(index));
02000 }
02001
02002 int NextEnumerationIndex() {
02003 return Smi::cast(get(kNextEnumerationIndexIndex))->value();
02004 }
02005
02006
02007 static Object* Allocate(int at_least_space_for);
02008
02009
02010 Object* EnsureCapacity(int n, HashTableKey* key);
02011
02012 #ifdef DEBUG
02013 void Print();
02014 #endif
02015
02016 Object* SlowReverseLookup(Object* value);
02017
02018
02019 static const int kRequiresSlowElementsMask = 1;
02020 static const int kRequiresSlowElementsTagSize = 1;
02021 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
02022
02023 private:
02024
02025 Object* AtPut(HashTableKey* key, Object* value);
02026
02027 Object* Add(HashTableKey* key, Object* value, PropertyDetails details);
02028
02029
02030 void AddEntry(Object* key,
02031 Object* value,
02032 PropertyDetails details,
02033 uint32_t hash);
02034
02035
02036 inline void SetEntry(int entry,
02037 Object* key,
02038 Object* value,
02039 PropertyDetails details);
02040
02041 void UpdateMaxNumberKey(uint32_t key);
02042
02043
02044 Object* GenerateNewEnumerationIndices();
02045
02046 static const int kMaxNumberKeyIndex = kPrefixStartIndex;
02047 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
02048
02049 DISALLOW_IMPLICIT_CONSTRUCTORS(Dictionary);
02050 };
02051
02052
02053
02054
02055
02056 class ByteArray: public Array {
02057 public:
02058
02059 inline byte get(int index);
02060 inline void set(int index, byte value);
02061
02062
02063 inline int get_int(int index);
02064
02065 static int SizeFor(int length) {
02066 return kHeaderSize + OBJECT_SIZE_ALIGN(length);
02067 }
02068
02069
02070
02071
02072 static int LengthFor(int size_in_bytes) {
02073 ASSERT(IsAligned(size_in_bytes, kPointerSize));
02074 ASSERT(size_in_bytes >= kHeaderSize);
02075 return size_in_bytes - kHeaderSize;
02076 }
02077
02078
02079 inline Address GetDataStartAddress();
02080
02081
02082 static inline ByteArray* FromDataStartAddress(Address address);
02083
02084
02085 static inline ByteArray* cast(Object* obj);
02086
02087
02088 int ByteArraySize() { return SizeFor(length()); }
02089 #ifdef DEBUG
02090 void ByteArrayPrint();
02091 void ByteArrayVerify();
02092 #endif
02093
02094 private:
02095 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
02096 };
02097
02098
02099
02100 class Code: public HeapObject {
02101 public:
02102
02103
02104 enum Flags { };
02105
02106 enum Kind {
02107 FUNCTION,
02108 STUB,
02109 BUILTIN,
02110 LOAD_IC,
02111 KEYED_LOAD_IC,
02112 CALL_IC,
02113 STORE_IC,
02114 KEYED_STORE_IC,
02115
02116
02117 FIRST_IC_KIND = LOAD_IC,
02118 LAST_IC_KIND = KEYED_STORE_IC
02119 };
02120
02121 enum {
02122 NUMBER_OF_KINDS = LAST_IC_KIND + 1
02123 };
02124
02125
02126
02127 enum ICTargetState {
02128 IC_TARGET_IS_ADDRESS,
02129 IC_TARGET_IS_OBJECT
02130 };
02131
02132 #ifdef ENABLE_DISASSEMBLER
02133
02134 static const char* Kind2String(Kind kind);
02135 static const char* ICState2String(InlineCacheState state);
02136 void Disassemble();
02137 #endif // ENABLE_DISASSEMBLER
02138
02139
02140 inline int instruction_size();
02141 inline void set_instruction_size(int value);
02142
02143
02144 inline int relocation_size();
02145 inline void set_relocation_size(int value);
02146
02147
02148 inline int sinfo_size();
02149 inline void set_sinfo_size(int value);
02150
02151
02152 inline Flags flags();
02153 inline void set_flags(Flags flags);
02154
02155
02156 inline Kind kind();
02157 inline InlineCacheState ic_state();
02158 inline PropertyType type();
02159 inline int arguments_count();
02160
02161
02162 inline bool is_inline_cache_stub();
02163 inline bool is_load_stub() { return kind() == LOAD_IC; }
02164 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; }
02165 inline bool is_store_stub() { return kind() == STORE_IC; }
02166 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; }
02167 inline bool is_call_stub() { return kind() == CALL_IC; }
02168
02169
02170
02171
02172 inline ICTargetState ic_flag();
02173 inline void set_ic_flag(ICTargetState value);
02174
02175
02176 inline CodeStub::Major major_key();
02177 inline void set_major_key(CodeStub::Major major);
02178
02179
02180 static inline Flags ComputeFlags(Kind kind,
02181 InlineCacheState ic_state = UNINITIALIZED,
02182 PropertyType type = NORMAL,
02183 int argc = -1);
02184
02185 static inline Flags ComputeMonomorphicFlags(Kind kind,
02186 PropertyType type,
02187 int argc = -1);
02188
02189 static inline Kind ExtractKindFromFlags(Flags flags);
02190 static inline InlineCacheState ExtractICStateFromFlags(Flags flags);
02191 static inline PropertyType ExtractTypeFromFlags(Flags flags);
02192 static inline int ExtractArgumentsCountFromFlags(Flags flags);
02193 static inline Flags RemoveTypeFromFlags(Flags flags);
02194
02195
02196
02197 inline byte* instruction_start();
02198
02199
02200 inline int body_size();
02201
02202
02203 inline byte* relocation_start();
02204
02205
02206 inline byte* entry();
02207
02208
02209 inline bool contains(byte* pc);
02210
02211
02212 inline byte* sinfo_start();
02213
02214
02215 void ConvertICTargetsFromAddressToObject();
02216
02217
02218 void ConvertICTargetsFromObjectToAddress();
02219
02220
02221
02222 void Relocate(int delta);
02223
02224
02225 void CopyFrom(const CodeDesc& desc);
02226
02227
02228
02229 static int SizeFor(int body_size, int sinfo_size) {
02230 ASSERT_SIZE_TAG_ALIGNED(body_size);
02231 ASSERT_SIZE_TAG_ALIGNED(sinfo_size);
02232 return kHeaderSize + body_size + sinfo_size;
02233 }
02234
02235
02236 int SourcePosition(Address pc);
02237 int SourceStatementPosition(Address pc);
02238
02239
02240 static inline Code* cast(Object* obj);
02241
02242
02243 int CodeSize() { return SizeFor(body_size(), sinfo_size()); }
02244 void CodeIterateBody(ObjectVisitor* v);
02245 #ifdef DEBUG
02246 void CodePrint();
02247 void CodeVerify();
02248 #endif
02249
02250
02251 static const int kInstructionSizeOffset = HeapObject::kHeaderSize;
02252 static const int kRelocationSizeOffset = kInstructionSizeOffset + kIntSize;
02253 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize;
02254 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize;
02255 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize;
02256 static const int kHeaderSize = kKindSpecificFlagsOffset + kIntSize;
02257
02258
02259 static const int kICFlagOffset = kKindSpecificFlagsOffset + 0;
02260 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1;
02261
02262
02263 static const int kFlagsICStateShift = 0;
02264 static const int kFlagsKindShift = 3;
02265 static const int kFlagsTypeShift = 6;
02266 static const int kFlagsArgumentsCountShift = 9;
02267
02268 static const int kFlagsICStateMask = 0x00000007;
02269 static const int kFlagsKindMask = 0x00000038;
02270 static const int kFlagsTypeMask = 0x000001C0;
02271 static const int kFlagsArgumentsCountMask = 0xFFFFFE00;
02272
02273
02274 private:
02275 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
02276 };
02277
02278
02279
02280
02281
02282
02283 class Map: public HeapObject {
02284 public:
02285
02286 inline int instance_size();
02287 inline void set_instance_size(int value);
02288
02289
02290 inline int inobject_properties();
02291 inline void set_inobject_properties(int value);
02292
02293
02294 inline InstanceType instance_type();
02295 inline void set_instance_type(InstanceType value);
02296
02297
02298
02299 inline int unused_property_fields();
02300 inline void set_unused_property_fields(int value);
02301
02302
02303 inline byte bit_field();
02304 inline void set_bit_field(byte value);
02305
02306
02307
02308
02309
02310
02311 inline void set_non_instance_prototype(bool value);
02312 inline bool has_non_instance_prototype();
02313
02314
02315
02316 inline void set_is_hidden_prototype() {
02317 set_bit_field(bit_field() | (1 << kIsHiddenPrototype));
02318 }
02319
02320 inline bool is_hidden_prototype() {
02321 return ((1 << kIsHiddenPrototype) & bit_field()) != 0;
02322 }
02323
02324
02325 inline void set_has_named_interceptor() {
02326 set_bit_field(bit_field() | (1 << kHasNamedInterceptor));
02327 }
02328
02329 inline bool has_named_interceptor() {
02330 return ((1 << kHasNamedInterceptor) & bit_field()) != 0;
02331 }
02332
02333
02334 inline void set_has_indexed_interceptor() {
02335 set_bit_field(bit_field() | (1 << kHasIndexedInterceptor));
02336 }
02337
02338 inline bool has_indexed_interceptor() {
02339 return ((1 << kHasIndexedInterceptor) & bit_field()) != 0;
02340 }
02341
02342
02343
02344
02345
02346
02347
02348 inline void set_is_undetectable() {
02349 set_bit_field(bit_field() | (1 << kIsUndetectable));
02350 }
02351
02352 inline bool is_undetectable() {
02353 return ((1 << kIsUndetectable) & bit_field()) != 0;
02354 }
02355
02356
02357 inline void set_has_instance_call_handler() {
02358 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler));
02359 }
02360
02361 inline bool has_instance_call_handler() {
02362 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0;
02363 }
02364
02365
02366
02367 inline void set_is_access_check_needed() {
02368 set_bit_field(bit_field() | (1 << kIsAccessCheckNeeded));
02369 }
02370
02371 inline bool is_access_check_needed() {
02372 return ((1 << kIsAccessCheckNeeded) & bit_field()) != 0;
02373 }
02374
02375
02376 DECL_ACCESSORS(prototype, Object)
02377
02378
02379 DECL_ACCESSORS(constructor, Object)
02380
02381
02382 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
02383
02384
02385 DECL_ACCESSORS(code_cache, FixedArray)
02386
02387
02388 Object* Copy();
02389
02390
02391
02392 Object* CopyDropTransitions();
02393
02394
02395 int PropertyIndexFor(String* name);
02396
02397
02398 int NextFreePropertyIndex();
02399
02400
02401 int NumberOfDescribedProperties();
02402
02403
02404 static inline Map* cast(Object* obj);
02405
02406
02407 AccessorDescriptor* FindAccessor(String* name);
02408
02409
02410
02411
02412 inline void ClearCodeCache();
02413
02414
02415 Object* UpdateCodeCache(String* name, Code* code);
02416
02417
02418 Object* FindInCodeCache(String* name, Code::Flags flags);
02419
02420
02421
02422 int IndexInCodeCache(Code* code);
02423
02424
02425 void RemoveFromCodeCache(int index);
02426
02427
02428
02429
02430 void CreateBackPointers();
02431
02432
02433
02434
02435
02436 void ClearNonLiveTransitions(Object* real_prototype);
02437
02438
02439 void MapIterateBody(ObjectVisitor* v);
02440 #ifdef DEBUG
02441 void MapPrint();
02442 void MapVerify();
02443 #endif
02444
02445
02446 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
02447 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
02448 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
02449 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
02450 static const int kInstanceDescriptorsOffset =
02451 kConstructorOffset + kPointerSize;
02452 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize;
02453 static const int kSize = kCodeCacheOffset + kIntSize;
02454
02455
02456 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
02457 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1;
02458
02459
02460
02461
02462 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0;
02463 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1;
02464 static const int kBitFieldOffset = kInstanceAttributesOffset + 2;
02465
02466
02467
02468 static const int kUnused = 0;
02469 static const int kHasNonInstancePrototype = 1;
02470 static const int kIsHiddenPrototype = 2;
02471 static const int kHasNamedInterceptor = 3;
02472 static const int kHasIndexedInterceptor = 4;
02473 static const int kIsUndetectable = 5;
02474 static const int kHasInstanceCallHandler = 6;
02475 static const int kIsAccessCheckNeeded = 7;
02476 private:
02477 DISALLOW_IMPLICIT_CONSTRUCTORS(Map);
02478 };
02479
02480
02481
02482
02483
02484 class Struct: public HeapObject {
02485 public:
02486 inline void InitializeBody(int object_size);
02487 static inline Struct* cast(Object* that);
02488 };
02489
02490
02491
02492 enum ScriptType {
02493 SCRIPT_TYPE_NATIVE,
02494 SCRIPT_TYPE_EXTENSION,
02495 SCRIPT_TYPE_NORMAL
02496 };
02497
02498
02499
02500 class Script: public Struct {
02501 public:
02502
02503 DECL_ACCESSORS(source, Object)
02504
02505
02506 DECL_ACCESSORS(name, Object)
02507
02508
02509 DECL_ACCESSORS(line_offset, Smi)
02510
02511
02512
02513 DECL_ACCESSORS(column_offset, Smi)
02514
02515
02516 DECL_ACCESSORS(wrapper, Proxy)
02517
02518
02519 DECL_ACCESSORS(type, Smi)
02520
02521 static inline Script* cast(Object* obj);
02522
02523 #ifdef DEBUG
02524 void ScriptPrint();
02525 void ScriptVerify();
02526 #endif
02527
02528 static const int kSourceOffset = HeapObject::kHeaderSize;
02529 static const int kNameOffset = kSourceOffset + kPointerSize;
02530 static const int kLineOffsetOffset = kNameOffset + kPointerSize;
02531 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize;
02532 static const int kWrapperOffset = kColumnOffsetOffset + kPointerSize;
02533 static const int kTypeOffset = kWrapperOffset + kPointerSize;
02534 static const int kSize = kTypeOffset + kPointerSize;
02535
02536 private:
02537 DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
02538 };
02539
02540
02541
02542
02543 class SharedFunctionInfo: public HeapObject {
02544 public:
02545
02546 DECL_ACCESSORS(name, Object)
02547
02548
02549 DECL_ACCESSORS(code, Code)
02550
02551
02552 inline bool is_compiled();
02553
02554
02555
02556 inline int length();
02557 inline void set_length(int value);
02558
02559
02560 inline int formal_parameter_count();
02561 inline void set_formal_parameter_count(int value);
02562
02563
02564
02565 inline void DontAdaptArguments();
02566
02567
02568 inline int expected_nof_properties();
02569 inline void set_expected_nof_properties(int value);
02570
02571
02572 DECL_ACCESSORS(instance_class_name, Object)
02573
02574
02575
02576
02577
02578 DECL_ACCESSORS(function_data, Object)
02579
02580
02581
02582 DECL_ACCESSORS(lazy_load_data, Object)
02583
02584
02585 DECL_ACCESSORS(script, Object)
02586
02587
02588
02589
02590
02591
02592 inline int start_position_and_type();
02593 inline void set_start_position_and_type(int value);
02594
02595
02596 DECL_ACCESSORS(debug_info, Object)
02597
02598
02599 inline int function_token_position();
02600 inline void set_function_token_position(int function_token_position);
02601
02602
02603 inline int start_position();
02604 inline void set_start_position(int start_position);
02605
02606
02607 inline int end_position();
02608 inline void set_end_position(int end_position);
02609
02610
02611 inline bool is_expression();
02612 inline void set_is_expression(bool value);
02613
02614
02615
02616
02617 inline bool is_toplevel();
02618 inline void set_is_toplevel(bool value);
02619
02620
02621 bool HasSourceCode();
02622 Object* GetSourceCode();
02623
02624
02625 void SharedFunctionInfoIterateBody(ObjectVisitor* v);
02626
02627 void SourceCodePrint(StringStream* accumulator, int max_length);
02628 #ifdef DEBUG
02629 void SharedFunctionInfoPrint();
02630 void SharedFunctionInfoVerify();
02631 #endif
02632
02633
02634 static inline SharedFunctionInfo* cast(Object* obj);
02635
02636
02637 static const int kDontAdaptArgumentsSentinel = -1;
02638
02639
02640 static const int kNameOffset = HeapObject::kHeaderSize;
02641 static const int kCodeOffset = kNameOffset + kPointerSize;
02642 static const int kLengthOffset = kCodeOffset + kPointerSize;
02643 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize;
02644 static const int kExpectedNofPropertiesOffset =
02645 kFormalParameterCountOffset + kIntSize;
02646 static const int kInstanceClassNameOffset =
02647 kExpectedNofPropertiesOffset + kIntSize;
02648 static const int kExternalReferenceDataOffset =
02649 kInstanceClassNameOffset + kPointerSize;
02650 static const int kLazyLoadDataOffset =
02651 kExternalReferenceDataOffset + kPointerSize;
02652 static const int kScriptOffset = kLazyLoadDataOffset + kPointerSize;
02653 static const int kStartPositionAndTypeOffset = kScriptOffset + kPointerSize;
02654 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
02655 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
02656 static const int kDebugInfoOffset = kFunctionTokenPositionOffset + kIntSize;
02657 static const int kSize = kDebugInfoOffset + kPointerSize;
02658
02659 private:
02660
02661
02662 static const int kFlagBit = 0;
02663 static const int kLengthShift = 1;
02664 static const int kLengthMask = ~((1 << kLengthShift) - 1);
02665
02666
02667
02668
02669 static const int kIsExpressionBit = 0;
02670 static const int kIsTopLevelBit = 1;
02671 static const int kStartPositionShift = 2;
02672 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1);
02673
02674 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
02675 };
02676
02677
02678
02679 class JSFunction: public JSObject {
02680 public:
02681
02682 DECL_ACCESSORS(prototype_or_initial_map, Object)
02683
02684
02685
02686 DECL_ACCESSORS(shared, SharedFunctionInfo)
02687
02688
02689 inline Context* context();
02690 inline Object* unchecked_context();
02691 inline void set_context(Object* context);
02692
02693
02694
02695
02696
02697 inline Code* code();
02698 inline void set_code(Code* value);
02699
02700
02701
02702 inline bool IsBoilerplate();
02703
02704
02705 inline bool IsLoaded();
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716 DECL_ACCESSORS(literals, FixedArray)
02717
02718
02719 inline Map* initial_map();
02720 inline void set_initial_map(Map* value);
02721 inline bool has_initial_map();
02722
02723
02724
02725
02726
02727 inline bool has_prototype();
02728 inline bool has_instance_prototype();
02729 inline Object* prototype();
02730 inline Object* instance_prototype();
02731 Object* SetInstancePrototype(Object* value);
02732 Object* SetPrototype(Object* value);
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743 Object* SetInstanceClassName(String* name);
02744
02745
02746 inline bool is_compiled();
02747
02748
02749 static inline JSFunction* cast(Object* obj);
02750
02751
02752 #ifdef DEBUG
02753 void JSFunctionPrint();
02754 void JSFunctionVerify();
02755 #endif
02756
02757
02758 inline int NumberOfLiterals();
02759
02760
02761 static Context* GlobalContextFromLiterals(FixedArray* literals);
02762
02763
02764 static const int kPrototypeOrInitialMapOffset = JSObject::kHeaderSize;
02765 static const int kSharedFunctionInfoOffset =
02766 kPrototypeOrInitialMapOffset + kPointerSize;
02767 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
02768 static const int kLiteralsOffset = kContextOffset + kPointerSize;
02769 static const int kSize = kLiteralsOffset + kPointerSize;
02770
02771
02772 static const int kLiteralsPrefixSize = 1;
02773 static const int kLiteralGlobalContextIndex = 0;
02774 private:
02775 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
02776 };
02777
02778
02779
02780
02781
02782
02783
02784
02785
02786
02787 class JSGlobalProxy : public JSObject {
02788 public:
02789
02790
02791 DECL_ACCESSORS(context, Object)
02792
02793
02794 static inline JSGlobalProxy* cast(Object* obj);
02795
02796
02797 #ifdef DEBUG
02798 void JSGlobalProxyPrint();
02799 void JSGlobalProxyVerify();
02800 #endif
02801
02802
02803 static const int kContextOffset = JSObject::kHeaderSize;
02804 static const int kSize = kContextOffset + kPointerSize;
02805
02806 private:
02807
02808 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalProxy);
02809 };
02810
02811
02812
02813 class JSBuiltinsObject;
02814
02815
02816
02817 class GlobalObject: public JSObject {
02818 public:
02819
02820 DECL_ACCESSORS(builtins, JSBuiltinsObject)
02821
02822
02823 DECL_ACCESSORS(global_context, Context)
02824
02825
02826 DECL_ACCESSORS(global_receiver, JSObject)
02827
02828
02829 static inline GlobalObject* cast(Object* obj);
02830
02831
02832 static const int kBuiltinsOffset = JSObject::kHeaderSize;
02833 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize;
02834 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize;
02835 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize;
02836
02837 private:
02838 friend class AGCCVersionRequiresThisClassToHaveAFriendSoHereItIs;
02839
02840 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject);
02841 };
02842
02843
02844
02845 class JSGlobalObject: public GlobalObject {
02846 public:
02847
02848 static inline JSGlobalObject* cast(Object* obj);
02849
02850
02851 #ifdef DEBUG
02852 void JSGlobalObjectPrint();
02853 void JSGlobalObjectVerify();
02854 #endif
02855
02856
02857 static const int kSize = GlobalObject::kHeaderSize;
02858
02859 private:
02860 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject);
02861 };
02862
02863
02864
02865
02866 class JSBuiltinsObject: public GlobalObject {
02867 public:
02868
02869 inline Object* javascript_builtin(Builtins::JavaScript id);
02870 inline void set_javascript_builtin(Builtins::JavaScript id, Object* value);
02871
02872
02873 static inline JSBuiltinsObject* cast(Object* obj);
02874
02875
02876 #ifdef DEBUG
02877 void JSBuiltinsObjectPrint();
02878 void JSBuiltinsObjectVerify();
02879 #endif
02880
02881
02882
02883 static const int kJSBuiltinsCount = Builtins::id_count;
02884 static const int kJSBuiltinsOffset = GlobalObject::kHeaderSize;
02885 static const int kSize =
02886 kJSBuiltinsOffset + (kJSBuiltinsCount * kPointerSize);
02887 private:
02888 DISALLOW_IMPLICIT_CONSTRUCTORS(JSBuiltinsObject);
02889 };
02890
02891
02892
02893 class JSValue: public JSObject {
02894 public:
02895
02896 DECL_ACCESSORS(value, Object)
02897
02898
02899 static inline JSValue* cast(Object* obj);
02900
02901
02902 #ifdef DEBUG
02903 void JSValuePrint();
02904 void JSValueVerify();
02905 #endif
02906
02907
02908 static const int kValueOffset = JSObject::kHeaderSize;
02909 static const int kSize = kValueOffset + kPointerSize;
02910
02911 private:
02912 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue);
02913 };
02914
02915
02916 class JSRegExp: public JSObject {
02917 public:
02918 enum Type { NOT_COMPILED, JSCRE, ATOM };
02919 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 };
02920
02921 class Flags {
02922 public:
02923 explicit Flags(uint32_t value) : value_(value) { }
02924 bool is_global() { return (value_ & GLOBAL) != 0; }
02925 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; }
02926 bool is_multiline() { return (value_ & MULTILINE) != 0; }
02927 uint32_t value() { return value_; }
02928 private:
02929 uint32_t value_;
02930 };
02931
02932 DECL_ACCESSORS(data, Object)
02933
02934 inline Type TypeTag();
02935 inline Object* DataAt(int index);
02936
02937 static inline JSRegExp* cast(Object* obj);
02938
02939
02940 #ifdef DEBUG
02941 void JSRegExpPrint();
02942 void JSRegExpVerify();
02943 #endif
02944
02945 static const int kDataOffset = JSObject::kHeaderSize;
02946 static const int kSize = kDataOffset + kIntSize;
02947
02948 static const int kTagIndex = 0;
02949 static const int kSourceIndex = kTagIndex + 1;
02950 static const int kFlagsIndex = kSourceIndex + 1;
02951
02952
02953 static const int kAtomPatternIndex = kFlagsIndex + 1;
02954 static const int kJscreDataIndex = kFlagsIndex + 1;
02955 static const int kDataSize = kAtomPatternIndex + 1;
02956 };
02957
02958
02959 class CompilationCacheTable: public HashTable<0, 2> {
02960 public:
02961
02962 Object* Lookup(String* src);
02963 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
02964 Object* Put(String* src, Object* value);
02965 Object* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
02966
02967 static inline CompilationCacheTable* cast(Object* obj);
02968
02969 private:
02970 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
02971 };
02972
02973
02974 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS};
02975 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL};
02976
02977
02978 class StringHasher {
02979 public:
02980 inline StringHasher(int length);
02981
02982
02983
02984 inline bool has_trivial_hash();
02985
02986
02987 inline void AddCharacter(uc32 c);
02988
02989
02990
02991
02992 inline void AddCharacterNoIndex(uc32 c);
02993
02994
02995
02996 uint32_t GetHashField();
02997
02998
02999
03000 bool is_array_index() { return is_array_index_; }
03001
03002 bool is_valid() { return is_valid_; }
03003
03004 void invalidate() { is_valid_ = false; }
03005
03006 private:
03007
03008 uint32_t array_index() {
03009 ASSERT(is_array_index());
03010 return array_index_;
03011 }
03012
03013 inline uint32_t GetHash();
03014
03015 int length_;
03016 uint32_t raw_running_hash_;
03017 uint32_t array_index_;
03018 bool is_array_index_;
03019 bool is_first_char_;
03020 bool is_valid_;
03021 };
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032 class String: public HeapObject {
03033 public:
03034
03035 inline int length();
03036 inline void set_length(int value);
03037
03038
03039
03040
03041
03042 inline uint32_t length_field();
03043 inline void set_length_field(uint32_t value);
03044
03045
03046 inline void Set(int index, uint16_t value);
03047
03048
03049 inline uint16_t Get(int index);
03050
03051
03052
03053
03054
03055 Object* Flatten();
03056
03057
03058
03059 inline void TryFlatten();
03060
03061
03062 inline bool IsAsciiRepresentation();
03063
03064
03065
03066 inline bool IsSeqAsciiString();
03067
03068
03069
03070 inline bool StringIsSlicedString();
03071 inline bool StringIsConsString();
03072
03073 Vector<const char> ToAsciiVector();
03074 Vector<const uc16> ToUC16Vector();
03075
03076
03077
03078 bool MarkAsUndetectable();
03079
03080
03081 Object* Slice(int from, int to);
03082
03083
03084 inline bool Equals(String* other);
03085 bool IsEqualTo(Vector<const char> str);
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095 SmartPointer<char> ToCString(AllowNullsFlag allow_nulls,
03096 RobustnessFlag robustness_flag,
03097 int offset,
03098 int length,
03099 int* length_output = 0);
03100 SmartPointer<char> ToCString(
03101 AllowNullsFlag allow_nulls = DISALLOW_NULLS,
03102 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL,
03103 int* length_output = 0);
03104
03105 int Utf8Length();
03106
03107
03108
03109
03110
03111
03112
03113 SmartPointer<uc16> ToWideCString(
03114 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL);
03115
03116
03117 inline bool HasHashCode();
03118
03119
03120 inline uint32_t Hash();
03121
03122 static uint32_t ComputeLengthAndHashField(unibrow::CharacterStream* buffer,
03123 int length);
03124
03125 static bool ComputeArrayIndex(unibrow::CharacterStream* buffer,
03126 uint32_t* index,
03127 int length);
03128
03129
03130 inline bool AsArrayIndex(uint32_t* index);
03131
03132
03133 static inline String* cast(Object* obj);
03134
03135 void PrintOn(FILE* out);
03136
03137
03138 inline uint32_t size_tag();
03139 static inline uint32_t map_size_tag(Map* map);
03140
03141
03142 inline bool is_symbol();
03143 static inline bool is_symbol_map(Map* map);
03144
03145
03146 inline bool is_ascii_representation();
03147 static inline bool is_ascii_representation_map(Map* map);
03148
03149
03150 inline StringRepresentationTag representation_tag();
03151
03152 inline int full_representation_tag();
03153 static inline StringRepresentationTag map_representation_tag(Map* map);
03154
03155
03156 bool LooksValid();
03157
03158
03159 void StringShortPrint(StringStream* accumulator);
03160 #ifdef DEBUG
03161 void StringPrint();
03162 void StringVerify();
03163 #endif
03164 inline bool IsFlat();
03165
03166
03167 static const int kLengthOffset = HeapObject::kHeaderSize;
03168 static const int kSize = kLengthOffset + kIntSize;
03169
03170
03171 static const int kMaxShortStringSize = 63;
03172 static const int kMaxMediumStringSize = 16383;
03173
03174 static const int kMaxArrayIndexSize = 10;
03175
03176
03177 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar;
03178
03179
03180 static const int kMinNonFlatLength = 13;
03181
03182
03183
03184
03185
03186
03187 static const int kHashComputedMask = 1;
03188 static const int kIsArrayIndexMask = 1 << 1;
03189 static const int kNofLengthBitFields = 2;
03190
03191
03192
03193 static const int kMaxCachedArrayIndexLength = 7;
03194
03195
03196
03197 static const int kHashShift = kNofLengthBitFields;
03198 static const int kShortLengthShift = kHashShift + kShortStringTag;
03199 static const int kMediumLengthShift = kHashShift + kMediumStringTag;
03200 static const int kLongLengthShift = kHashShift + kLongStringTag;
03201
03202
03203 static const int kMaxShortPrintLength = 1024;
03204
03205
03206 const uc16* GetTwoByteData();
03207 const uc16* GetTwoByteData(unsigned start);
03208
03209
03210 static const unibrow::byte* ReadBlock(String* input,
03211 unibrow::byte* util_buffer,
03212 unsigned capacity,
03213 unsigned* remaining,
03214 unsigned* offset);
03215 static const unibrow::byte* ReadBlock(String** input,
03216 unibrow::byte* util_buffer,
03217 unsigned capacity,
03218 unsigned* remaining,
03219 unsigned* offset);
03220
03221
03222 template <typename sinkchar>
03223 static void WriteToFlat(String* source,
03224 sinkchar* sink,
03225 int from,
03226 int to);
03227
03228 protected:
03229 class ReadBlockBuffer {
03230 public:
03231 ReadBlockBuffer(unibrow::byte* util_buffer_,
03232 unsigned cursor_,
03233 unsigned capacity_,
03234 unsigned remaining_) :
03235 util_buffer(util_buffer_),
03236 cursor(cursor_),
03237 capacity(capacity_),
03238 remaining(remaining_) {
03239 }
03240 unibrow::byte* util_buffer;
03241 unsigned cursor;
03242 unsigned capacity;
03243 unsigned remaining;
03244 };
03245
03246
03247
03248
03249
03250
03251
03252 static inline const unibrow::byte* ReadBlock(String* input,
03253 ReadBlockBuffer* buffer,
03254 unsigned* offset,
03255 unsigned max_chars);
03256 static void ReadBlockIntoBuffer(String* input,
03257 ReadBlockBuffer* buffer,
03258 unsigned* offset_ptr,
03259 unsigned max_chars);
03260
03261 private:
03262
03263
03264 bool SlowEquals(String* other);
03265
03266
03267 bool SlowAsArrayIndex(uint32_t* index);
03268
03269
03270 uint32_t ComputeAndSetHash();
03271
03272 DISALLOW_IMPLICIT_CONSTRUCTORS(String);
03273 };
03274
03275
03276
03277 class SeqString: public String {
03278 public:
03279
03280
03281 static inline SeqString* cast(Object* obj);
03282
03283
03284
03285 uint16_t* SeqStringGetTwoByteAddress();
03286
03287 private:
03288 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString);
03289 };
03290
03291
03292
03293
03294 class SeqAsciiString: public SeqString {
03295 public:
03296
03297 inline uint16_t SeqAsciiStringGet(int index);
03298 inline void SeqAsciiStringSet(int index, uint16_t value);
03299
03300
03301 inline Address GetCharsAddress();
03302
03303 inline char* GetChars();
03304
03305
03306 static inline SeqAsciiString* cast(Object* obj);
03307
03308
03309
03310
03311 inline int SeqAsciiStringSize(Map* map);
03312
03313
03314 static int SizeFor(int length) {
03315 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize);
03316 }
03317
03318
03319 static const int kHeaderSize = String::kSize;
03320
03321
03322 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
03323 unsigned* offset,
03324 unsigned chars);
03325 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining,
03326 unsigned* offset,
03327 unsigned chars);
03328
03329 private:
03330 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqAsciiString);
03331 };
03332
03333
03334
03335
03336 class SeqTwoByteString: public SeqString {
03337 public:
03338
03339 inline uint16_t SeqTwoByteStringGet(int index);
03340 inline void SeqTwoByteStringSet(int index, uint16_t value);
03341
03342
03343 inline Address GetCharsAddress();
03344
03345 inline uc16* GetChars();
03346
03347
03348 const uint16_t* SeqTwoByteStringGetData(unsigned start);
03349
03350
03351 static inline SeqTwoByteString* cast(Object* obj);
03352
03353
03354
03355
03356 inline int SeqTwoByteStringSize(Map* map);
03357
03358
03359 static int SizeFor(int length) {
03360 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize);
03361 }
03362
03363
03364 static const int kHeaderSize = String::kSize;
03365
03366
03367 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
03368 unsigned* offset_ptr,
03369 unsigned chars);
03370
03371 private:
03372 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString);
03373 };
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384 class ConsString: public String {
03385 public:
03386
03387 inline Object* first();
03388 inline void set_first(Object* first,
03389 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
03390
03391
03392 inline Object* second();
03393 inline void set_second(Object* second,
03394 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
03395
03396
03397 uint16_t ConsStringGet(int index);
03398
03399
03400 static inline ConsString* cast(Object* obj);
03401
03402
03403
03404
03405 void ConsStringIterateBody(ObjectVisitor* v);
03406
03407
03408 static const int kFirstOffset = String::kSize;
03409 static const int kSecondOffset = kFirstOffset + kPointerSize;
03410 static const int kSize = kSecondOffset + kPointerSize;
03411
03412
03413 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer,
03414 unsigned* offset_ptr,
03415 unsigned chars);
03416 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
03417 unsigned* offset_ptr,
03418 unsigned chars);
03419
03420
03421 static const int kMinLength = 13;
03422
03423 private:
03424 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString);
03425 };
03426
03427
03428
03429
03430
03431
03432 class SlicedString: public String {
03433 public:
03434
03435 inline Object* buffer();
03436 inline void set_buffer(Object* buffer);
03437
03438
03439 inline int start();
03440 inline void set_start(int start);
03441
03442
03443 uint16_t SlicedStringGet(int index);
03444
03445
03446 Object* SlicedStringFlatten();
03447
03448
03449 static inline SlicedString* cast(Object* obj);
03450
03451
03452 void SlicedStringIterateBody(ObjectVisitor* v);
03453
03454
03455 static const int kBufferOffset = String::kSize;
03456 static const int kStartOffset = kBufferOffset + kPointerSize;
03457 static const int kSize = kStartOffset + kIntSize;
03458
03459
03460 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer,
03461 unsigned* offset_ptr,
03462 unsigned chars);
03463 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
03464 unsigned* offset_ptr,
03465 unsigned chars);
03466
03467 private:
03468 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString);
03469 };
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481 class ExternalString: public String {
03482 public:
03483
03484 static inline ExternalString* cast(Object* obj);
03485
03486
03487 static const int kResourceOffset = String::kSize;
03488 static const int kSize = kResourceOffset + kPointerSize;
03489
03490 private:
03491 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
03492 };
03493
03494
03495
03496
03497 class ExternalAsciiString: public ExternalString {
03498 public:
03499 typedef v8::String::ExternalAsciiStringResource Resource;
03500
03501
03502 inline Resource* resource();
03503 inline void set_resource(Resource* buffer);
03504
03505
03506 uint16_t ExternalAsciiStringGet(int index);
03507
03508
03509 static inline ExternalAsciiString* cast(Object* obj);
03510
03511
03512 const unibrow::byte* ExternalAsciiStringReadBlock(unsigned* remaining,
03513 unsigned* offset,
03514 unsigned chars);
03515 inline void ExternalAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
03516 unsigned* offset,
03517 unsigned chars);
03518
03519 private:
03520 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalAsciiString);
03521 };
03522
03523
03524
03525
03526 class ExternalTwoByteString: public ExternalString {
03527 public:
03528 typedef v8::String::ExternalStringResource Resource;
03529
03530
03531 inline Resource* resource();
03532 inline void set_resource(Resource* buffer);
03533
03534
03535 uint16_t ExternalTwoByteStringGet(int index);
03536
03537
03538 const uint16_t* ExternalTwoByteStringGetData(unsigned start);
03539
03540
03541 static inline ExternalTwoByteString* cast(Object* obj);
03542
03543
03544 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
03545 unsigned* offset_ptr,
03546 unsigned chars);
03547
03548 private:
03549 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString);
03550 };
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562 class StringInputBuffer: public unibrow::InputBuffer<String, String*, 1024> {
03563 public:
03564 virtual void Seek(unsigned pos);
03565 inline StringInputBuffer(): unibrow::InputBuffer<String, String*, 1024>() {}
03566 inline StringInputBuffer(String* backing):
03567 unibrow::InputBuffer<String, String*, 1024>(backing) {}
03568 };
03569
03570
03571 class SafeStringInputBuffer
03572 : public unibrow::InputBuffer<String, String**, 256> {
03573 public:
03574 virtual void Seek(unsigned pos);
03575 inline SafeStringInputBuffer()
03576 : unibrow::InputBuffer<String, String**, 256>() {}
03577 inline SafeStringInputBuffer(String** backing)
03578 : unibrow::InputBuffer<String, String**, 256>(backing) {}
03579 };
03580
03581
03582 template <typename T>
03583 class VectorIterator {
03584 public:
03585 VectorIterator(T* d, int l) : data_(Vector<const T>(d, l)), index_(0) { }
03586 explicit VectorIterator(Vector<const T> data) : data_(data), index_(0) { }
03587 T GetNext() { return data_[index_++]; }
03588 bool has_more() { return index_ < data_.length(); }
03589 private:
03590 Vector<const T> data_;
03591 int index_;
03592 };
03593
03594
03595
03596 class Oddball: public HeapObject {
03597 public:
03598
03599 DECL_ACCESSORS(to_string, String)
03600
03601
03602 DECL_ACCESSORS(to_number, Object)
03603
03604
03605 static inline Oddball* cast(Object* obj);
03606
03607
03608 void OddballIterateBody(ObjectVisitor* v);
03609 #ifdef DEBUG
03610 void OddballVerify();
03611 #endif
03612
03613
03614 Object* Initialize(const char* to_string, Object* to_number);
03615
03616
03617 static const int kToStringOffset = HeapObject::kHeaderSize;
03618 static const int kToNumberOffset = kToStringOffset + kPointerSize;
03619 static const int kSize = kToNumberOffset + kPointerSize;
03620
03621 private:
03622 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball);
03623 };
03624
03625
03626
03627
03628
03629 class Proxy: public HeapObject {
03630 public:
03631
03632 inline Address proxy();
03633 inline void set_proxy(Address value);
03634
03635
03636 static inline Proxy* cast(Object* obj);
03637
03638
03639 inline void ProxyIterateBody(ObjectVisitor* v);
03640 #ifdef DEBUG
03641 void ProxyPrint();
03642 void ProxyVerify();
03643 #endif
03644
03645
03646
03647 static const int kProxyOffset = HeapObject::kHeaderSize;
03648 static const int kSize = kProxyOffset + kPointerSize;
03649
03650 private:
03651 DISALLOW_IMPLICIT_CONSTRUCTORS(Proxy);
03652 };
03653
03654
03655
03656
03657
03658
03659
03660 class JSArray: public JSObject {
03661 public:
03662
03663 DECL_ACCESSORS(length, Object)
03664
03665 Object* JSArrayUpdateLengthFromIndex(uint32_t index, Object* value);
03666
03667
03668
03669
03670 Object* Initialize(int capacity);
03671
03672
03673 inline void SetContent(FixedArray* storage);
03674
03675
03676 Object* RemoveHoles();
03677
03678
03679 static inline JSArray* cast(Object* obj);
03680
03681
03682 #ifdef DEBUG
03683 void JSArrayPrint();
03684 void JSArrayVerify();
03685 #endif
03686
03687
03688 static const int kLengthOffset = JSObject::kHeaderSize;
03689 static const int kSize = kLengthOffset + kPointerSize;
03690
03691 private:
03692 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArray);
03693 };
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706 class AccessorInfo: public Struct {
03707 public:
03708 DECL_ACCESSORS(getter, Object)
03709 DECL_ACCESSORS(setter, Object)
03710 DECL_ACCESSORS(data, Object)
03711 DECL_ACCESSORS(name, Object)
03712 DECL_ACCESSORS(flag, Smi)
03713
03714 inline bool all_can_read();
03715 inline void set_all_can_read(bool value);
03716
03717 inline bool all_can_write();
03718 inline void set_all_can_write(bool value);
03719
03720 inline PropertyAttributes property_attributes();
03721 inline void set_property_attributes(PropertyAttributes attributes);
03722
03723 static inline AccessorInfo* cast(Object* obj);
03724
03725 #ifdef DEBUG
03726 void AccessorInfoPrint();
03727 void AccessorInfoVerify();
03728 #endif
03729
03730 static const int kGetterOffset = HeapObject::kHeaderSize;
03731 static const int kSetterOffset = kGetterOffset + kPointerSize;
03732 static const int kDataOffset = kSetterOffset + kPointerSize;
03733 static const int kNameOffset = kDataOffset + kPointerSize;
03734 static const int kFlagOffset = kNameOffset + kPointerSize;
03735 static const int kSize = kFlagOffset + kPointerSize;
03736
03737 private:
03738
03739 static const int kAllCanReadBit = 0;
03740 static const int kAllCanWriteBit = 1;
03741 class AttributesField: public BitField<PropertyAttributes, 2, 3> {};
03742
03743 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorInfo);
03744 };
03745
03746
03747 class AccessCheckInfo: public Struct {
03748 public:
03749 DECL_ACCESSORS(named_callback, Object)
03750 DECL_ACCESSORS(indexed_callback, Object)
03751 DECL_ACCESSORS(data, Object)
03752
03753 static inline AccessCheckInfo* cast(Object* obj);
03754
03755 #ifdef DEBUG
03756 void AccessCheckInfoPrint();
03757 void AccessCheckInfoVerify();
03758 #endif
03759
03760 static const int kNamedCallbackOffset = HeapObject::kHeaderSize;
03761 static const int kIndexedCallbackOffset = kNamedCallbackOffset + kPointerSize;
03762 static const int kDataOffset = kIndexedCallbackOffset + kPointerSize;
03763 static const int kSize = kDataOffset + kPointerSize;
03764
03765 private:
03766 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessCheckInfo);
03767 };
03768
03769
03770 class InterceptorInfo: public Struct {
03771 public:
03772 DECL_ACCESSORS(getter, Object)
03773 DECL_ACCESSORS(setter, Object)
03774 DECL_ACCESSORS(query, Object)
03775 DECL_ACCESSORS(deleter, Object)
03776 DECL_ACCESSORS(enumerator, Object)
03777 DECL_ACCESSORS(data, Object)
03778
03779 static inline InterceptorInfo* cast(Object* obj);
03780
03781 #ifdef DEBUG
03782 void InterceptorInfoPrint();
03783 void InterceptorInfoVerify();
03784 #endif
03785
03786 static const int kGetterOffset = HeapObject::kHeaderSize;
03787 static const int kSetterOffset = kGetterOffset + kPointerSize;
03788 static const int kQueryOffset = kSetterOffset + kPointerSize;
03789 static const int kDeleterOffset = kQueryOffset + kPointerSize;
03790 static const int kEnumeratorOffset = kDeleterOffset + kPointerSize;
03791 static const int kDataOffset = kEnumeratorOffset + kPointerSize;
03792 static const int kSize = kDataOffset + kPointerSize;
03793
03794 private:
03795 DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo);
03796 };
03797
03798
03799 class CallHandlerInfo: public Struct {
03800 public:
03801 DECL_ACCESSORS(callback, Object)
03802 DECL_ACCESSORS(data, Object)
03803
03804 static inline CallHandlerInfo* cast(Object* obj);
03805
03806 #ifdef DEBUG
03807 void CallHandlerInfoPrint();
03808 void CallHandlerInfoVerify();
03809 #endif
03810
03811 static const int kCallbackOffset = HeapObject::kHeaderSize;
03812 static const int kDataOffset = kCallbackOffset + kPointerSize;
03813 static const int kSize = kDataOffset + kPointerSize;
03814
03815 private:
03816 DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo);
03817 };
03818
03819
03820 class TemplateInfo: public Struct {
03821 public:
03822 DECL_ACCESSORS(tag, Object)
03823 DECL_ACCESSORS(property_list, Object)
03824
03825 #ifdef DEBUG
03826 void TemplateInfoVerify();
03827 #endif
03828
03829 static const int kTagOffset = HeapObject::kHeaderSize;
03830 static const int kPropertyListOffset = kTagOffset + kPointerSize;
03831 static const int kHeaderSize = kPropertyListOffset + kPointerSize;
03832 protected:
03833 friend class AGCCVersionRequiresThisClassToHaveAFriendSoHereItIs;
03834 DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo);
03835 };
03836
03837
03838 class FunctionTemplateInfo: public TemplateInfo {
03839 public:
03840 DECL_ACCESSORS(serial_number, Object)
03841 DECL_ACCESSORS(call_code, Object)
03842 DECL_ACCESSORS(property_accessors, Object)
03843 DECL_ACCESSORS(prototype_template, Object)
03844 DECL_ACCESSORS(parent_template, Object)
03845 DECL_ACCESSORS(named_property_handler, Object)
03846 DECL_ACCESSORS(indexed_property_handler, Object)
03847 DECL_ACCESSORS(instance_template, Object)
03848 DECL_ACCESSORS(class_name, Object)
03849 DECL_ACCESSORS(signature, Object)
03850 DECL_ACCESSORS(instance_call_handler, Object)
03851 DECL_ACCESSORS(access_check_info, Object)
03852 DECL_ACCESSORS(flag, Smi)
03853
03854
03855 DECL_BOOLEAN_ACCESSORS(hidden_prototype)
03856 DECL_BOOLEAN_ACCESSORS(undetectable)
03857
03858
03859 DECL_BOOLEAN_ACCESSORS(needs_access_check)
03860
03861 static inline FunctionTemplateInfo* cast(Object* obj);
03862
03863 #ifdef DEBUG
03864 void FunctionTemplateInfoPrint();
03865 void FunctionTemplateInfoVerify();
03866 #endif
03867
03868 static const int kSerialNumberOffset = TemplateInfo::kHeaderSize;
03869 static const int kCallCodeOffset = kSerialNumberOffset + kPointerSize;
03870 static const int kPropertyAccessorsOffset = kCallCodeOffset + kPointerSize;
03871 static const int kPrototypeTemplateOffset =
03872 kPropertyAccessorsOffset + kPointerSize;
03873 static const int kParentTemplateOffset =
03874 kPrototypeTemplateOffset + kPointerSize;
03875 static const int kNamedPropertyHandlerOffset =
03876 kParentTemplateOffset + kPointerSize;
03877 static const int kIndexedPropertyHandlerOffset =
03878 kNamedPropertyHandlerOffset + kPointerSize;
03879 static const int kInstanceTemplateOffset =
03880 kIndexedPropertyHandlerOffset + kPointerSize;
03881 static const int kClassNameOffset = kInstanceTemplateOffset + kPointerSize;
03882 static const int kSignatureOffset = kClassNameOffset + kPointerSize;
03883 static const int kInstanceCallHandlerOffset = kSignatureOffset + kPointerSize;
03884 static const int kAccessCheckInfoOffset =
03885 kInstanceCallHandlerOffset + kPointerSize;
03886 static const int kFlagOffset = kAccessCheckInfoOffset + kPointerSize;
03887 static const int kSize = kFlagOffset + kPointerSize;
03888
03889 private:
03890
03891 static const int kHiddenPrototypeBit = 0;
03892 static const int kUndetectableBit = 1;
03893 static const int kNeedsAccessCheckBit = 2;
03894
03895 DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo);
03896 };
03897
03898
03899 class ObjectTemplateInfo: public TemplateInfo {
03900 public:
03901 DECL_ACCESSORS(constructor, Object)
03902 DECL_ACCESSORS(internal_field_count, Object)
03903
03904 static inline ObjectTemplateInfo* cast(Object* obj);
03905
03906 #ifdef DEBUG
03907 void ObjectTemplateInfoPrint();
03908 void ObjectTemplateInfoVerify();
03909 #endif
03910
03911 static const int kConstructorOffset = TemplateInfo::kHeaderSize;
03912 static const int kInternalFieldCountOffset =
03913 kConstructorOffset + kPointerSize;
03914 static const int kSize = kInternalFieldCountOffset + kHeaderSize;
03915 };
03916
03917
03918 class SignatureInfo: public Struct {
03919 public:
03920 DECL_ACCESSORS(receiver, Object)
03921 DECL_ACCESSORS(args, Object)
03922
03923 static inline SignatureInfo* cast(Object* obj);
03924
03925 #ifdef DEBUG
03926 void SignatureInfoPrint();
03927 void SignatureInfoVerify();
03928 #endif
03929
03930 static const int kReceiverOffset = Struct::kHeaderSize;
03931 static const int kArgsOffset = kReceiverOffset + kPointerSize;
03932 static const int kSize = kArgsOffset + kPointerSize;
03933
03934 private:
03935 DISALLOW_IMPLICIT_CONSTRUCTORS(SignatureInfo);
03936 };
03937
03938
03939 class TypeSwitchInfo: public Struct {
03940 public:
03941 DECL_ACCESSORS(types, Object)
03942
03943 static inline TypeSwitchInfo* cast(Object* obj);
03944
03945 #ifdef DEBUG
03946 void TypeSwitchInfoPrint();
03947 void TypeSwitchInfoVerify();
03948 #endif
03949
03950 static const int kTypesOffset = Struct::kHeaderSize;
03951 static const int kSize = kTypesOffset + kPointerSize;
03952 };
03953
03954
03955
03956
03957 class DebugInfo: public Struct {
03958 public:
03959
03960 DECL_ACCESSORS(shared, SharedFunctionInfo)
03961
03962 DECL_ACCESSORS(original_code, Code)
03963
03964
03965 DECL_ACCESSORS(code, Code)
03966
03967 DECL_ACCESSORS(break_points, FixedArray)
03968
03969
03970 bool HasBreakPoint(int code_position);
03971
03972 Object* GetBreakPointInfo(int code_position);
03973
03974 static void ClearBreakPoint(Handle<DebugInfo> debug_info,
03975 int code_position,
03976 Handle<Object> break_point_object);
03977
03978 static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_position,
03979 int source_position, int statement_position,
03980 Handle<Object> break_point_object);
03981
03982 Object* GetBreakPointObjects(int code_position);
03983
03984 static Object* FindBreakPointInfo(Handle<DebugInfo> debug_info,
03985 Handle<Object> break_point_object);
03986
03987 int GetBreakPointCount();
03988
03989 static inline DebugInfo* cast(Object* obj);
03990
03991 #ifdef DEBUG
03992 void DebugInfoPrint();
03993 void DebugInfoVerify();
03994 #endif
03995
03996 static const int kSharedFunctionInfoIndex = Struct::kHeaderSize;
03997 static const int kOriginalCodeIndex = kSharedFunctionInfoIndex + kPointerSize;
03998 static const int kPatchedCodeIndex = kOriginalCodeIndex + kPointerSize;
03999 static const int kActiveBreakPointsCountIndex =
04000 kPatchedCodeIndex + kPointerSize;
04001 static const int kBreakPointsStateIndex =
04002 kActiveBreakPointsCountIndex + kPointerSize;
04003 static const int kSize = kBreakPointsStateIndex + kPointerSize;
04004
04005 private:
04006 static const int kNoBreakPointInfo = -1;
04007
04008
04009 int GetBreakPointInfoIndex(int code_position);
04010
04011 DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo);
04012 };
04013
04014
04015
04016
04017
04018 class BreakPointInfo: public Struct {
04019 public:
04020
04021 DECL_ACCESSORS(code_position, Smi)
04022
04023 DECL_ACCESSORS(source_position, Smi)
04024
04025
04026 DECL_ACCESSORS(statement_position, Smi)
04027
04028 DECL_ACCESSORS(break_point_objects, Object)
04029
04030
04031 static void ClearBreakPoint(Handle<BreakPointInfo> info,
04032 Handle<Object> break_point_object);
04033
04034 static void SetBreakPoint(Handle<BreakPointInfo> info,
04035 Handle<Object> break_point_object);
04036
04037 static bool HasBreakPointObject(Handle<BreakPointInfo> info,
04038 Handle<Object> break_point_object);
04039
04040 int GetBreakPointCount();
04041
04042 static inline BreakPointInfo* cast(Object* obj);
04043
04044 #ifdef DEBUG
04045 void BreakPointInfoPrint();
04046 void BreakPointInfoVerify();
04047 #endif
04048
04049 static const int kCodePositionIndex = Struct::kHeaderSize;
04050 static const int kSourcePositionIndex = kCodePositionIndex + kPointerSize;
04051 static const int kStatementPositionIndex =
04052 kSourcePositionIndex + kPointerSize;
04053 static const int kBreakPointObjectsIndex =
04054 kStatementPositionIndex + kPointerSize;
04055 static const int kSize = kBreakPointObjectsIndex + kPointerSize;
04056
04057 private:
04058 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo);
04059 };
04060
04061
04062 #undef DECL_BOOLEAN_ACCESSORS
04063 #undef DECL_ACCESSORS
04064
04065
04066
04067
04068 class ObjectVisitor BASE_EMBEDDED {
04069 public:
04070 virtual ~ObjectVisitor() {}
04071
04072
04073
04074 virtual void VisitPointers(Object** start, Object** end) = 0;
04075
04076
04077
04078
04079
04080 virtual void BeginCodeIteration(Code* code);
04081
04082
04083 virtual void VisitCodeTarget(RelocInfo* rinfo);
04084
04085
04086 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {}
04087
04088
04089 virtual void VisitDebugTarget(RelocInfo* rinfo);
04090
04091
04092 virtual void EndCodeIteration(Code* code) {}
04093
04094
04095 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); }
04096
04097
04098
04099
04100 virtual void VisitExternalReferences(Address* start, Address* end) {}
04101
04102 inline void VisitExternalReference(Address* p) {
04103 VisitExternalReferences(p, p + 1);
04104 }
04105
04106 #ifdef DEBUG
04107
04108
04109 virtual void Synchronize(const char* tag) {}
04110 #endif
04111 };
04112
04113
04114
04115
04116 class BooleanBit : public AllStatic {
04117 public:
04118 static inline bool get(Smi* smi, int bit_position) {
04119 return get(smi->value(), bit_position);
04120 }
04121
04122 static inline bool get(int value, int bit_position) {
04123 return (value & (1 << bit_position)) != 0;
04124 }
04125
04126 static inline Smi* set(Smi* smi, int bit_position, bool v) {
04127 return Smi::FromInt(set(smi->value(), bit_position, v));
04128 }
04129
04130 static inline int set(int value, int bit_position, bool v) {
04131 if (v) {
04132 value |= (1 << bit_position);
04133 } else {
04134 value &= ~(1 << bit_position);
04135 }
04136 return value;
04137 }
04138 };
04139
04140 } }
04141
04142 #endif // V8_OBJECTS_H_