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

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

Issue 1992703005: Add test harness option for app snapshots with unoptimized code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 1456
1457 DART_EXPORT Dart_Handle Dart_CreateSnapshot( 1457 DART_EXPORT Dart_Handle Dart_CreateSnapshot(
1458 uint8_t** vm_isolate_snapshot_buffer, 1458 uint8_t** vm_isolate_snapshot_buffer,
1459 intptr_t* vm_isolate_snapshot_size, 1459 intptr_t* vm_isolate_snapshot_size,
1460 uint8_t** isolate_snapshot_buffer, 1460 uint8_t** isolate_snapshot_buffer,
1461 intptr_t* isolate_snapshot_size) { 1461 intptr_t* isolate_snapshot_size) {
1462 DARTSCOPE(Thread::Current()); 1462 DARTSCOPE(Thread::Current());
1463 API_TIMELINE_DURATION; 1463 API_TIMELINE_DURATION;
1464 Isolate* I = T->isolate(); 1464 Isolate* I = T->isolate();
1465 if (!FLAG_load_deferred_eagerly) { 1465 if (!FLAG_load_deferred_eagerly) {
1466 return Dart_NewApiError( 1466 return Api::NewError(
1467 "Creating full snapshots requires --load_deferred_eagerly"); 1467 "Creating full snapshots requires --load_deferred_eagerly");
1468 } 1468 }
1469 if (vm_isolate_snapshot_buffer != NULL && 1469 if (vm_isolate_snapshot_buffer != NULL &&
1470 vm_isolate_snapshot_size == NULL) { 1470 vm_isolate_snapshot_size == NULL) {
1471 RETURN_NULL_ERROR(vm_isolate_snapshot_size); 1471 RETURN_NULL_ERROR(vm_isolate_snapshot_size);
1472 } 1472 }
1473 if (isolate_snapshot_buffer == NULL) { 1473 if (isolate_snapshot_buffer == NULL) {
1474 RETURN_NULL_ERROR(isolate_snapshot_buffer); 1474 RETURN_NULL_ERROR(isolate_snapshot_buffer);
1475 } 1475 }
1476 if (isolate_snapshot_size == NULL) { 1476 if (isolate_snapshot_size == NULL) {
(...skipping 4647 matching lines...) Expand 10 before | Expand all | Expand 10 after
6124 intptr_t* rodata_blob_size) { 6124 intptr_t* rodata_blob_size) {
6125 UNREACHABLE(); 6125 UNREACHABLE();
6126 return 0; 6126 return 0;
6127 } 6127 }
6128 6128
6129 #else // DART_PRECOMPILER 6129 #else // DART_PRECOMPILER
6130 6130
6131 DART_EXPORT Dart_Handle Dart_Precompile( 6131 DART_EXPORT Dart_Handle Dart_Precompile(
6132 Dart_QualifiedFunctionName entry_points[], 6132 Dart_QualifiedFunctionName entry_points[],
6133 bool reset_fields) { 6133 bool reset_fields) {
6134 #if defined(TARGET_ARCH_IA32)
6135 return Api::NewError("Precompilation is not supported on IA32.");
6136 #else
6134 API_TIMELINE_BEGIN_END; 6137 API_TIMELINE_BEGIN_END;
6135 DARTSCOPE(Thread::Current()); 6138 DARTSCOPE(Thread::Current());
6136 if (!FLAG_precompiled_mode) { 6139 if (!FLAG_precompiled_mode) {
6137 return Dart_NewApiError("Flag --precompilation was not specified."); 6140 return Api::NewError("Flag --precompilation was not specified.");
6138 } 6141 }
6139 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); 6142 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T);
6140 if (::Dart_IsError(result)) { 6143 if (::Dart_IsError(result)) {
6141 return result; 6144 return result;
6142 } 6145 }
6143 CHECK_CALLBACK_STATE(T); 6146 CHECK_CALLBACK_STATE(T);
6144 const Error& error = Error::Handle(Precompiler::CompileAll(entry_points, 6147 const Error& error = Error::Handle(Precompiler::CompileAll(entry_points,
6145 reset_fields)); 6148 reset_fields));
6146 if (!error.IsNull()) { 6149 if (!error.IsNull()) {
6147 return Api::NewHandle(T, error.raw()); 6150 return Api::NewHandle(T, error.raw());
6148 } 6151 }
6149 return Api::Success(); 6152 return Api::Success();
6153 #endif
6150 } 6154 }
6151 6155
6152 6156
6153 DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshotAssembly( 6157 DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshotAssembly(
6154 uint8_t** vm_isolate_snapshot_buffer, 6158 uint8_t** vm_isolate_snapshot_buffer,
6155 intptr_t* vm_isolate_snapshot_size, 6159 intptr_t* vm_isolate_snapshot_size,
6156 uint8_t** isolate_snapshot_buffer, 6160 uint8_t** isolate_snapshot_buffer,
6157 intptr_t* isolate_snapshot_size, 6161 intptr_t* isolate_snapshot_size,
6158 uint8_t** assembly_buffer, 6162 uint8_t** assembly_buffer,
6159 intptr_t* assembly_size) { 6163 intptr_t* assembly_size) {
6164 #if defined(TARGET_ARCH_IA32)
6165 return Api::NewError("Snapshots with code are not supported on IA32.");
6166 #else
6160 API_TIMELINE_DURATION; 6167 API_TIMELINE_DURATION;
6161 DARTSCOPE(Thread::Current()); 6168 DARTSCOPE(Thread::Current());
6162 Isolate* I = T->isolate(); 6169 Isolate* I = T->isolate();
6163 if (I->compilation_allowed()) { 6170 if (I->compilation_allowed()) {
6164 return Dart_NewApiError("Isolate is not precompiled. " 6171 return Api::NewError("Isolate is not precompiled. "
6165 "Did you forget to call Dart_Precompile?"); 6172 "Did you forget to call Dart_Precompile?");
6166 } 6173 }
6167 ASSERT(FLAG_load_deferred_eagerly); 6174 ASSERT(FLAG_load_deferred_eagerly);
6168 if (vm_isolate_snapshot_buffer == NULL) { 6175 if (vm_isolate_snapshot_buffer == NULL) {
6169 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer); 6176 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer);
6170 } 6177 }
6171 if (vm_isolate_snapshot_size == NULL) { 6178 if (vm_isolate_snapshot_size == NULL) {
6172 RETURN_NULL_ERROR(vm_isolate_snapshot_size); 6179 RETURN_NULL_ERROR(vm_isolate_snapshot_size);
6173 } 6180 }
6174 if (isolate_snapshot_buffer == NULL) { 6181 if (isolate_snapshot_buffer == NULL) {
6175 RETURN_NULL_ERROR(isolate_snapshot_buffer); 6182 RETURN_NULL_ERROR(isolate_snapshot_buffer);
(...skipping 18 matching lines...) Expand all
6194 isolate_snapshot_buffer, 6201 isolate_snapshot_buffer,
6195 ApiReallocate, 6202 ApiReallocate,
6196 &instructions_writer); 6203 &instructions_writer);
6197 6204
6198 writer.WriteFullSnapshot(); 6205 writer.WriteFullSnapshot();
6199 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 6206 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
6200 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 6207 *isolate_snapshot_size = writer.IsolateSnapshotSize();
6201 *assembly_size = instructions_writer.AssemblySize(); 6208 *assembly_size = instructions_writer.AssemblySize();
6202 6209
6203 return Api::Success(); 6210 return Api::Success();
6211 #endif
6204 } 6212 }
6205 6213
6206 6214
6207 DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshotBlob( 6215 DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshotBlob(
6208 uint8_t** vm_isolate_snapshot_buffer, 6216 uint8_t** vm_isolate_snapshot_buffer,
6209 intptr_t* vm_isolate_snapshot_size, 6217 intptr_t* vm_isolate_snapshot_size,
6210 uint8_t** isolate_snapshot_buffer, 6218 uint8_t** isolate_snapshot_buffer,
6211 intptr_t* isolate_snapshot_size, 6219 intptr_t* isolate_snapshot_size,
6212 uint8_t** instructions_blob_buffer, 6220 uint8_t** instructions_blob_buffer,
6213 intptr_t* instructions_blob_size, 6221 intptr_t* instructions_blob_size,
6214 uint8_t** rodata_blob_buffer, 6222 uint8_t** rodata_blob_buffer,
6215 intptr_t* rodata_blob_size) { 6223 intptr_t* rodata_blob_size) {
6224 #if defined(TARGET_ARCH_IA32)
6225 return Api::NewError("Snapshots with code are not supported on IA32.");
6226 #else
6216 API_TIMELINE_DURATION; 6227 API_TIMELINE_DURATION;
6217 DARTSCOPE(Thread::Current()); 6228 DARTSCOPE(Thread::Current());
6218 Isolate* I = T->isolate(); 6229 Isolate* I = T->isolate();
6219 if (I->compilation_allowed()) { 6230 if (I->compilation_allowed()) {
6220 return Dart_NewApiError("Isolate is not precompiled. " 6231 return Api::NewError("Isolate is not precompiled. "
6221 "Did you forget to call Dart_Precompile?"); 6232 "Did you forget to call Dart_Precompile?");
6222 } 6233 }
6223 ASSERT(FLAG_load_deferred_eagerly); 6234 ASSERT(FLAG_load_deferred_eagerly);
6224 if (vm_isolate_snapshot_buffer == NULL) { 6235 if (vm_isolate_snapshot_buffer == NULL) {
6225 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer); 6236 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer);
6226 } 6237 }
6227 if (vm_isolate_snapshot_size == NULL) { 6238 if (vm_isolate_snapshot_size == NULL) {
6228 RETURN_NULL_ERROR(vm_isolate_snapshot_size); 6239 RETURN_NULL_ERROR(vm_isolate_snapshot_size);
6229 } 6240 }
6230 if (isolate_snapshot_buffer == NULL) { 6241 if (isolate_snapshot_buffer == NULL) {
6231 RETURN_NULL_ERROR(isolate_snapshot_buffer); 6242 RETURN_NULL_ERROR(isolate_snapshot_buffer);
(...skipping 26 matching lines...) Expand all
6258 ApiReallocate, 6269 ApiReallocate,
6259 &instructions_writer); 6270 &instructions_writer);
6260 6271
6261 writer.WriteFullSnapshot(); 6272 writer.WriteFullSnapshot();
6262 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 6273 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
6263 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 6274 *isolate_snapshot_size = writer.IsolateSnapshotSize();
6264 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); 6275 *instructions_blob_size = instructions_writer.InstructionsBlobSize();
6265 *rodata_blob_size = instructions_writer.RodataBlobSize(); 6276 *rodata_blob_size = instructions_writer.RodataBlobSize();
6266 6277
6267 return Api::Success(); 6278 return Api::Success();
6279 #endif
6268 } 6280 }
6269 #endif // DART_PRECOMPILER 6281 #endif // DART_PRECOMPILER
6270 6282
6271 6283
6272 DART_EXPORT Dart_Handle Dart_PrecompileJIT() { 6284 DART_EXPORT Dart_Handle Dart_PrecompileJIT() {
6273 API_TIMELINE_BEGIN_END; 6285 API_TIMELINE_BEGIN_END;
6274 DARTSCOPE(Thread::Current()); 6286 DARTSCOPE(Thread::Current());
6275 Isolate* I = T->isolate(); 6287 Isolate* I = T->isolate();
6276 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); 6288 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T);
6277 if (::Dart_IsError(result)) { 6289 if (::Dart_IsError(result)) {
(...skipping 16 matching lines...) Expand all
6294 error = cls.EnsureIsFinalized(T); 6306 error = cls.EnsureIsFinalized(T);
6295 if (!error.IsNull()) { 6307 if (!error.IsNull()) {
6296 return Api::NewHandle(T, error.raw()); 6308 return Api::NewHandle(T, error.raw());
6297 } 6309 }
6298 } 6310 }
6299 } 6311 }
6300 return Api::Success(); 6312 return Api::Success();
6301 } 6313 }
6302 6314
6303 6315
6304 DART_EXPORT Dart_Handle Dart_CreatePrecompiledJITSnapshotBlob( 6316 DART_EXPORT Dart_Handle Dart_CreateAppJITSnapshot(
6305 uint8_t** vm_isolate_snapshot_buffer, 6317 uint8_t** vm_isolate_snapshot_buffer,
6306 intptr_t* vm_isolate_snapshot_size, 6318 intptr_t* vm_isolate_snapshot_size,
6307 uint8_t** isolate_snapshot_buffer, 6319 uint8_t** isolate_snapshot_buffer,
6308 intptr_t* isolate_snapshot_size, 6320 intptr_t* isolate_snapshot_size,
6309 uint8_t** instructions_blob_buffer, 6321 uint8_t** instructions_blob_buffer,
6310 intptr_t* instructions_blob_size, 6322 intptr_t* instructions_blob_size,
6311 uint8_t** rodata_blob_buffer, 6323 uint8_t** rodata_blob_buffer,
6312 intptr_t* rodata_blob_size) { 6324 intptr_t* rodata_blob_size) {
6325 #if defined(TARGET_ARCH_IA32)
6326 return Api::NewError("Snapshots with code are not supported on IA32.");
6327 #else
6313 API_TIMELINE_DURATION; 6328 API_TIMELINE_DURATION;
6314 DARTSCOPE(Thread::Current()); 6329 DARTSCOPE(Thread::Current());
6315 Isolate* I = T->isolate(); 6330 Isolate* I = T->isolate();
6316 if (!FLAG_load_deferred_eagerly) { 6331 if (!FLAG_load_deferred_eagerly) {
6317 return Dart_NewApiError( 6332 return Api::NewError(
6318 "Creating full snapshots requires --load_deferred_eagerly"); 6333 "Creating full snapshots requires --load_deferred_eagerly");
6319 } 6334 }
6320 if (vm_isolate_snapshot_buffer == NULL) { 6335 if (vm_isolate_snapshot_buffer == NULL) {
6321 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer); 6336 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer);
6322 } 6337 }
6323 if (vm_isolate_snapshot_size == NULL) { 6338 if (vm_isolate_snapshot_size == NULL) {
6324 RETURN_NULL_ERROR(vm_isolate_snapshot_size); 6339 RETURN_NULL_ERROR(vm_isolate_snapshot_size);
6325 } 6340 }
6326 if (isolate_snapshot_buffer == NULL) { 6341 if (isolate_snapshot_buffer == NULL) {
6327 RETURN_NULL_ERROR(isolate_snapshot_buffer); 6342 RETURN_NULL_ERROR(isolate_snapshot_buffer);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 isolate_snapshot_buffer, 6374 isolate_snapshot_buffer,
6360 ApiReallocate, 6375 ApiReallocate,
6361 &instructions_writer); 6376 &instructions_writer);
6362 writer.WriteFullSnapshot(); 6377 writer.WriteFullSnapshot();
6363 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 6378 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
6364 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 6379 *isolate_snapshot_size = writer.IsolateSnapshotSize();
6365 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); 6380 *instructions_blob_size = instructions_writer.InstructionsBlobSize();
6366 *rodata_blob_size = instructions_writer.RodataBlobSize(); 6381 *rodata_blob_size = instructions_writer.RodataBlobSize();
6367 6382
6368 return Api::Success(); 6383 return Api::Success();
6384 #endif
6369 } 6385 }
6370 6386
6371 6387
6372 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { 6388 DART_EXPORT bool Dart_IsRunningPrecompiledCode() {
6373 return Snapshot::IncludesCode(Dart::snapshot_kind()); 6389 return Snapshot::IncludesCode(Dart::snapshot_kind());
6374 } 6390 }
6375 6391
6376 6392
6377 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6393 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6378 #if defined(DART_PRECOMPILED_RUNTIME) 6394 #if defined(DART_PRECOMPILED_RUNTIME)
6379 return true; 6395 return true;
6380 #else 6396 #else
6381 return false; 6397 return false;
6382 #endif 6398 #endif
6383 } 6399 }
6384 6400
6385 } // namespace dart 6401 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698