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

Side by Side Diff: src/objects-inl.h

Issue 16663009: Deprecate several unchecked accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Hannes Payer. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
2118 double* FixedDoubleArray::data_start() { 2094 double* FixedDoubleArray::data_start() {
2119 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize)); 2095 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
2120 } 2096 }
2121 2097
2122 2098
2123 Object** FixedArray::data_start() { 2099 Object** FixedArray::data_start() {
2124 return HeapObject::RawField(this, kHeaderSize); 2100 return HeapObject::RawField(this, kHeaderSize);
2125 } 2101 }
2126 2102
2127 2103
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3570 void Map::set_dictionary_map(bool value) { 3546 void Map::set_dictionary_map(bool value) {
3571 set_bit_field3(DictionaryMap::update(bit_field3(), value)); 3547 set_bit_field3(DictionaryMap::update(bit_field3(), value));
3572 } 3548 }
3573 3549
3574 3550
3575 bool Map::is_dictionary_map() { 3551 bool Map::is_dictionary_map() {
3576 return DictionaryMap::decode(bit_field3()); 3552 return DictionaryMap::decode(bit_field3());
3577 } 3553 }
3578 3554
3579 3555
3580 JSFunction* Map::unchecked_constructor() {
3581 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset));
3582 }
3583
3584
3585 Code::Flags Code::flags() { 3556 Code::Flags Code::flags() {
3586 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); 3557 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset));
3587 } 3558 }
3588 3559
3589 3560
3590 inline bool Map::CanTrackAllocationSite() { 3561 inline bool Map::CanTrackAllocationSite() {
3591 return instance_type() == JS_ARRAY_TYPE; 3562 return instance_type() == JS_ARRAY_TYPE;
3592 } 3563 }
3593 3564
3594 3565
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
4737 set_start_position_and_type((start_position << kStartPositionShift) 4708 set_start_position_and_type((start_position << kStartPositionShift)
4738 | (start_position_and_type() & ~kStartPositionMask)); 4709 | (start_position_and_type() & ~kStartPositionMask));
4739 } 4710 }
4740 4711
4741 4712
4742 Code* SharedFunctionInfo::code() { 4713 Code* SharedFunctionInfo::code() {
4743 return Code::cast(READ_FIELD(this, kCodeOffset)); 4714 return Code::cast(READ_FIELD(this, kCodeOffset));
4744 } 4715 }
4745 4716
4746 4717
4747 Code* SharedFunctionInfo::unchecked_code() {
4748 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset));
4749 }
4750
4751
4752 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { 4718 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) {
4753 WRITE_FIELD(this, kCodeOffset, value); 4719 WRITE_FIELD(this, kCodeOffset, value);
4754 CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode); 4720 CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode);
4755 } 4721 }
4756 4722
4757 4723
4758 void SharedFunctionInfo::ReplaceCode(Code* value) { 4724 void SharedFunctionInfo::ReplaceCode(Code* value) {
4759 // If the GC metadata field is already used then the function was 4725 // If the GC metadata field is already used then the function was
4760 // enqueued as a code flushing candidate and we remove it now. 4726 // enqueued as a code flushing candidate and we remove it now.
4761 if (code()->gc_metadata() != NULL) { 4727 if (code()->gc_metadata() != NULL) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
5278 byte* Code::instruction_end() { 5244 byte* Code::instruction_end() {
5279 return instruction_start() + instruction_size(); 5245 return instruction_start() + instruction_size();
5280 } 5246 }
5281 5247
5282 5248
5283 int Code::body_size() { 5249 int Code::body_size() {
5284 return RoundUp(instruction_size(), kObjectAlignment); 5250 return RoundUp(instruction_size(), kObjectAlignment);
5285 } 5251 }
5286 5252
5287 5253
5288 FixedArray* Code::unchecked_deoptimization_data() {
5289 return reinterpret_cast<FixedArray*>(
5290 READ_FIELD(this, kDeoptimizationDataOffset));
5291 }
5292
5293
5294 ByteArray* Code::unchecked_relocation_info() { 5254 ByteArray* Code::unchecked_relocation_info() {
5295 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); 5255 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset));
5296 } 5256 }
5297 5257
5298 5258
5299 byte* Code::relocation_start() { 5259 byte* Code::relocation_start() {
5300 return unchecked_relocation_info()->GetDataStartAddress(); 5260 return unchecked_relocation_info()->GetDataStartAddress();
5301 } 5261 }
5302 5262
5303 5263
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5359 5319
5360 5320
5361 JSRegExp::Type JSRegExp::TypeTag() { 5321 JSRegExp::Type JSRegExp::TypeTag() {
5362 Object* data = this->data(); 5322 Object* data = this->data();
5363 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; 5323 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED;
5364 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); 5324 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
5365 return static_cast<JSRegExp::Type>(smi->value()); 5325 return static_cast<JSRegExp::Type>(smi->value());
5366 } 5326 }
5367 5327
5368 5328
5369 JSRegExp::Type JSRegExp::TypeTagUnchecked() {
5370 Smi* smi = Smi::cast(DataAtUnchecked(kTagIndex));
5371 return static_cast<JSRegExp::Type>(smi->value());
5372 }
5373
5374
5375 int JSRegExp::CaptureCount() { 5329 int JSRegExp::CaptureCount() {
5376 switch (TypeTag()) { 5330 switch (TypeTag()) {
5377 case ATOM: 5331 case ATOM:
5378 return 0; 5332 return 0;
5379 case IRREGEXP: 5333 case IRREGEXP:
5380 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); 5334 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value();
5381 default: 5335 default:
5382 UNREACHABLE(); 5336 UNREACHABLE();
5383 return -1; 5337 return -1;
5384 } 5338 }
(...skipping 15 matching lines...) Expand all
5400 return pattern; 5354 return pattern;
5401 } 5355 }
5402 5356
5403 5357
5404 Object* JSRegExp::DataAt(int index) { 5358 Object* JSRegExp::DataAt(int index) {
5405 ASSERT(TypeTag() != NOT_COMPILED); 5359 ASSERT(TypeTag() != NOT_COMPILED);
5406 return FixedArray::cast(data())->get(index); 5360 return FixedArray::cast(data())->get(index);
5407 } 5361 }
5408 5362
5409 5363
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
5417 void JSRegExp::SetDataAt(int index, Object* value) { 5364 void JSRegExp::SetDataAt(int index, Object* value) {
5418 ASSERT(TypeTag() != NOT_COMPILED); 5365 ASSERT(TypeTag() != NOT_COMPILED);
5419 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. 5366 ASSERT(index >= kDataIndex); // Only implementation data can be set this way.
5420 FixedArray::cast(data())->set(index, value); 5367 FixedArray::cast(data())->set(index, value);
5421 } 5368 }
5422 5369
5423 5370
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
5436 ElementsKind JSObject::GetElementsKind() { 5371 ElementsKind JSObject::GetElementsKind() {
5437 ElementsKind kind = map()->elements_kind(); 5372 ElementsKind kind = map()->elements_kind();
5438 #if DEBUG 5373 #if DEBUG
5439 FixedArrayBase* fixed_array = 5374 FixedArrayBase* fixed_array =
5440 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset)); 5375 reinterpret_cast<FixedArrayBase*>(READ_FIELD(this, kElementsOffset));
5441 Map* map = fixed_array->map(); 5376 Map* map = fixed_array->map();
5442 ASSERT((IsFastSmiOrObjectElementsKind(kind) && 5377 ASSERT((IsFastSmiOrObjectElementsKind(kind) &&
5443 (map == GetHeap()->fixed_array_map() || 5378 (map == GetHeap()->fixed_array_map() ||
5444 map == GetHeap()->fixed_cow_array_map())) || 5379 map == GetHeap()->fixed_cow_array_map())) ||
5445 (IsFastDoubleElementsKind(kind) && 5380 (IsFastDoubleElementsKind(kind) &&
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
6246 #undef WRITE_UINT32_FIELD 6181 #undef WRITE_UINT32_FIELD
6247 #undef READ_SHORT_FIELD 6182 #undef READ_SHORT_FIELD
6248 #undef WRITE_SHORT_FIELD 6183 #undef WRITE_SHORT_FIELD
6249 #undef READ_BYTE_FIELD 6184 #undef READ_BYTE_FIELD
6250 #undef WRITE_BYTE_FIELD 6185 #undef WRITE_BYTE_FIELD
6251 6186
6252 6187
6253 } } // namespace v8::internal 6188 } } // namespace v8::internal
6254 6189
6255 #endif // V8_OBJECTS_INL_H_ 6190 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698