OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 | 402 |
403 bool MaybeObject::IsRetryAfterGC() { | 403 bool MaybeObject::IsRetryAfterGC() { |
404 return HAS_FAILURE_TAG(this) | 404 return HAS_FAILURE_TAG(this) |
405 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; | 405 && Failure::cast(this)->type() == Failure::RETRY_AFTER_GC; |
406 } | 406 } |
407 | 407 |
408 | 408 |
409 bool MaybeObject::IsOutOfMemory() { | 409 bool MaybeObject::IsOutOfMemory() { |
410 return HAS_FAILURE_TAG(this) | 410 return HAS_FAILURE_TAG(this) |
411 && Failure::cast(this)->IsOutOfMemoryException(); | 411 && Failure::cast(this)->IsOutOfMemoryException(); |
412 } | 412 } |
413 | 413 |
414 | 414 |
415 bool MaybeObject::IsException() { | 415 bool MaybeObject::IsException() { |
416 return this == Failure::Exception(); | 416 return this == Failure::Exception(); |
417 } | 417 } |
418 | 418 |
419 | 419 |
420 bool MaybeObject::IsTheHole() { | 420 bool MaybeObject::IsTheHole() { |
421 return this == Heap::the_hole_value(); | 421 return this == Heap::the_hole_value(); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 Failure* Failure::cast(MaybeObject* obj) { | 425 Failure* Failure::cast(MaybeObject* obj) { |
426 ASSERT(HAS_FAILURE_TAG(obj)); | 426 ASSERT(HAS_FAILURE_TAG(obj)); |
427 return reinterpret_cast<Failure*>(obj); | 427 return reinterpret_cast<Failure*>(obj); |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 bool Object::IsJSObject() { | 431 bool Object::IsJSObject() { |
432 return IsHeapObject() | 432 return IsHeapObject() |
433 && HeapObject::cast(this)->map()->instance_type() >= FIRST_JS_OBJECT_TYPE; | 433 && HeapObject::cast(this)->map()->instance_type() >= FIRST_JS_OBJECT_TYPE; |
434 } | 434 } |
435 | 435 |
436 | 436 |
437 bool Object::IsJSContextExtensionObject() { | 437 bool Object::IsJSContextExtensionObject() { |
438 return IsHeapObject() | 438 return IsHeapObject() |
439 && (HeapObject::cast(this)->map()->instance_type() == | 439 && (HeapObject::cast(this)->map()->instance_type() == |
440 JS_CONTEXT_EXTENSION_OBJECT_TYPE); | 440 JS_CONTEXT_EXTENSION_OBJECT_TYPE); |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 bool Object::IsMap() { | 444 bool Object::IsMap() { |
445 return Object::IsHeapObject() | 445 return Object::IsHeapObject() |
446 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; | 446 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; |
447 } | 447 } |
448 | 448 |
449 | 449 |
450 bool Object::IsFixedArray() { | 450 bool Object::IsFixedArray() { |
451 return Object::IsHeapObject() | 451 return Object::IsHeapObject() |
452 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; | 452 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; |
453 } | 453 } |
454 | 454 |
455 | 455 |
456 bool Object::IsDescriptorArray() { | 456 bool Object::IsDescriptorArray() { |
457 return IsFixedArray(); | 457 return IsFixedArray(); |
458 } | 458 } |
459 | 459 |
460 | 460 |
461 bool Object::IsDeoptimizationInputData() { | 461 bool Object::IsDeoptimizationInputData() { |
462 // Must be a fixed array. | 462 // Must be a fixed array. |
(...skipping 25 matching lines...) Expand all Loading... |
488 bool Object::IsContext() { | 488 bool Object::IsContext() { |
489 return Object::IsHeapObject() | 489 return Object::IsHeapObject() |
490 && (HeapObject::cast(this)->map() == Heap::context_map() || | 490 && (HeapObject::cast(this)->map() == Heap::context_map() || |
491 HeapObject::cast(this)->map() == Heap::catch_context_map() || | 491 HeapObject::cast(this)->map() == Heap::catch_context_map() || |
492 HeapObject::cast(this)->map() == Heap::global_context_map()); | 492 HeapObject::cast(this)->map() == Heap::global_context_map()); |
493 } | 493 } |
494 | 494 |
495 | 495 |
496 bool Object::IsCatchContext() { | 496 bool Object::IsCatchContext() { |
497 return Object::IsHeapObject() | 497 return Object::IsHeapObject() |
498 && HeapObject::cast(this)->map() == Heap::catch_context_map(); | 498 && HeapObject::cast(this)->map() == Heap::catch_context_map(); |
499 } | 499 } |
500 | 500 |
501 | 501 |
502 bool Object::IsGlobalContext() { | 502 bool Object::IsGlobalContext() { |
503 return Object::IsHeapObject() | 503 return Object::IsHeapObject() |
504 && HeapObject::cast(this)->map() == Heap::global_context_map(); | 504 && HeapObject::cast(this)->map() == Heap::global_context_map(); |
505 } | 505 } |
506 | 506 |
507 | 507 |
508 bool Object::IsJSFunction() { | 508 bool Object::IsJSFunction() { |
509 return Object::IsHeapObject() | 509 return Object::IsHeapObject() |
510 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE; | 510 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE; |
511 } | 511 } |
512 | 512 |
513 | 513 |
514 template <> inline bool Is<JSFunction>(Object* obj) { | 514 template <> inline bool Is<JSFunction>(Object* obj) { |
515 return obj->IsJSFunction(); | 515 return obj->IsJSFunction(); |
516 } | 516 } |
517 | 517 |
518 | 518 |
519 bool Object::IsCode() { | 519 bool Object::IsCode() { |
520 return Object::IsHeapObject() | 520 return Object::IsHeapObject() |
521 && HeapObject::cast(this)->map()->instance_type() == CODE_TYPE; | 521 && HeapObject::cast(this)->map()->instance_type() == CODE_TYPE; |
522 } | 522 } |
523 | 523 |
524 | 524 |
525 bool Object::IsOddball() { | 525 bool Object::IsOddball() { |
526 return Object::IsHeapObject() | 526 return Object::IsHeapObject() |
527 && HeapObject::cast(this)->map()->instance_type() == ODDBALL_TYPE; | 527 && HeapObject::cast(this)->map()->instance_type() == ODDBALL_TYPE; |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 bool Object::IsJSGlobalPropertyCell() { | 531 bool Object::IsJSGlobalPropertyCell() { |
532 return Object::IsHeapObject() | 532 return Object::IsHeapObject() |
533 && HeapObject::cast(this)->map()->instance_type() | 533 && HeapObject::cast(this)->map()->instance_type() |
534 == JS_GLOBAL_PROPERTY_CELL_TYPE; | 534 == JS_GLOBAL_PROPERTY_CELL_TYPE; |
535 } | 535 } |
536 | 536 |
537 | 537 |
538 bool Object::IsSharedFunctionInfo() { | 538 bool Object::IsSharedFunctionInfo() { |
539 return Object::IsHeapObject() && | 539 return Object::IsHeapObject() && |
540 (HeapObject::cast(this)->map()->instance_type() == | 540 (HeapObject::cast(this)->map()->instance_type() == |
541 SHARED_FUNCTION_INFO_TYPE); | 541 SHARED_FUNCTION_INFO_TYPE); |
542 } | 542 } |
543 | 543 |
544 | 544 |
545 bool Object::IsJSValue() { | 545 bool Object::IsJSValue() { |
546 return Object::IsHeapObject() | 546 return Object::IsHeapObject() |
547 && HeapObject::cast(this)->map()->instance_type() == JS_VALUE_TYPE; | 547 && HeapObject::cast(this)->map()->instance_type() == JS_VALUE_TYPE; |
548 } | 548 } |
549 | 549 |
550 | 550 |
| 551 bool Object::IsJSMessageObject() { |
| 552 return Object::IsHeapObject() |
| 553 && (HeapObject::cast(this)->map()->instance_type() == |
| 554 JS_MESSAGE_OBJECT_TYPE); |
| 555 } |
| 556 |
| 557 |
551 bool Object::IsStringWrapper() { | 558 bool Object::IsStringWrapper() { |
552 return IsJSValue() && JSValue::cast(this)->value()->IsString(); | 559 return IsJSValue() && JSValue::cast(this)->value()->IsString(); |
553 } | 560 } |
554 | 561 |
555 | 562 |
556 bool Object::IsProxy() { | 563 bool Object::IsProxy() { |
557 return Object::IsHeapObject() | 564 return Object::IsHeapObject() |
558 && HeapObject::cast(this)->map()->instance_type() == PROXY_TYPE; | 565 && HeapObject::cast(this)->map()->instance_type() == PROXY_TYPE; |
559 } | 566 } |
560 | 567 |
561 | 568 |
562 bool Object::IsBoolean() { | 569 bool Object::IsBoolean() { |
563 return IsTrue() || IsFalse(); | 570 return IsTrue() || IsFalse(); |
564 } | 571 } |
565 | 572 |
566 | 573 |
567 bool Object::IsJSArray() { | 574 bool Object::IsJSArray() { |
568 return Object::IsHeapObject() | 575 return Object::IsHeapObject() |
569 && HeapObject::cast(this)->map()->instance_type() == JS_ARRAY_TYPE; | 576 && HeapObject::cast(this)->map()->instance_type() == JS_ARRAY_TYPE; |
570 } | 577 } |
571 | 578 |
572 | 579 |
573 bool Object::IsJSRegExp() { | 580 bool Object::IsJSRegExp() { |
574 return Object::IsHeapObject() | 581 return Object::IsHeapObject() |
575 && HeapObject::cast(this)->map()->instance_type() == JS_REGEXP_TYPE; | 582 && HeapObject::cast(this)->map()->instance_type() == JS_REGEXP_TYPE; |
576 } | 583 } |
577 | 584 |
578 | 585 |
579 template <> inline bool Is<JSArray>(Object* obj) { | 586 template <> inline bool Is<JSArray>(Object* obj) { |
580 return obj->IsJSArray(); | 587 return obj->IsJSArray(); |
581 } | 588 } |
582 | 589 |
583 | 590 |
584 bool Object::IsHashTable() { | 591 bool Object::IsHashTable() { |
585 return Object::IsHeapObject() | 592 return Object::IsHeapObject() |
586 && HeapObject::cast(this)->map() == Heap::hash_table_map(); | 593 && HeapObject::cast(this)->map() == Heap::hash_table_map(); |
587 } | 594 } |
588 | 595 |
589 | 596 |
590 bool Object::IsDictionary() { | 597 bool Object::IsDictionary() { |
591 return IsHashTable() && this != Heap::symbol_table(); | 598 return IsHashTable() && this != Heap::symbol_table(); |
592 } | 599 } |
593 | 600 |
594 | 601 |
595 bool Object::IsSymbolTable() { | 602 bool Object::IsSymbolTable() { |
596 return IsHashTable() && this == Heap::raw_unchecked_symbol_table(); | 603 return IsHashTable() && this == Heap::raw_unchecked_symbol_table(); |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 case JS_FUNCTION_TYPE: | 1285 case JS_FUNCTION_TYPE: |
1279 return JSFunction::kSize; | 1286 return JSFunction::kSize; |
1280 case JS_VALUE_TYPE: | 1287 case JS_VALUE_TYPE: |
1281 return JSValue::kSize; | 1288 return JSValue::kSize; |
1282 case JS_ARRAY_TYPE: | 1289 case JS_ARRAY_TYPE: |
1283 return JSValue::kSize; | 1290 return JSValue::kSize; |
1284 case JS_REGEXP_TYPE: | 1291 case JS_REGEXP_TYPE: |
1285 return JSValue::kSize; | 1292 return JSValue::kSize; |
1286 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 1293 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
1287 return JSObject::kHeaderSize; | 1294 return JSObject::kHeaderSize; |
| 1295 case JS_MESSAGE_OBJECT_TYPE: |
| 1296 return JSMessageObject::kSize; |
1288 default: | 1297 default: |
1289 UNREACHABLE(); | 1298 UNREACHABLE(); |
1290 return 0; | 1299 return 0; |
1291 } | 1300 } |
1292 } | 1301 } |
1293 | 1302 |
1294 | 1303 |
1295 int JSObject::GetInternalFieldCount() { | 1304 int JSObject::GetInternalFieldCount() { |
1296 ASSERT(1 << kPointerSizeLog2 == kPointerSize); | 1305 ASSERT(1 << kPointerSizeLog2 == kPointerSize); |
1297 // Make sure to adjust for the number of in-object properties. These | 1306 // Make sure to adjust for the number of in-object properties. These |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3282 ACCESSORS(JSValue, value, Object, kValueOffset) | 3291 ACCESSORS(JSValue, value, Object, kValueOffset) |
3283 | 3292 |
3284 | 3293 |
3285 JSValue* JSValue::cast(Object* obj) { | 3294 JSValue* JSValue::cast(Object* obj) { |
3286 ASSERT(obj->IsJSValue()); | 3295 ASSERT(obj->IsJSValue()); |
3287 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); | 3296 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); |
3288 return reinterpret_cast<JSValue*>(obj); | 3297 return reinterpret_cast<JSValue*>(obj); |
3289 } | 3298 } |
3290 | 3299 |
3291 | 3300 |
| 3301 ACCESSORS(JSMessageObject, type, String, kTypeOffset) |
| 3302 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset) |
| 3303 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) |
| 3304 ACCESSORS(JSMessageObject, stack_trace, Object, kStackTraceOffset) |
| 3305 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) |
| 3306 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) |
| 3307 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) |
| 3308 |
| 3309 |
| 3310 JSMessageObject* JSMessageObject::cast(Object* obj) { |
| 3311 ASSERT(obj->IsJSMessageObject()); |
| 3312 ASSERT(HeapObject::cast(obj)->Size() == JSMessageObject::kSize); |
| 3313 return reinterpret_cast<JSMessageObject*>(obj); |
| 3314 } |
| 3315 |
| 3316 |
3292 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 3317 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
3293 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 3318 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) |
3294 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 3319 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
3295 | 3320 |
3296 | 3321 |
3297 byte* Code::instruction_start() { | 3322 byte* Code::instruction_start() { |
3298 return FIELD_ADDR(this, kHeaderSize); | 3323 return FIELD_ADDR(this, kHeaderSize); |
3299 } | 3324 } |
3300 | 3325 |
3301 | 3326 |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3876 #undef WRITE_INT_FIELD | 3901 #undef WRITE_INT_FIELD |
3877 #undef READ_SHORT_FIELD | 3902 #undef READ_SHORT_FIELD |
3878 #undef WRITE_SHORT_FIELD | 3903 #undef WRITE_SHORT_FIELD |
3879 #undef READ_BYTE_FIELD | 3904 #undef READ_BYTE_FIELD |
3880 #undef WRITE_BYTE_FIELD | 3905 #undef WRITE_BYTE_FIELD |
3881 | 3906 |
3882 | 3907 |
3883 } } // namespace v8::internal | 3908 } } // namespace v8::internal |
3884 | 3909 |
3885 #endif // V8_OBJECTS_INL_H_ | 3910 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |