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

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

Issue 1410363005: Make ICData changes thread safe (first compute array, then set it). Install code in the main thread… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 1 month 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 | « no previous file | runtime/vm/compiler.h » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "vm/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 // called like a regular function and can't be entered via OSR. 1380 // called like a regular function and can't be entered via OSR.
1381 if (!CanOptimizeFunction(function, isolate) || function.is_intrinsic()) { 1381 if (!CanOptimizeFunction(function, isolate) || function.is_intrinsic()) {
1382 return; 1382 return;
1383 } 1383 }
1384 1384
1385 // The unoptimized code is on the stack and should never be detached from 1385 // The unoptimized code is on the stack and should never be detached from
1386 // the function at this point. 1386 // the function at this point.
1387 ASSERT(function.unoptimized_code() != Object::null()); 1387 ASSERT(function.unoptimized_code() != Object::null());
1388 intptr_t osr_id = 1388 intptr_t osr_id =
1389 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); 1389 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc());
1390 ASSERT(osr_id != Thread::kNoDeoptId); 1390 ASSERT(osr_id != Compiler::kNoOSRDeoptId);
1391 if (FLAG_trace_osr) { 1391 if (FLAG_trace_osr) {
1392 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n", 1392 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n",
1393 function.ToFullyQualifiedCString(), 1393 function.ToFullyQualifiedCString(),
1394 osr_id, 1394 osr_id,
1395 function.usage_counter()); 1395 function.usage_counter());
1396 } 1396 }
1397 1397
1398 const Code& original_code = Code::Handle(function.CurrentCode()); 1398 const Code& original_code = Code::Handle(function.CurrentCode());
1399 // Since the code is referenced from the frame and the ZoneHandle, 1399 // Since the code is referenced from the frame and the ZoneHandle,
1400 // it cannot have been removed from the function. 1400 // it cannot have been removed from the function.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 if (CanOptimizeFunction(function, isolate)) { 1450 if (CanOptimizeFunction(function, isolate)) {
1451 if (FLAG_background_compilation) { 1451 if (FLAG_background_compilation) {
1452 // Reduce the chance of triggering optimization while the function is 1452 // Reduce the chance of triggering optimization while the function is
1453 // being optimized in the background. INT_MIN should ensure that it takes 1453 // being optimized in the background. INT_MIN should ensure that it takes
1454 // long time to trigger optimization. 1454 // long time to trigger optimization.
1455 // Note that the background compilation queue rejects duplicate entries. 1455 // Note that the background compilation queue rejects duplicate entries.
1456 function.set_usage_counter(INT_MIN); 1456 function.set_usage_counter(INT_MIN);
1457 BackgroundCompiler::EnsureInit(thread); 1457 BackgroundCompiler::EnsureInit(thread);
1458 ASSERT(isolate->background_compiler() != NULL); 1458 ASSERT(isolate->background_compiler() != NULL);
1459 isolate->background_compiler()->CompileOptimized(function); 1459 isolate->background_compiler()->CompileOptimized(function);
1460 // Install all generated optimized code in the mutator thread (this one).
1461 isolate->background_compiler()->InstallGeneratedCode();
1460 // Continue in the same code. 1462 // Continue in the same code.
1461 arguments.SetReturn(Code::Handle(zone, function.CurrentCode())); 1463 arguments.SetReturn(Code::Handle(zone, function.CurrentCode()));
1462 return; 1464 return;
1463 } 1465 }
1464 1466
1465 // Reset usage counter for reoptimization before calling optimizer to 1467 // Reset usage counter for reoptimization before calling optimizer to
1466 // prevent recursive triggering of function optimization. 1468 // prevent recursive triggering of function optimization.
1467 function.set_usage_counter(0); 1469 function.set_usage_counter(0);
1468 if (FLAG_trace_compiler) { 1470 if (FLAG_trace_compiler) {
1469 if (function.HasOptimizedCode()) { 1471 if (function.HasOptimizedCode()) {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 const intptr_t elm_size = old_data.ElementSizeInBytes(); 1843 const intptr_t elm_size = old_data.ElementSizeInBytes();
1842 const TypedData& new_data = 1844 const TypedData& new_data =
1843 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 1845 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
1844 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 1846 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
1845 typed_data_cell.SetAt(0, new_data); 1847 typed_data_cell.SetAt(0, new_data);
1846 arguments.SetReturn(new_data); 1848 arguments.SetReturn(new_data);
1847 } 1849 }
1848 1850
1849 1851
1850 } // namespace dart 1852 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698