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

Side by Side Diff: runtime/vm/simulator_dbc.cc

Issue 2341683003: DBC: Double converstion instructions (Closed)
Patch Set: Use uint64_t Created 4 years, 3 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
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <setjmp.h> // NOLINT 5 #include <setjmp.h> // NOLINT
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #if defined(TARGET_ARCH_DBC) 9 #if defined(TARGET_ARCH_DBC)
10 10
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return static_cast<RawCode*>(FP[kPcMarkerSlotFromFp]); 244 return static_cast<RawCode*>(FP[kPcMarkerSlotFromFp]);
245 } 245 }
246 246
247 247
248 DART_FORCE_INLINE static void SetFrameCode(RawObject** FP, RawCode* code) { 248 DART_FORCE_INLINE static void SetFrameCode(RawObject** FP, RawCode* code) {
249 ASSERT(GetClassId(code) == kCodeCid); 249 ASSERT(GetClassId(code) == kCodeCid);
250 FP[kPcMarkerSlotFromFp] = code; 250 FP[kPcMarkerSlotFromFp] = code;
251 } 251 }
252 252
253 DART_FORCE_INLINE static uint8_t* GetTypedData( 253 DART_FORCE_INLINE static uint8_t* GetTypedData(
254 RawObject* obj, RawObject* index, intptr_t scale) { 254 RawObject* obj, RawObject* index) {
255 ASSERT(RawObject::IsTypedDataClassId(obj->GetClassId())); 255 ASSERT(RawObject::IsTypedDataClassId(obj->GetClassId()));
256 RawTypedData* array = reinterpret_cast<RawTypedData*>(obj); 256 RawTypedData* array = reinterpret_cast<RawTypedData*>(obj);
257 const intptr_t byte_offset = Smi::Value(RAW_CAST(Smi, index)); 257 const intptr_t byte_offset = Smi::Value(RAW_CAST(Smi, index));
258 ASSERT(byte_offset >= 0); 258 ASSERT(byte_offset >= 0);
259 return array->ptr()->data() + byte_offset; 259 return array->ptr()->data() + byte_offset;
260 } 260 }
261 }; 261 };
262 262
263 263
264 DART_FORCE_INLINE static uint32_t* SavedCallerPC(RawObject** FP) { 264 DART_FORCE_INLINE static uint32_t* SavedCallerPC(RawObject** FP) {
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 1962
1963 { 1963 {
1964 BYTECODE(DMax, A_B_C); 1964 BYTECODE(DMax, A_B_C);
1965 const double lhs = bit_cast<double, RawObject*>(FP[rB]); 1965 const double lhs = bit_cast<double, RawObject*>(FP[rB]);
1966 const double rhs = bit_cast<double, RawObject*>(FP[rC]); 1966 const double rhs = bit_cast<double, RawObject*>(FP[rC]);
1967 FP[rA] = bit_cast<RawObject*, double>(fmax(lhs, rhs)); 1967 FP[rA] = bit_cast<RawObject*, double>(fmax(lhs, rhs));
1968 DISPATCH(); 1968 DISPATCH();
1969 } 1969 }
1970 1970
1971 { 1971 {
1972 BYTECODE(DTruncate, A_D);
1973 const double value = bit_cast<double, RawObject*>(FP[rD]);
1974 FP[rA] = bit_cast<RawObject*, double>(trunc(value));
1975 DISPATCH();
1976 }
1977
1978 {
1979 BYTECODE(DFloor, A_D);
1980 const double value = bit_cast<double, RawObject*>(FP[rD]);
1981 FP[rA] = bit_cast<RawObject*, double>(floor(value));
1982 DISPATCH();
1983 }
1984
1985 {
1986 BYTECODE(DCeil, A_D);
1987 const double value = bit_cast<double, RawObject*>(FP[rD]);
1988 FP[rA] = bit_cast<RawObject*, double>(ceil(value));
1989 DISPATCH();
1990 }
1991
1992 {
1993 BYTECODE(DoubleToFloat, A_D);
1994 const double value = bit_cast<double, RawObject*>(FP[rD]);
1995 const float valuef = static_cast<float>(value);
1996 *reinterpret_cast<float*>(&FP[rA]) = valuef;
1997 DISPATCH();
1998 }
1999
2000 {
2001 BYTECODE(FloatToDouble, A_D);
2002 const float valuef = *reinterpret_cast<float*>(&FP[rD]);
2003 const double value = static_cast<double>(valuef);
2004 FP[rA] = bit_cast<RawObject*, double>(value);
2005 DISPATCH();
2006 }
2007
2008 {
2009 BYTECODE(LoadIndexedFloat32, A_B_C);
2010 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC]);
2011 const uint32_t value = *reinterpret_cast<uint32_t*>(data);
2012 const uint64_t value64 = value;
2013 FP[rA] = reinterpret_cast<RawObject*>(value64);
2014 DISPATCH();
2015 }
2016
2017 {
2018 BYTECODE(LoadIndexed4Float32, A_B_C);
2019 ASSERT(RawObject::IsTypedDataClassId(FP[rB]->GetClassId()));
2020 RawTypedData* array = reinterpret_cast<RawTypedData*>(FP[rB]);
2021 RawSmi* index = RAW_CAST(Smi, FP[rC]);
2022 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
2023 const uint32_t value =
2024 reinterpret_cast<uint32_t*>(array->ptr()->data())[Smi::Value(index)];
2025 const uint64_t value64 = value; // sign extend to clear high bits.
2026 FP[rA] = reinterpret_cast<RawObject*>(value64);
2027 DISPATCH();
2028 }
2029
2030 {
1972 BYTECODE(LoadIndexedFloat64, A_B_C); 2031 BYTECODE(LoadIndexedFloat64, A_B_C);
1973 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC], 3); 2032 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC]);
1974 *reinterpret_cast<uint64_t*>(&FP[rA]) = *reinterpret_cast<uint64_t*>(data); 2033 *reinterpret_cast<uint64_t*>(&FP[rA]) = *reinterpret_cast<uint64_t*>(data);
1975 DISPATCH(); 2034 DISPATCH();
1976 } 2035 }
1977 2036
1978 { 2037 {
1979 BYTECODE(LoadIndexed8Float64, A_B_C); 2038 BYTECODE(LoadIndexed8Float64, A_B_C);
1980 ASSERT(RawObject::IsTypedDataClassId(FP[rB]->GetClassId())); 2039 ASSERT(RawObject::IsTypedDataClassId(FP[rB]->GetClassId()));
1981 RawTypedData* array = reinterpret_cast<RawTypedData*>(FP[rB]); 2040 RawTypedData* array = reinterpret_cast<RawTypedData*>(FP[rB]);
1982 RawSmi* index = RAW_CAST(Smi, FP[rC]); 2041 RawSmi* index = RAW_CAST(Smi, FP[rC]);
1983 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); 2042 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
1984 const int64_t value = 2043 const int64_t value =
1985 reinterpret_cast<int64_t*>(array->ptr()->data())[Smi::Value(index)]; 2044 reinterpret_cast<int64_t*>(array->ptr()->data())[Smi::Value(index)];
1986 FP[rA] = reinterpret_cast<RawObject*>(value); 2045 FP[rA] = reinterpret_cast<RawObject*>(value);
1987 DISPATCH(); 2046 DISPATCH();
1988 } 2047 }
1989 2048
1990 { 2049 {
2050 BYTECODE(StoreIndexedFloat32, A_B_C);
2051 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB]);
2052 const uint64_t value = reinterpret_cast<uint64_t>(FP[rC]);
2053 const uint32_t value32 = value;
2054 *reinterpret_cast<uint32_t*>(data) = value32;
2055 DISPATCH();
2056 }
2057
2058 {
2059 BYTECODE(StoreIndexed4Float32, A_B_C);
2060 ASSERT(RawObject::IsTypedDataClassId(FP[rA]->GetClassId()));
2061 RawTypedData* array = reinterpret_cast<RawTypedData*>(FP[rA]);
2062 RawSmi* index = RAW_CAST(Smi, FP[rB]);
2063 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
2064 const uint64_t value = reinterpret_cast<uint64_t>(FP[rC]);
2065 const uint32_t value32 = value;
2066 reinterpret_cast<uint32_t*>(array->ptr()->data())[Smi::Value(index)] =
2067 value32;
2068 DISPATCH();
2069 }
2070
2071 {
1991 BYTECODE(StoreIndexedFloat64, A_B_C); 2072 BYTECODE(StoreIndexedFloat64, A_B_C);
1992 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB], 3); 2073 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB]);
1993 *reinterpret_cast<uint64_t*>(data) = reinterpret_cast<uint64_t>(FP[rC]); 2074 *reinterpret_cast<uint64_t*>(data) = reinterpret_cast<uint64_t>(FP[rC]);
1994 DISPATCH(); 2075 DISPATCH();
1995 } 2076 }
1996 2077
1997 { 2078 {
1998 BYTECODE(StoreIndexed8Float64, A_B_C); 2079 BYTECODE(StoreIndexed8Float64, A_B_C);
1999 ASSERT(RawObject::IsTypedDataClassId(FP[rA]->GetClassId())); 2080 ASSERT(RawObject::IsTypedDataClassId(FP[rA]->GetClassId()));
2000 RawTypedData* array = reinterpret_cast<RawTypedData*>(FP[rA]); 2081 RawTypedData* array = reinterpret_cast<RawTypedData*>(FP[rA]);
2001 RawSmi* index = RAW_CAST(Smi, FP[rB]); 2082 RawSmi* index = RAW_CAST(Smi, FP[rB]);
2002 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); 2083 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 DISPATCH(); 2200 DISPATCH();
2120 } 2201 }
2121 2202
2122 { 2203 {
2123 BYTECODE(DMax, A_B_C); 2204 BYTECODE(DMax, A_B_C);
2124 UNREACHABLE(); 2205 UNREACHABLE();
2125 DISPATCH(); 2206 DISPATCH();
2126 } 2207 }
2127 2208
2128 { 2209 {
2210 BYTECODE(DTruncate, A_D);
2211 UNREACHABLE();
2212 DISPATCH();
2213 }
2214
2215 {
2216 BYTECODE(DFloor, A_D);
2217 UNREACHABLE();
2218 DISPATCH();
2219 }
2220
2221 {
2222 BYTECODE(DCeil, A_D);
2223 UNREACHABLE();
2224 DISPATCH();
2225 }
2226
2227 {
2228 BYTECODE(DoubleToFloat, A_D);
2229 UNREACHABLE();
2230 DISPATCH();
2231 }
2232
2233 {
2234 BYTECODE(FloatToDouble, A_D);
2235 UNREACHABLE();
2236 DISPATCH();
2237 }
2238
2239 {
2240 BYTECODE(LoadIndexedFloat32, A_B_C);
2241 UNREACHABLE();
2242 DISPATCH();
2243 }
2244
2245 {
2246 BYTECODE(LoadIndexed4Float32, A_B_C);
2247 UNREACHABLE();
2248 DISPATCH();
2249 }
2250
2251 {
2129 BYTECODE(LoadIndexedFloat64, A_B_C); 2252 BYTECODE(LoadIndexedFloat64, A_B_C);
2130 UNREACHABLE(); 2253 UNREACHABLE();
2131 DISPATCH(); 2254 DISPATCH();
2132 } 2255 }
2133 2256
2134 { 2257 {
2135 BYTECODE(LoadIndexed8Float64, A_B_C); 2258 BYTECODE(LoadIndexed8Float64, A_B_C);
2136 UNREACHABLE(); 2259 UNREACHABLE();
2137 DISPATCH(); 2260 DISPATCH();
2138 } 2261 }
2139 2262
2140 { 2263 {
2264 BYTECODE(StoreIndexedFloat32, A_B_C);
2265 UNREACHABLE();
2266 DISPATCH();
2267 }
2268
2269 {
2270 BYTECODE(StoreIndexed4Float32, A_B_C);
2271 UNREACHABLE();
2272 DISPATCH();
2273 }
2274
2275 {
2141 BYTECODE(StoreIndexedFloat64, A_B_C); 2276 BYTECODE(StoreIndexedFloat64, A_B_C);
2142 UNREACHABLE(); 2277 UNREACHABLE();
2143 DISPATCH(); 2278 DISPATCH();
2144 } 2279 }
2145 2280
2146 { 2281 {
2147 BYTECODE(StoreIndexed8Float64, A_B_C); 2282 BYTECODE(StoreIndexed8Float64, A_B_C);
2148 UNREACHABLE(); 2283 UNREACHABLE();
2149 DISPATCH(); 2284 DISPATCH();
2150 } 2285 }
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 RawArray* array = RAW_CAST(Array, FP[rA]); 3171 RawArray* array = RAW_CAST(Array, FP[rA]);
3037 RawSmi* index = RAW_CAST(Smi, FP[rB]); 3172 RawSmi* index = RAW_CAST(Smi, FP[rB]);
3038 RawObject* value = FP[rC]; 3173 RawObject* value = FP[rC];
3039 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); 3174 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
3040 array->StorePointer(array->ptr()->data() + Smi::Value(index), value); 3175 array->StorePointer(array->ptr()->data() + Smi::Value(index), value);
3041 DISPATCH(); 3176 DISPATCH();
3042 } 3177 }
3043 3178
3044 { 3179 {
3045 BYTECODE(StoreIndexedUint8, A_B_C); 3180 BYTECODE(StoreIndexedUint8, A_B_C);
3046 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB], 0); 3181 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB]);
3047 *data = Smi::Value(RAW_CAST(Smi, FP[rC])); 3182 *data = Smi::Value(RAW_CAST(Smi, FP[rC]));
3048 DISPATCH(); 3183 DISPATCH();
3049 } 3184 }
3050 3185
3051 { 3186 {
3052 BYTECODE(StoreIndexedExternalUint8, A_B_C); 3187 BYTECODE(StoreIndexedExternalUint8, A_B_C);
3053 uint8_t* array = reinterpret_cast<uint8_t*>(FP[rA]); 3188 uint8_t* array = reinterpret_cast<uint8_t*>(FP[rA]);
3054 RawSmi* index = RAW_CAST(Smi, FP[rB]); 3189 RawSmi* index = RAW_CAST(Smi, FP[rB]);
3055 RawSmi* value = RAW_CAST(Smi, FP[rC]); 3190 RawSmi* value = RAW_CAST(Smi, FP[rC]);
3056 array[Smi::Value(index)] = Smi::Value(value); 3191 array[Smi::Value(index)] = Smi::Value(value);
3057 DISPATCH(); 3192 DISPATCH();
3058 } 3193 }
3059 3194
3060 { 3195 {
3061 BYTECODE(StoreIndexedOneByteString, A_B_C); 3196 BYTECODE(StoreIndexedOneByteString, A_B_C);
3062 RawOneByteString* array = RAW_CAST(OneByteString, FP[rA]); 3197 RawOneByteString* array = RAW_CAST(OneByteString, FP[rA]);
3063 RawSmi* index = RAW_CAST(Smi, FP[rB]); 3198 RawSmi* index = RAW_CAST(Smi, FP[rB]);
3064 RawSmi* value = RAW_CAST(Smi, FP[rC]); 3199 RawSmi* value = RAW_CAST(Smi, FP[rC]);
3065 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); 3200 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
3066 array->ptr()->data()[Smi::Value(index)] = Smi::Value(value); 3201 array->ptr()->data()[Smi::Value(index)] = Smi::Value(value);
3067 DISPATCH(); 3202 DISPATCH();
3068 } 3203 }
3069 3204
3070 { 3205 {
3071 BYTECODE(StoreIndexedUint32, A_B_C); 3206 BYTECODE(StoreIndexedUint32, A_B_C);
3072 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB], 2); 3207 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rA], FP[rB]);
3073 const uintptr_t value = reinterpret_cast<uintptr_t>(FP[rC]); 3208 const uintptr_t value = reinterpret_cast<uintptr_t>(FP[rC]);
3074 *reinterpret_cast<uint32_t*>(data) = static_cast<uint32_t>(value); 3209 *reinterpret_cast<uint32_t*>(data) = static_cast<uint32_t>(value);
3075 DISPATCH(); 3210 DISPATCH();
3076 } 3211 }
3077 3212
3078 { 3213 {
3079 BYTECODE(LoadIndexed, A_B_C); 3214 BYTECODE(LoadIndexed, A_B_C);
3080 RawObject* obj = FP[rB]; 3215 RawObject* obj = FP[rB];
3081 ASSERT(obj->IsArray() || obj->IsImmutableArray()); 3216 ASSERT(obj->IsArray() || obj->IsImmutableArray());
3082 RawArray* array = reinterpret_cast<RawArray*>(obj); 3217 RawArray* array = reinterpret_cast<RawArray*>(obj);
3083 RawSmi* index = RAW_CAST(Smi, FP[rC]); 3218 RawSmi* index = RAW_CAST(Smi, FP[rC]);
3084 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); 3219 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_));
3085 FP[rA] = array->ptr()->data()[Smi::Value(index)]; 3220 FP[rA] = array->ptr()->data()[Smi::Value(index)];
3086 DISPATCH(); 3221 DISPATCH();
3087 } 3222 }
3088 3223
3089 { 3224 {
3090 BYTECODE(LoadIndexedUint8, A_B_C); 3225 BYTECODE(LoadIndexedUint8, A_B_C);
3091 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC], 0); 3226 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC]);
3092 FP[rA] = Smi::New(*data); 3227 FP[rA] = Smi::New(*data);
3093 DISPATCH(); 3228 DISPATCH();
3094 } 3229 }
3095 3230
3096 { 3231 {
3097 BYTECODE(LoadIndexedInt8, A_B_C); 3232 BYTECODE(LoadIndexedInt8, A_B_C);
3098 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC], 0); 3233 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC]);
3099 FP[rA] = Smi::New(*reinterpret_cast<int8_t*>(data)); 3234 FP[rA] = Smi::New(*reinterpret_cast<int8_t*>(data));
3100 DISPATCH(); 3235 DISPATCH();
3101 } 3236 }
3102 3237
3103 { 3238 {
3104 BYTECODE(LoadIndexedUint32, A_B_C); 3239 BYTECODE(LoadIndexedUint32, A_B_C);
3105 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC], 2); 3240 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC]);
3106 FP[rA] = reinterpret_cast<RawObject*>(*reinterpret_cast<uintptr_t*>(data)); 3241 FP[rA] = reinterpret_cast<RawObject*>(*reinterpret_cast<uintptr_t*>(data));
3107 DISPATCH(); 3242 DISPATCH();
3108 } 3243 }
3109 3244
3110 { 3245 {
3111 BYTECODE(LoadIndexedInt32, A_B_C); 3246 BYTECODE(LoadIndexedInt32, A_B_C);
3112 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC], 2); 3247 uint8_t* data = SimulatorHelpers::GetTypedData(FP[rB], FP[rC]);
3113 FP[rA] = reinterpret_cast<RawObject*>(*reinterpret_cast<intptr_t*>(data)); 3248 FP[rA] = reinterpret_cast<RawObject*>(*reinterpret_cast<intptr_t*>(data));
3114 DISPATCH(); 3249 DISPATCH();
3115 } 3250 }
3116 3251
3117 { 3252 {
3118 BYTECODE(LoadIndexedExternalUint8, A_B_C); 3253 BYTECODE(LoadIndexedExternalUint8, A_B_C);
3119 uint8_t* data = reinterpret_cast<uint8_t*>(FP[rB]); 3254 uint8_t* data = reinterpret_cast<uint8_t*>(FP[rB]);
3120 RawSmi* index = RAW_CAST(Smi, FP[rC]); 3255 RawSmi* index = RAW_CAST(Smi, FP[rC]);
3121 FP[rA] = Smi::New(data[Smi::Value(index)]); 3256 FP[rA] = Smi::New(data[Smi::Value(index)]);
3122 DISPATCH(); 3257 DISPATCH();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 pc_ = pc; 3462 pc_ = pc;
3328 special_[kExceptionSpecialIndex] = raw_exception; 3463 special_[kExceptionSpecialIndex] = raw_exception;
3329 special_[kStacktraceSpecialIndex] = raw_stacktrace; 3464 special_[kStacktraceSpecialIndex] = raw_stacktrace;
3330 buf->Longjmp(); 3465 buf->Longjmp();
3331 UNREACHABLE(); 3466 UNREACHABLE();
3332 } 3467 }
3333 3468
3334 } // namespace dart 3469 } // namespace dart
3335 3470
3336 #endif // defined TARGET_ARCH_DBC 3471 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698