OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 void FixedArray::set_the_hole(int index) { | 2084 void FixedArray::set_the_hole(int index) { |
2085 ASSERT(map() != HEAP->fixed_cow_array_map()); | 2085 ASSERT(map() != HEAP->fixed_cow_array_map()); |
2086 ASSERT(index >= 0 && index < this->length()); | 2086 ASSERT(index >= 0 && index < this->length()); |
2087 ASSERT(!HEAP->InNewSpace(HEAP->the_hole_value())); | 2087 ASSERT(!HEAP->InNewSpace(HEAP->the_hole_value())); |
2088 WRITE_FIELD(this, | 2088 WRITE_FIELD(this, |
2089 kHeaderSize + index * kPointerSize, | 2089 kHeaderSize + index * kPointerSize, |
2090 GetHeap()->the_hole_value()); | 2090 GetHeap()->the_hole_value()); |
2091 } | 2091 } |
2092 | 2092 |
2093 | 2093 |
| 2094 void FixedArray::set_unchecked(int index, Smi* value) { |
| 2095 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); |
| 2096 int offset = kHeaderSize + index * kPointerSize; |
| 2097 WRITE_FIELD(this, offset, value); |
| 2098 } |
| 2099 |
| 2100 |
| 2101 void FixedArray::set_unchecked(Heap* heap, |
| 2102 int index, |
| 2103 Object* value, |
| 2104 WriteBarrierMode mode) { |
| 2105 int offset = kHeaderSize + index * kPointerSize; |
| 2106 WRITE_FIELD(this, offset, value); |
| 2107 CONDITIONAL_WRITE_BARRIER(heap, this, offset, value, mode); |
| 2108 } |
| 2109 |
| 2110 |
| 2111 void FixedArray::set_null_unchecked(Heap* heap, int index) { |
| 2112 ASSERT(index >= 0 && index < this->length()); |
| 2113 ASSERT(!heap->InNewSpace(heap->null_value())); |
| 2114 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); |
| 2115 } |
| 2116 |
| 2117 |
2094 double* FixedDoubleArray::data_start() { | 2118 double* FixedDoubleArray::data_start() { |
2095 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize)); | 2119 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize)); |
2096 } | 2120 } |
2097 | 2121 |
2098 | 2122 |
2099 Object** FixedArray::data_start() { | 2123 Object** FixedArray::data_start() { |
2100 return HeapObject::RawField(this, kHeaderSize); | 2124 return HeapObject::RawField(this, kHeaderSize); |
2101 } | 2125 } |
2102 | 2126 |
2103 | 2127 |
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3546 void Map::set_dictionary_map(bool value) { | 3570 void Map::set_dictionary_map(bool value) { |
3547 set_bit_field3(DictionaryMap::update(bit_field3(), value)); | 3571 set_bit_field3(DictionaryMap::update(bit_field3(), value)); |
3548 } | 3572 } |
3549 | 3573 |
3550 | 3574 |
3551 bool Map::is_dictionary_map() { | 3575 bool Map::is_dictionary_map() { |
3552 return DictionaryMap::decode(bit_field3()); | 3576 return DictionaryMap::decode(bit_field3()); |
3553 } | 3577 } |
3554 | 3578 |
3555 | 3579 |
| 3580 JSFunction* Map::unchecked_constructor() { |
| 3581 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); |
| 3582 } |
| 3583 |
| 3584 |
3556 Code::Flags Code::flags() { | 3585 Code::Flags Code::flags() { |
3557 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); | 3586 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); |
3558 } | 3587 } |
3559 | 3588 |
3560 | 3589 |
3561 inline bool Map::CanTrackAllocationSite() { | 3590 inline bool Map::CanTrackAllocationSite() { |
3562 return instance_type() == JS_ARRAY_TYPE; | 3591 return instance_type() == JS_ARRAY_TYPE; |
3563 } | 3592 } |
3564 | 3593 |
3565 | 3594 |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4708 set_start_position_and_type((start_position << kStartPositionShift) | 4737 set_start_position_and_type((start_position << kStartPositionShift) |
4709 | (start_position_and_type() & ~kStartPositionMask)); | 4738 | (start_position_and_type() & ~kStartPositionMask)); |
4710 } | 4739 } |
4711 | 4740 |
4712 | 4741 |
4713 Code* SharedFunctionInfo::code() { | 4742 Code* SharedFunctionInfo::code() { |
4714 return Code::cast(READ_FIELD(this, kCodeOffset)); | 4743 return Code::cast(READ_FIELD(this, kCodeOffset)); |
4715 } | 4744 } |
4716 | 4745 |
4717 | 4746 |
| 4747 Code* SharedFunctionInfo::unchecked_code() { |
| 4748 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset)); |
| 4749 } |
| 4750 |
| 4751 |
4718 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { | 4752 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { |
4719 WRITE_FIELD(this, kCodeOffset, value); | 4753 WRITE_FIELD(this, kCodeOffset, value); |
4720 CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode); | 4754 CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode); |
4721 } | 4755 } |
4722 | 4756 |
4723 | 4757 |
4724 void SharedFunctionInfo::ReplaceCode(Code* value) { | 4758 void SharedFunctionInfo::ReplaceCode(Code* value) { |
4725 // If the GC metadata field is already used then the function was | 4759 // If the GC metadata field is already used then the function was |
4726 // enqueued as a code flushing candidate and we remove it now. | 4760 // enqueued as a code flushing candidate and we remove it now. |
4727 if (code()->gc_metadata() != NULL) { | 4761 if (code()->gc_metadata() != NULL) { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5244 byte* Code::instruction_end() { | 5278 byte* Code::instruction_end() { |
5245 return instruction_start() + instruction_size(); | 5279 return instruction_start() + instruction_size(); |
5246 } | 5280 } |
5247 | 5281 |
5248 | 5282 |
5249 int Code::body_size() { | 5283 int Code::body_size() { |
5250 return RoundUp(instruction_size(), kObjectAlignment); | 5284 return RoundUp(instruction_size(), kObjectAlignment); |
5251 } | 5285 } |
5252 | 5286 |
5253 | 5287 |
| 5288 FixedArray* Code::unchecked_deoptimization_data() { |
| 5289 return reinterpret_cast<FixedArray*>( |
| 5290 READ_FIELD(this, kDeoptimizationDataOffset)); |
| 5291 } |
| 5292 |
| 5293 |
5254 ByteArray* Code::unchecked_relocation_info() { | 5294 ByteArray* Code::unchecked_relocation_info() { |
5255 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); | 5295 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); |
5256 } | 5296 } |
5257 | 5297 |
5258 | 5298 |
5259 byte* Code::relocation_start() { | 5299 byte* Code::relocation_start() { |
5260 return unchecked_relocation_info()->GetDataStartAddress(); | 5300 return unchecked_relocation_info()->GetDataStartAddress(); |
5261 } | 5301 } |
5262 | 5302 |
5263 | 5303 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5319 | 5359 |
5320 | 5360 |
5321 JSRegExp::Type JSRegExp::TypeTag() { | 5361 JSRegExp::Type JSRegExp::TypeTag() { |
5322 Object* data = this->data(); | 5362 Object* data = this->data(); |
5323 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; | 5363 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; |
5324 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); | 5364 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); |
5325 return static_cast<JSRegExp::Type>(smi->value()); | 5365 return static_cast<JSRegExp::Type>(smi->value()); |
5326 } | 5366 } |
5327 | 5367 |
5328 | 5368 |
| 5369 JSRegExp::Type JSRegExp::TypeTagUnchecked() { |
| 5370 Smi* smi = Smi::cast(DataAtUnchecked(kTagIndex)); |
| 5371 return static_cast<JSRegExp::Type>(smi->value()); |
| 5372 } |
| 5373 |
| 5374 |
5329 int JSRegExp::CaptureCount() { | 5375 int JSRegExp::CaptureCount() { |
5330 switch (TypeTag()) { | 5376 switch (TypeTag()) { |
5331 case ATOM: | 5377 case ATOM: |
5332 return 0; | 5378 return 0; |
5333 case IRREGEXP: | 5379 case IRREGEXP: |
5334 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); | 5380 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); |
5335 default: | 5381 default: |
5336 UNREACHABLE(); | 5382 UNREACHABLE(); |
5337 return -1; | 5383 return -1; |
5338 } | 5384 } |
(...skipping 15 matching lines...) Expand all Loading... |
5354 return pattern; | 5400 return pattern; |
5355 } | 5401 } |
5356 | 5402 |
5357 | 5403 |
5358 Object* JSRegExp::DataAt(int index) { | 5404 Object* JSRegExp::DataAt(int index) { |
5359 ASSERT(TypeTag() != NOT_COMPILED); | 5405 ASSERT(TypeTag() != NOT_COMPILED); |
5360 return FixedArray::cast(data())->get(index); | 5406 return FixedArray::cast(data())->get(index); |
5361 } | 5407 } |
5362 | 5408 |
5363 | 5409 |
| 5410 Object* JSRegExp::DataAtUnchecked(int index) { |
| 5411 FixedArray* fa = reinterpret_cast<FixedArray*>(data()); |
| 5412 int offset = FixedArray::kHeaderSize + index * kPointerSize; |
| 5413 return READ_FIELD(fa, offset); |
| 5414 } |
| 5415 |
| 5416 |
5364 void JSRegExp::SetDataAt(int index, Object* value) { | 5417 void JSRegExp::SetDataAt(int index, Object* value) { |
5365 ASSERT(TypeTag() != NOT_COMPILED); | 5418 ASSERT(TypeTag() != NOT_COMPILED); |
5366 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | 5419 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. |
5367 FixedArray::cast(data())->set(index, value); | 5420 FixedArray::cast(data())->set(index, value); |
5368 } | 5421 } |
5369 | 5422 |
5370 | 5423 |
| 5424 void JSRegExp::SetDataAtUnchecked(int index, Object* value, Heap* heap) { |
| 5425 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. |
| 5426 FixedArray* fa = reinterpret_cast<FixedArray*>(data()); |
| 5427 if (value->IsSmi()) { |
| 5428 fa->set_unchecked(index, Smi::cast(value)); |
| 5429 } else { |
| 5430 // We only do this during GC, so we don't need to notify the write barrier. |
| 5431 fa->set_unchecked(heap, index, value, SKIP_WRITE_BARRIER); |
| 5432 } |
| 5433 } |
| 5434 |
| 5435 |
5371 ElementsKind JSObject::GetElementsKind() { | 5436 ElementsKind JSObject::GetElementsKind() { |
5372 ElementsKind kind = map()->elements_kind(); | 5437 ElementsKind kind = map()->elements_kind(); |
5373 #if DEBUG | 5438 #if DEBUG |
5374 FixedArrayBase* fixed_array = | 5439 FixedArrayBase* fixed_array = |
5375 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); | 5440 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); |
5376 Map* map = fixed_array->map(); | 5441 Map* map = fixed_array->map(); |
5377 ASSERT((IsFastSmiOrObjectElementsKind(kind) && | 5442 ASSERT((IsFastSmiOrObjectElementsKind(kind) && |
5378 (map == GetHeap()->fixed_array_map() || | 5443 (map == GetHeap()->fixed_array_map() || |
5379 map == GetHeap()->fixed_cow_array_map())) || | 5444 map == GetHeap()->fixed_cow_array_map())) || |
5380 (IsFastDoubleElementsKind(kind) && | 5445 (IsFastDoubleElementsKind(kind) && |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6181 #undef WRITE_UINT32_FIELD | 6246 #undef WRITE_UINT32_FIELD |
6182 #undef READ_SHORT_FIELD | 6247 #undef READ_SHORT_FIELD |
6183 #undef WRITE_SHORT_FIELD | 6248 #undef WRITE_SHORT_FIELD |
6184 #undef READ_BYTE_FIELD | 6249 #undef READ_BYTE_FIELD |
6185 #undef WRITE_BYTE_FIELD | 6250 #undef WRITE_BYTE_FIELD |
6186 | 6251 |
6187 | 6252 |
6188 } } // namespace v8::internal | 6253 } } // namespace v8::internal |
6189 | 6254 |
6190 #endif // V8_OBJECTS_INL_H_ | 6255 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |