| 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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 set_map_word(MapWord::FromMap(value)); | 1065 set_map_word(MapWord::FromMap(value)); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 | 1068 |
| 1069 MapWord HeapObject::map_word() { | 1069 MapWord HeapObject::map_word() { |
| 1070 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); | 1070 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 | 1073 |
| 1074 void HeapObject::set_map_word(MapWord map_word) { | 1074 void HeapObject::set_map_word(MapWord map_word) { |
| 1075 // WRITE_FIELD does not update the remembered set, but there is no need | 1075 // WRITE_FIELD does not update the remembered set, but there is no need here. |
| 1076 // here. | |
| 1077 WRITE_FIELD(this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); | 1076 WRITE_FIELD(this, kMapOffset, reinterpret_cast<Object*>(map_word.value_)); |
| 1078 } | 1077 } |
| 1079 | 1078 |
| 1080 | 1079 |
| 1081 HeapObject* HeapObject::FromAddress(Address address) { | 1080 HeapObject* HeapObject::FromAddress(Address address) { |
| 1082 ASSERT_TAG_ALIGNED(address); | 1081 ASSERT_TAG_ALIGNED(address); |
| 1083 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1082 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 | 1085 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1138 |
| 1140 | 1139 |
| 1141 void HeapObject::ClearOverflow() { | 1140 void HeapObject::ClearOverflow() { |
| 1142 ASSERT(IsOverflowed()); | 1141 ASSERT(IsOverflowed()); |
| 1143 MapWord first_word = map_word(); | 1142 MapWord first_word = map_word(); |
| 1144 first_word.ClearOverflow(); | 1143 first_word.ClearOverflow(); |
| 1145 set_map_word(first_word); | 1144 set_map_word(first_word); |
| 1146 } | 1145 } |
| 1147 | 1146 |
| 1148 | 1147 |
| 1148 #ifndef V8_HOST_ARCH_MIPS |
| 1149 double HeapNumber::value() { | 1149 double HeapNumber::value() { |
| 1150 return READ_DOUBLE_FIELD(this, kValueOffset); | 1150 return READ_DOUBLE_FIELD(this, kValueOffset); |
| 1151 } | 1151 } |
| 1152 #else |
| 1153 // TODO(MIPS.6) |
| 1154 double HeapNumber::value() { |
| 1155 double res; |
| 1156 byte* addr = (reinterpret_cast<byte*>(this) + kValueOffset - kHeapObjectTag); |
| 1157 uint32_t p = ((uint32_t)addr & 0x7); |
| 1158 uint32_t* res_addr = (uint32_t*) &res; |
| 1159 |
| 1160 if(p == 0) { |
| 1161 // 8-byte aligned read is legal. |
| 1162 return READ_DOUBLE_FIELD(this, kValueOffset); |
| 1163 } else { |
| 1164 // Cannot read at an unaligned address. Read manually. |
| 1165 // asm("break"); |
| 1166 asm(".set noat"); |
| 1167 asm("lw $1, 0(%1);" |
| 1168 "sw $1, 0(%2)" |
| 1169 : "=r" (p) |
| 1170 : "r" (addr), "r" (res_addr) |
| 1171 ); |
| 1172 asm("lw $1, 4(%1);" |
| 1173 "sw $1, 4(%2)" |
| 1174 : "=r" (p) |
| 1175 : "r" (addr), "r" (res_addr) |
| 1176 ); |
| 1177 asm(".set at"); |
| 1178 } |
| 1179 return res; |
| 1180 } |
| 1181 #endif |
| 1152 | 1182 |
| 1153 | 1183 |
| 1184 #ifndef V8_HOST_ARCH_MIPS |
| 1154 void HeapNumber::set_value(double value) { | 1185 void HeapNumber::set_value(double value) { |
| 1155 WRITE_DOUBLE_FIELD(this, kValueOffset, value); | 1186 WRITE_DOUBLE_FIELD(this, kValueOffset, value); |
| 1156 } | 1187 } |
| 1188 #else |
| 1189 // TODO(MIPS.6) |
| 1190 void HeapNumber::set_value(double value) { |
| 1191 |
| 1192 byte* addr = (reinterpret_cast<byte*>(this) + kValueOffset - kHeapObjectTag); |
| 1193 uint32_t p = ((uint32_t)addr & 0x7); |
| 1194 |
| 1195 if(p == 0) { |
| 1196 // 8-byte aligned write is legal. |
| 1197 WRITE_DOUBLE_FIELD(this, kValueOffset, value); |
| 1198 } else { |
| 1199 // Cannot store to an unaligned address. Store manually. |
| 1200 // mfc1 must be executed first. (See MIPS ISA) |
| 1201 asm(".set noat"); |
| 1202 asm("mfc1 $1, %1;" |
| 1203 "sw $1, 4(%2)" |
| 1204 : "=r" (p) |
| 1205 : "f" (value), "r" (addr) |
| 1206 ); |
| 1207 asm("mfhc1 $1, %1;" |
| 1208 "sw $1, 0(%2)" |
| 1209 : "=r" (p) |
| 1210 : "f" (value), "r" (addr) |
| 1211 ); |
| 1212 asm(".set at"); |
| 1213 // In debug mode value is actually passed in a2-a3. If this is always the |
| 1214 // case we could spare the need to use the coprocessor and be much faster. |
| 1215 } |
| 1216 } |
| 1217 #endif |
| 1157 | 1218 |
| 1158 | 1219 |
| 1159 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) | 1220 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) |
| 1160 | 1221 |
| 1161 | 1222 |
| 1162 Array* JSObject::elements() { | 1223 Array* JSObject::elements() { |
| 1163 Object* array = READ_FIELD(this, kElementsOffset); | 1224 Object* array = READ_FIELD(this, kElementsOffset); |
| 1164 // In the assert below Dictionary is covered under FixedArray. | 1225 // In the assert below Dictionary is covered under FixedArray. |
| 1165 ASSERT(array->IsFixedArray() || array->IsPixelArray() || | 1226 ASSERT(array->IsFixedArray() || array->IsPixelArray() || |
| 1166 array->IsExternalArray()); | 1227 array->IsExternalArray()); |
| (...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3156 #undef WRITE_INT_FIELD | 3217 #undef WRITE_INT_FIELD |
| 3157 #undef READ_SHORT_FIELD | 3218 #undef READ_SHORT_FIELD |
| 3158 #undef WRITE_SHORT_FIELD | 3219 #undef WRITE_SHORT_FIELD |
| 3159 #undef READ_BYTE_FIELD | 3220 #undef READ_BYTE_FIELD |
| 3160 #undef WRITE_BYTE_FIELD | 3221 #undef WRITE_BYTE_FIELD |
| 3161 | 3222 |
| 3162 | 3223 |
| 3163 } } // namespace v8::internal | 3224 } } // namespace v8::internal |
| 3164 | 3225 |
| 3165 #endif // V8_OBJECTS_INL_H_ | 3226 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |