Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3843 | 3843 |
| 3844 | 3844 |
| 3845 JSRegExp::Type JSRegExp::TypeTag() { | 3845 JSRegExp::Type JSRegExp::TypeTag() { |
| 3846 Object* data = this->data(); | 3846 Object* data = this->data(); |
| 3847 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; | 3847 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; |
| 3848 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); | 3848 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); |
| 3849 return static_cast<JSRegExp::Type>(smi->value()); | 3849 return static_cast<JSRegExp::Type>(smi->value()); |
| 3850 } | 3850 } |
| 3851 | 3851 |
| 3852 | 3852 |
| 3853 JSRegExp::Type JSRegExp::TypeTagUnchecked() { | |
| 3854 Smi* smi = Smi::cast(DataAtUnchecked(kTagIndex)); | |
| 3855 return static_cast<JSRegExp::Type>(smi->value()); | |
| 3856 } | |
| 3857 | |
| 3858 | |
| 3853 int JSRegExp::CaptureCount() { | 3859 int JSRegExp::CaptureCount() { |
| 3854 switch (TypeTag()) { | 3860 switch (TypeTag()) { |
| 3855 case ATOM: | 3861 case ATOM: |
| 3856 return 0; | 3862 return 0; |
| 3857 case IRREGEXP: | 3863 case IRREGEXP: |
| 3858 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); | 3864 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); |
| 3859 default: | 3865 default: |
| 3860 UNREACHABLE(); | 3866 UNREACHABLE(); |
| 3861 return -1; | 3867 return -1; |
| 3862 } | 3868 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3878 return pattern; | 3884 return pattern; |
| 3879 } | 3885 } |
| 3880 | 3886 |
| 3881 | 3887 |
| 3882 Object* JSRegExp::DataAt(int index) { | 3888 Object* JSRegExp::DataAt(int index) { |
| 3883 ASSERT(TypeTag() != NOT_COMPILED); | 3889 ASSERT(TypeTag() != NOT_COMPILED); |
| 3884 return FixedArray::cast(data())->get(index); | 3890 return FixedArray::cast(data())->get(index); |
| 3885 } | 3891 } |
| 3886 | 3892 |
| 3887 | 3893 |
| 3894 Object* JSRegExp::DataAtUnchecked(int index) { | |
| 3895 FixedArray* fa = reinterpret_cast<FixedArray*>(data()); | |
| 3896 int offset = FixedArray::kHeaderSize + index * kPointerSize; | |
| 3897 return READ_FIELD(fa, offset); | |
| 3898 } | |
| 3899 | |
| 3900 | |
| 3888 void JSRegExp::SetDataAt(int index, Object* value) { | 3901 void JSRegExp::SetDataAt(int index, Object* value) { |
| 3889 ASSERT(TypeTag() != NOT_COMPILED); | 3902 ASSERT(TypeTag() != NOT_COMPILED); |
| 3890 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | 3903 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. |
| 3891 FixedArray::cast(data())->set(index, value); | 3904 FixedArray::cast(data())->set(index, value); |
| 3892 } | 3905 } |
| 3893 | 3906 |
| 3894 | 3907 |
| 3908 void JSRegExp::SetDataAtUnchecked(int index, Object* value, Heap* heap) { | |
| 3909 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | |
| 3910 FixedArray* fa = reinterpret_cast<FixedArray*>(data()); | |
| 3911 if (value->IsSmi()) { | |
| 3912 fa->set_unchecked(index, Smi::cast(value)); | |
| 3913 } else { | |
| 3914 fa->set_unchecked(heap, index, value, UPDATE_WRITE_BARRIER); | |
|
Erik Corry
2011/06/30 18:48:25
I think this is OK, but I would like to ask Slava.
Rico
2011/07/01 05:58:09
Done.
| |
| 3915 } | |
| 3916 } | |
| 3917 | |
| 3918 | |
| 3895 JSObject::ElementsKind JSObject::GetElementsKind() { | 3919 JSObject::ElementsKind JSObject::GetElementsKind() { |
| 3896 ElementsKind kind = map()->elements_kind(); | 3920 ElementsKind kind = map()->elements_kind(); |
| 3897 ASSERT((kind == FAST_ELEMENTS && | 3921 ASSERT((kind == FAST_ELEMENTS && |
| 3898 (elements()->map() == GetHeap()->fixed_array_map() || | 3922 (elements()->map() == GetHeap()->fixed_array_map() || |
| 3899 elements()->map() == GetHeap()->fixed_cow_array_map())) || | 3923 elements()->map() == GetHeap()->fixed_cow_array_map())) || |
| 3900 (kind == FAST_DOUBLE_ELEMENTS && | 3924 (kind == FAST_DOUBLE_ELEMENTS && |
| 3901 elements()->IsFixedDoubleArray()) || | 3925 elements()->IsFixedDoubleArray()) || |
| 3902 (kind == DICTIONARY_ELEMENTS && | 3926 (kind == DICTIONARY_ELEMENTS && |
| 3903 elements()->IsFixedArray() && | 3927 elements()->IsFixedArray() && |
| 3904 elements()->IsDictionary()) || | 3928 elements()->IsDictionary()) || |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4422 #undef WRITE_INT_FIELD | 4446 #undef WRITE_INT_FIELD |
| 4423 #undef READ_SHORT_FIELD | 4447 #undef READ_SHORT_FIELD |
| 4424 #undef WRITE_SHORT_FIELD | 4448 #undef WRITE_SHORT_FIELD |
| 4425 #undef READ_BYTE_FIELD | 4449 #undef READ_BYTE_FIELD |
| 4426 #undef WRITE_BYTE_FIELD | 4450 #undef WRITE_BYTE_FIELD |
| 4427 | 4451 |
| 4428 | 4452 |
| 4429 } } // namespace v8::internal | 4453 } } // namespace v8::internal |
| 4430 | 4454 |
| 4431 #endif // V8_OBJECTS_INL_H_ | 4455 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |