| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 #define BOOL_ACCESSORS(holder, field, name, offset) \ | 101 #define BOOL_ACCESSORS(holder, field, name, offset) \ |
| 102 bool holder::name() { \ | 102 bool holder::name() { \ |
| 103 return BooleanBit::get(field(), offset); \ | 103 return BooleanBit::get(field(), offset); \ |
| 104 } \ | 104 } \ |
| 105 void holder::set_##name(bool value) { \ | 105 void holder::set_##name(bool value) { \ |
| 106 set_##field(BooleanBit::set(field(), offset, value)); \ | 106 set_##field(BooleanBit::set(field(), offset, value)); \ |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 #define GET_HEAP (HeapObject::cast(this)->GetHeap()) | |
| 111 | |
| 112 | |
| 113 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { | 110 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) { |
| 114 // There is a constraint on the object; check. | 111 // There is a constraint on the object; check. |
| 115 if (!this->IsJSObject()) return false; | 112 if (!this->IsJSObject()) return false; |
| 116 // Fetch the constructor function of the object. | 113 // Fetch the constructor function of the object. |
| 117 Object* cons_obj = JSObject::cast(this)->map()->constructor(); | 114 Object* cons_obj = JSObject::cast(this)->map()->constructor(); |
| 118 if (!cons_obj->IsJSFunction()) return false; | 115 if (!cons_obj->IsJSFunction()) return false; |
| 119 JSFunction* fun = JSFunction::cast(cons_obj); | 116 JSFunction* fun = JSFunction::cast(cons_obj); |
| 120 // Iterate through the chain of inheriting function templates to | 117 // Iterate through the chain of inheriting function templates to |
| 121 // see if the required one occurs. | 118 // see if the required one occurs. |
| 122 for (Object* type = fun->shared()->function_data(); | 119 for (Object* type = fun->shared()->function_data(); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; | 441 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; |
| 445 } | 442 } |
| 446 | 443 |
| 447 | 444 |
| 448 bool Object::IsDescriptorArray() { | 445 bool Object::IsDescriptorArray() { |
| 449 return IsFixedArray(); | 446 return IsFixedArray(); |
| 450 } | 447 } |
| 451 | 448 |
| 452 | 449 |
| 453 bool Object::IsContext() { | 450 bool Object::IsContext() { |
| 454 return Object::IsHeapObject() | 451 if (Object::IsHeapObject()) { |
| 455 && (HeapObject::cast(this)->map() == GET_HEAP->context_map() || | 452 Heap* heap = HeapObject::cast(this)->GetHeap(); |
| 456 HeapObject::cast(this)->map() == GET_HEAP->catch_context_map() || | 453 return (HeapObject::cast(this)->map() == heap->context_map() || |
| 457 HeapObject::cast(this)->map() == GET_HEAP->global_context_map()); | 454 HeapObject::cast(this)->map() == heap->catch_context_map() || |
| 455 HeapObject::cast(this)->map() == heap->global_context_map()); |
| 456 } |
| 457 return false; |
| 458 } | 458 } |
| 459 | 459 |
| 460 | 460 |
| 461 bool Object::IsCatchContext() { | 461 bool Object::IsCatchContext() { |
| 462 return Object::IsHeapObject() | 462 return Object::IsHeapObject() && |
| 463 && HeapObject::cast(this)->map() == GET_HEAP->catch_context_map(); | 463 HeapObject::cast(this)->map() == |
| 464 HeapObject::cast(this)->GetHeap()->catch_context_map(); |
| 464 } | 465 } |
| 465 | 466 |
| 466 | 467 |
| 467 bool Object::IsGlobalContext() { | 468 bool Object::IsGlobalContext() { |
| 468 return Object::IsHeapObject() | 469 return Object::IsHeapObject() && |
| 469 && HeapObject::cast(this)->map() == GET_HEAP->global_context_map(); | 470 HeapObject::cast(this)->map() == |
| 471 HeapObject::cast(this)->GetHeap()->global_context_map(); |
| 470 } | 472 } |
| 471 | 473 |
| 472 | 474 |
| 473 bool Object::IsJSFunction() { | 475 bool Object::IsJSFunction() { |
| 474 return Object::IsHeapObject() | 476 return Object::IsHeapObject() |
| 475 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE; | 477 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE; |
| 476 } | 478 } |
| 477 | 479 |
| 478 | 480 |
| 479 template <> inline bool Is<JSFunction>(Object* obj) { | 481 template <> inline bool Is<JSFunction>(Object* obj) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 && HeapObject::cast(this)->map()->instance_type() == JS_REGEXP_TYPE; | 543 && HeapObject::cast(this)->map()->instance_type() == JS_REGEXP_TYPE; |
| 542 } | 544 } |
| 543 | 545 |
| 544 | 546 |
| 545 template <> inline bool Is<JSArray>(Object* obj) { | 547 template <> inline bool Is<JSArray>(Object* obj) { |
| 546 return obj->IsJSArray(); | 548 return obj->IsJSArray(); |
| 547 } | 549 } |
| 548 | 550 |
| 549 | 551 |
| 550 bool Object::IsHashTable() { | 552 bool Object::IsHashTable() { |
| 551 return Object::IsHeapObject() | 553 return Object::IsHeapObject() && |
| 552 && HeapObject::cast(this)->map() == GET_HEAP->hash_table_map(); | 554 HeapObject::cast(this)->map() == |
| 555 HeapObject::cast(this)->GetHeap()->hash_table_map(); |
| 553 } | 556 } |
| 554 | 557 |
| 555 | 558 |
| 556 bool Object::IsDictionary() { | 559 bool Object::IsDictionary() { |
| 557 return IsHashTable() && this != GET_HEAP->symbol_table(); | 560 return IsHashTable() && this != |
| 561 HeapObject::cast(this)->GetHeap()->symbol_table(); |
| 558 } | 562 } |
| 559 | 563 |
| 560 | 564 |
| 561 bool Object::IsSymbolTable() { | 565 bool Object::IsSymbolTable() { |
| 562 return IsHashTable() && this == GET_HEAP->raw_unchecked_symbol_table(); | 566 return IsHashTable() && this == |
| 567 HeapObject::cast(this)->GetHeap()->raw_unchecked_symbol_table(); |
| 563 } | 568 } |
| 564 | 569 |
| 565 | 570 |
| 566 bool Object::IsJSFunctionResultCache() { | 571 bool Object::IsJSFunctionResultCache() { |
| 567 if (!IsFixedArray()) return false; | 572 if (!IsFixedArray()) return false; |
| 568 FixedArray* self = FixedArray::cast(this); | 573 FixedArray* self = FixedArray::cast(this); |
| 569 int length = self->length(); | 574 int length = self->length(); |
| 570 if (length < JSFunctionResultCache::kEntriesIndex) return false; | 575 if (length < JSFunctionResultCache::kEntriesIndex) return false; |
| 571 if ((length - JSFunctionResultCache::kEntriesIndex) | 576 if ((length - JSFunctionResultCache::kEntriesIndex) |
| 572 % JSFunctionResultCache::kEntrySize != 0) { | 577 % JSFunctionResultCache::kEntrySize != 0) { |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 | 1470 |
| 1466 void FixedArray::set_undefined(Heap* heap, int index) { | 1471 void FixedArray::set_undefined(Heap* heap, int index) { |
| 1467 ASSERT(index >= 0 && index < this->length()); | 1472 ASSERT(index >= 0 && index < this->length()); |
| 1468 ASSERT(!heap->InNewSpace(heap->undefined_value())); | 1473 ASSERT(!heap->InNewSpace(heap->undefined_value())); |
| 1469 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, | 1474 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, |
| 1470 heap->undefined_value()); | 1475 heap->undefined_value()); |
| 1471 } | 1476 } |
| 1472 | 1477 |
| 1473 | 1478 |
| 1474 void FixedArray::set_null(int index) { | 1479 void FixedArray::set_null(int index) { |
| 1475 set_null(GetHeap(),index); | 1480 set_null(GetHeap(), index); |
| 1476 } | 1481 } |
| 1477 | 1482 |
| 1478 | 1483 |
| 1479 void FixedArray::set_null(Heap* heap, int index) { | 1484 void FixedArray::set_null(Heap* heap, int index) { |
| 1480 ASSERT(index >= 0 && index < this->length()); | 1485 ASSERT(index >= 0 && index < this->length()); |
| 1481 ASSERT(!heap->InNewSpace(heap->null_value())); | 1486 ASSERT(!heap->InNewSpace(heap->null_value())); |
| 1482 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); | 1487 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); |
| 1483 } | 1488 } |
| 1484 | 1489 |
| 1485 | 1490 |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 void ExternalFloatArray::set(int index, float value) { | 2098 void ExternalFloatArray::set(int index, float value) { |
| 2094 ASSERT((index >= 0) && (index < this->length())); | 2099 ASSERT((index >= 0) && (index < this->length())); |
| 2095 float* ptr = static_cast<float*>(external_pointer()); | 2100 float* ptr = static_cast<float*>(external_pointer()); |
| 2096 ptr[index] = value; | 2101 ptr[index] = value; |
| 2097 } | 2102 } |
| 2098 | 2103 |
| 2099 inline Scavenger Map::scavenger() { | 2104 inline Scavenger Map::scavenger() { |
| 2100 Scavenger callback = reinterpret_cast<Scavenger>( | 2105 Scavenger callback = reinterpret_cast<Scavenger>( |
| 2101 READ_INTPTR_FIELD(this, kScavengerCallbackOffset)); | 2106 READ_INTPTR_FIELD(this, kScavengerCallbackOffset)); |
| 2102 | 2107 |
| 2103 ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead. | 2108 ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead. |
| 2104 ASSERT(callback == Heap::GetScavenger(instance_type(), | 2109 ASSERT(callback == Heap::GetScavenger(instance_type(), |
| 2105 instance_size())); | 2110 instance_size())); |
| 2106 | 2111 |
| 2107 return callback; | 2112 return callback; |
| 2108 } | 2113 } |
| 2109 | 2114 |
| 2110 inline void Map::set_scavenger(Scavenger callback) { | 2115 inline void Map::set_scavenger(Scavenger callback) { |
| 2111 ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead. | 2116 ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead. |
| 2112 WRITE_INTPTR_FIELD(this, | 2117 WRITE_INTPTR_FIELD(this, |
| 2113 kScavengerCallbackOffset, | 2118 kScavengerCallbackOffset, |
| 2114 reinterpret_cast<intptr_t>(callback)); | 2119 reinterpret_cast<intptr_t>(callback)); |
| 2115 } | 2120 } |
| 2116 | 2121 |
| 2117 int Map::instance_size() { | 2122 int Map::instance_size() { |
| 2118 return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2; | 2123 return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2; |
| 2119 } | 2124 } |
| 2120 | 2125 |
| 2121 | 2126 |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3397 #undef WRITE_INT_FIELD | 3402 #undef WRITE_INT_FIELD |
| 3398 #undef READ_SHORT_FIELD | 3403 #undef READ_SHORT_FIELD |
| 3399 #undef WRITE_SHORT_FIELD | 3404 #undef WRITE_SHORT_FIELD |
| 3400 #undef READ_BYTE_FIELD | 3405 #undef READ_BYTE_FIELD |
| 3401 #undef WRITE_BYTE_FIELD | 3406 #undef WRITE_BYTE_FIELD |
| 3402 | 3407 |
| 3403 | 3408 |
| 3404 } } // namespace v8::internal | 3409 } } // namespace v8::internal |
| 3405 | 3410 |
| 3406 #endif // V8_OBJECTS_INL_H_ | 3411 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |