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

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

Issue 2335363002: DBC: Another allocation fast path (Closed)
Patch Set: Remove extra whitespace 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 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 Exit(thread, FP, SP + 3, pc); 2290 Exit(thread, FP, SP + 3, pc);
2291 NativeArguments args(thread, 1, SP + 1, SP + 2); 2291 NativeArguments args(thread, 1, SP + 1, SP + 2);
2292 INVOKE_RUNTIME(DRT_InitStaticField, args); 2292 INVOKE_RUNTIME(DRT_InitStaticField, args);
2293 } 2293 }
2294 DISPATCH(); 2294 DISPATCH();
2295 } 2295 }
2296 2296
2297 // TODO(vegorov) allocation bytecodes can benefit from the new-space 2297 // TODO(vegorov) allocation bytecodes can benefit from the new-space
2298 // allocation fast-path that does not transition into the runtime system. 2298 // allocation fast-path that does not transition into the runtime system.
2299 { 2299 {
2300 BYTECODE(AllocateUninitializedContext, A_D);
2301 const uint16_t num_context_variables = rD;
2302 const intptr_t instance_size = Context::InstanceSize(num_context_variables);
2303 const uword start =
2304 thread->heap()->new_space()->TryAllocate(instance_size);
2305 if (LIKELY(start != 0)) {
2306 uword tags = 0;
2307 tags = RawObject::ClassIdTag::update(kContextCid, tags);
2308 tags = RawObject::SizeTag::update(instance_size, tags);
2309 *reinterpret_cast<uword*>(start + Array::tags_offset()) = tags;
2310 *reinterpret_cast<uword*>(start + Context::num_variables_offset()) =
2311 num_context_variables;
2312 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2313 pc += 2;
2314 }
2315 DISPATCH();
2316 }
2317
2318 {
2300 BYTECODE(AllocateContext, A_D); 2319 BYTECODE(AllocateContext, A_D);
2301 const uint16_t num_context_variables = rD; 2320 const uint16_t num_context_variables = rD;
2302 { 2321 {
2303 *++SP = 0; 2322 *++SP = 0;
2304 SP[1] = Smi::New(num_context_variables); 2323 SP[1] = Smi::New(num_context_variables);
2305 Exit(thread, FP, SP + 2, pc); 2324 Exit(thread, FP, SP + 2, pc);
2306 NativeArguments args(thread, 1, SP + 1, SP); 2325 NativeArguments args(thread, 1, SP + 1, SP);
2307 INVOKE_RUNTIME(DRT_AllocateContext, args); 2326 INVOKE_RUNTIME(DRT_AllocateContext, args);
2308 } 2327 }
2309 DISPATCH(); 2328 DISPATCH();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 SP[2] = LOAD_CONSTANT(rD); // Class object. 2364 SP[2] = LOAD_CONSTANT(rD); // Class object.
2346 SP[3] = null_value; // Type arguments. 2365 SP[3] = null_value; // Type arguments.
2347 Exit(thread, FP, SP + 4, pc); 2366 Exit(thread, FP, SP + 4, pc);
2348 NativeArguments args(thread, 2, SP + 2, SP + 1); 2367 NativeArguments args(thread, 2, SP + 2, SP + 1);
2349 INVOKE_RUNTIME(DRT_AllocateObject, args); 2368 INVOKE_RUNTIME(DRT_AllocateObject, args);
2350 SP++; // Result is in SP[1]. 2369 SP++; // Result is in SP[1].
2351 DISPATCH(); 2370 DISPATCH();
2352 } 2371 }
2353 2372
2354 { 2373 {
2374 BYTECODE(AllocateTOpt, A_D);
2375 const uword tags = Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(rD)));
2376 const intptr_t instance_size = RawObject::SizeTag::decode(tags);
2377 const uword start = thread->heap()->new_space()->TryAllocate(instance_size);
2378 if (LIKELY(start != 0)) {
2379 RawObject* type_args = SP[0];
2380 const intptr_t type_args_offset = Bytecode::DecodeD(*pc);
2381 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags;
2382 *reinterpret_cast<RawObject**>(start + type_args_offset) = type_args;
2383 for (intptr_t current_offset = sizeof(RawInstance);
2384 current_offset < instance_size;
2385 current_offset += kWordSize) {
2386 *reinterpret_cast<RawObject**>(start + current_offset) = null_value;
2387 }
2388 FP[rA] = reinterpret_cast<RawObject*>(start + kHeapObjectTag);
2389 SP -= 1; // Consume the type arguments on the stack.
2390 pc += 4;
2391 }
2392 DISPATCH();
2393 }
2394
2395 {
2355 BYTECODE(AllocateT, 0); 2396 BYTECODE(AllocateT, 0);
2356 SP[1] = SP[-0]; // Class object. 2397 SP[1] = SP[-0]; // Class object.
2357 SP[2] = SP[-1]; // Type arguments 2398 SP[2] = SP[-1]; // Type arguments
2358 Exit(thread, FP, SP + 3, pc); 2399 Exit(thread, FP, SP + 3, pc);
2359 NativeArguments args(thread, 2, SP + 1, SP - 1); 2400 NativeArguments args(thread, 2, SP + 1, SP - 1);
2360 INVOKE_RUNTIME(DRT_AllocateObject, args); 2401 INVOKE_RUNTIME(DRT_AllocateObject, args);
2361 SP -= 1; // Result is in SP - 1. 2402 SP -= 1; // Result is in SP - 1.
2362 DISPATCH(); 2403 DISPATCH();
2363 } 2404 }
2364 2405
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
3286 pc_ = pc; 3327 pc_ = pc;
3287 special_[kExceptionSpecialIndex] = raw_exception; 3328 special_[kExceptionSpecialIndex] = raw_exception;
3288 special_[kStacktraceSpecialIndex] = raw_stacktrace; 3329 special_[kStacktraceSpecialIndex] = raw_stacktrace;
3289 buf->Longjmp(); 3330 buf->Longjmp();
3290 UNREACHABLE(); 3331 UNREACHABLE();
3291 } 3332 }
3292 3333
3293 } // namespace dart 3334 } // namespace dart
3294 3335
3295 #endif // defined TARGET_ARCH_DBC 3336 #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