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

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

Issue 2331033003: DBC: A couple allocation fastpaths. (Closed)
Patch Set: Address comments 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, intptr_t scale) {
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 ASSERT(((byte_offset + (1 << scale)) >> scale) <=
260 Smi::Value(array->ptr()->length_));
261 return array->ptr()->data() + byte_offset; 259 return array->ptr()->data() + byte_offset;
262 } 260 }
263 }; 261 };
264 262
265 263
266 DART_FORCE_INLINE static uint32_t* SavedCallerPC(RawObject** FP) { 264 DART_FORCE_INLINE static uint32_t* SavedCallerPC(RawObject** FP) {
267 return reinterpret_cast<uint32_t*>(FP[kSavedCallerPcSlotFromFp]); 265 return reinterpret_cast<uint32_t*>(FP[kSavedCallerPcSlotFromFp]);
268 } 266 }
269 267
270 268
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 pc++; 1817 pc++;
1820 } 1818 }
1821 } 1819 }
1822 DISPATCH(); 1820 DISPATCH();
1823 } 1821 }
1824 1822
1825 #if defined(ARCH_IS_64_BIT) 1823 #if defined(ARCH_IS_64_BIT)
1826 { 1824 {
1827 BYTECODE(WriteIntoDouble, A_D); 1825 BYTECODE(WriteIntoDouble, A_D);
1828 const double value = bit_cast<double, RawObject*>(FP[rD]); 1826 const double value = bit_cast<double, RawObject*>(FP[rD]);
1829 RawDouble* box = RAW_CAST(Double, *SP--); 1827 RawDouble* box = RAW_CAST(Double, FP[rA]);
1830 box->ptr()->value_ = value; 1828 box->ptr()->value_ = value;
1831 FP[rA] = box;
1832 DISPATCH(); 1829 DISPATCH();
1833 } 1830 }
1834 1831
1835 { 1832 {
1836 BYTECODE(UnboxDouble, A_D); 1833 BYTECODE(UnboxDouble, A_D);
1837 const RawDouble* box = RAW_CAST(Double, FP[rD]); 1834 const RawDouble* box = RAW_CAST(Double, FP[rD]);
1838 FP[rA] = bit_cast<RawObject*, double>(box->ptr()->value_); 1835 FP[rA] = bit_cast<RawObject*, double>(box->ptr()->value_);
1839 DISPATCH(); 1836 DISPATCH();
1840 } 1837 }
1841 1838
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 { 2314 {
2318 SP[1] = SP[0]; // Context to clone. 2315 SP[1] = SP[0]; // Context to clone.
2319 Exit(thread, FP, SP + 2, pc); 2316 Exit(thread, FP, SP + 2, pc);
2320 NativeArguments args(thread, 1, SP + 1, SP); 2317 NativeArguments args(thread, 1, SP + 1, SP);
2321 INVOKE_RUNTIME(DRT_CloneContext, args); 2318 INVOKE_RUNTIME(DRT_CloneContext, args);
2322 } 2319 }
2323 DISPATCH(); 2320 DISPATCH();
2324 } 2321 }
2325 2322
2326 { 2323 {
2324 BYTECODE(AllocateOpt, A_D);
2325 const uword tags =
2326 static_cast<uword>(Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(rD))));
2327 const intptr_t instance_size = RawObject::SizeTag::decode(tags);
2328 const uword start = thread->heap()->new_space()->TryAllocate(instance_size);
2329 if (LIKELY(start != 0)) {
2330 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags;
2331 for (intptr_t current_offset = sizeof(RawInstance);
2332 current_offset < instance_size;
2333 current_offset += kWordSize) {
2334 *reinterpret_cast<RawObject**>(start + current_offset) = null_value;
2335 }
2336 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2337 pc += 2;
2338 }
2339 DISPATCH();
2340 }
2341
2342 {
2327 BYTECODE(Allocate, A_D); 2343 BYTECODE(Allocate, A_D);
2328 SP[1] = 0; // Space for the result. 2344 SP[1] = 0; // Space for the result.
2329 SP[2] = LOAD_CONSTANT(rD); // Class object. 2345 SP[2] = LOAD_CONSTANT(rD); // Class object.
2330 SP[3] = null_value; // Type arguments. 2346 SP[3] = null_value; // Type arguments.
2331 Exit(thread, FP, SP + 4, pc); 2347 Exit(thread, FP, SP + 4, pc);
2332 NativeArguments args(thread, 2, SP + 2, SP + 1); 2348 NativeArguments args(thread, 2, SP + 2, SP + 1);
2333 INVOKE_RUNTIME(DRT_AllocateObject, args); 2349 INVOKE_RUNTIME(DRT_AllocateObject, args);
2334 SP++; // Result is in SP[1]. 2350 SP++; // Result is in SP[1].
2335 DISPATCH(); 2351 DISPATCH();
2336 } 2352 }
2337 2353
2338 { 2354 {
2339 BYTECODE(AllocateT, 0); 2355 BYTECODE(AllocateT, 0);
2340 SP[1] = SP[-0]; // Class object. 2356 SP[1] = SP[-0]; // Class object.
2341 SP[2] = SP[-1]; // Type arguments 2357 SP[2] = SP[-1]; // Type arguments
2342 Exit(thread, FP, SP + 3, pc); 2358 Exit(thread, FP, SP + 3, pc);
2343 NativeArguments args(thread, 2, SP + 1, SP - 1); 2359 NativeArguments args(thread, 2, SP + 1, SP - 1);
2344 INVOKE_RUNTIME(DRT_AllocateObject, args); 2360 INVOKE_RUNTIME(DRT_AllocateObject, args);
2345 SP -= 1; // Result is in SP - 1. 2361 SP -= 1; // Result is in SP - 1.
2346 DISPATCH(); 2362 DISPATCH();
2347 } 2363 }
2348 2364
2349 { 2365 {
2366 BYTECODE(CreateArrayOpt, A_B_C);
2367 const intptr_t length = Smi::Value(RAW_CAST(Smi, FP[rB]));
2368 if (LIKELY(length <= Array::kMaxElements)) {
2369 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
2370 const intptr_t instance_size =
2371 (fixed_size + length*kWordSize) & ~(kObjectAlignment - 1);
2372 const uword start =
2373 thread->heap()->new_space()->TryAllocate(instance_size);
2374 if (LIKELY(start != 0)) {
2375 const intptr_t cid = kArrayCid;
2376 uword tags = 0;
2377 if (LIKELY(instance_size < RawObject::SizeTag::kMaxSizeTag)) {
2378 tags = RawObject::SizeTag::update(instance_size, tags);
2379 }
2380 tags = RawObject::ClassIdTag::update(cid, tags);
2381 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags;
2382 *reinterpret_cast<RawObject**>(start + Array::length_offset()) = FP[rB];
2383 *reinterpret_cast<RawObject**>(start + Array::type_arguments_offset()) =
2384 FP[rC];
2385 RawObject** data =
2386 reinterpret_cast<RawObject**>(start + Array::data_offset());
2387 for (intptr_t i = 0; i < length; i++) {
2388 data[i] = null_value;
2389 }
2390 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2391 pc += 4;
2392 }
2393 }
2394 DISPATCH();
2395 }
2396
2397 {
2350 BYTECODE(CreateArrayTOS, 0); 2398 BYTECODE(CreateArrayTOS, 0);
2351 SP[1] = SP[-0]; // Length. 2399 SP[1] = SP[-0]; // Length.
2352 SP[2] = SP[-1]; // Type. 2400 SP[2] = SP[-1]; // Type.
2353 Exit(thread, FP, SP + 3, pc); 2401 Exit(thread, FP, SP + 3, pc);
2354 NativeArguments args(thread, 2, SP + 1, SP - 1); 2402 NativeArguments args(thread, 2, SP + 1, SP - 1);
2355 INVOKE_RUNTIME(DRT_AllocateArray, args); 2403 INVOKE_RUNTIME(DRT_AllocateArray, args);
2356 SP -= 1; 2404 SP -= 1;
2357 DISPATCH(); 2405 DISPATCH();
2358 } 2406 }
2359 2407
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 pc_ = pc; 3286 pc_ = pc;
3239 special_[kExceptionSpecialIndex] = raw_exception; 3287 special_[kExceptionSpecialIndex] = raw_exception;
3240 special_[kStacktraceSpecialIndex] = raw_stacktrace; 3288 special_[kStacktraceSpecialIndex] = raw_stacktrace;
3241 buf->Longjmp(); 3289 buf->Longjmp();
3242 UNREACHABLE(); 3290 UNREACHABLE();
3243 } 3291 }
3244 3292
3245 } // namespace dart 3293 } // namespace dart
3246 3294
3247 #endif // defined TARGET_ARCH_DBC 3295 #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