Revert "[vm/kernel] Expression execution through Kernel.

This reverts commit afd0a52a5a.

Reason for revert: Breaks kernel-a32 and kernel-rbc bots

Original change's description:
> [vm/kernel] Expression execution through Kernel.
> 
> Change-Id: Id90c91cb3b71f9ce703e21fe48147b86a7764d34
> Reviewed-on: https://dart-review.googlesource.com/42562
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Samir Jindel <sjindel@google.com>

TBR=aam@google.com,rmacnak@google.com,sjindel@google.com

Change-Id: If1ecad6145aeab81d5d3581798a628ead0265c38
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/54420
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
This commit is contained in:
Samir Jindel 2018-05-09 12:41:00 +00:00 committed by commit-bot@chromium.org
parent 2daa5610ac
commit b5154dd01e
28 changed files with 48 additions and 535 deletions

View file

@ -61,7 +61,6 @@ abstract class IncrementalKernelGenerator {
String expression,
Map<String, DartType> definitions,
List<TypeParameter> typeDefinitions,
String syntheticProcedureName,
Uri libraryUri,
[String className,
bool isStatic = false]);

View file

@ -360,7 +360,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
String expression,
Map<String, DartType> definitions,
List<TypeParameter> typeDefinitions,
String syntheticProcedureName,
Uri libraryUri,
[String className,
bool isStatic = false]) async {
@ -441,7 +440,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
debugLibrary, className, className != null && !isStatic, parameters);
Procedure procedure = new Procedure(
new Name(syntheticProcedureName), ProcedureKind.Method, parameters,
new Name("debugExpr"), ProcedureKind.Method, parameters,
isStatic: isStatic);
parameters.body = new ReturnStatement(compiledExpression)

View file

@ -6,10 +6,7 @@ import 'dart:async' show Future;
import 'dart:io' show BytesBuilder, File, IOSink;
import 'package:kernel/clone.dart' show CloneVisitor;
import 'package:kernel/ast.dart'
show Library, Component, Procedure, Class, TypeParameter, Supertype;
import 'package:kernel/ast.dart' show Library, Component;
import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
@ -61,39 +58,6 @@ List<int> serializeComponent(Component component,
return byteSink.builder.takeBytes();
}
List<int> serializeProcedure(Procedure procedure) {
Library fakeLibrary =
new Library(new Uri(scheme: 'evaluate', path: 'source'));
if (procedure.parent is Class) {
Class realClass = procedure.parent;
CloneVisitor cloner = new CloneVisitor();
Class fakeClass = new Class(name: realClass.name);
for (TypeParameter typeParam in realClass.typeParameters) {
fakeClass.typeParameters.add(typeParam.accept(cloner));
}
fakeClass.parent = fakeLibrary;
fakeClass.supertype = new Supertype.byReference(
realClass.supertype.className,
realClass.supertype.typeArguments.map(cloner.visitType).toList());
// Rebind the type parameters in the procedure.
procedure = procedure.accept(cloner);
procedure.parent = fakeClass;
fakeClass.procedures.add(procedure);
fakeLibrary.classes.add(fakeClass);
} else {
fakeLibrary.procedures.add(procedure);
procedure.parent = fakeLibrary;
}
Component program = new Component(libraries: [fakeLibrary]);
return serializeComponent(program);
}
/// A [Sink] that directly writes data into a byte builder.
class ByteSink implements Sink<List<int>> {
final BytesBuilder builder = new BytesBuilder();

View file

@ -325,7 +325,6 @@ class CompileExpression extends Step<List<TestCase>, List<TestCase>, Context> {
test.expression,
definitions,
typeParams,
"debugExpr",
test.library,
test.className,
test.isStaticMethod);

View file

@ -217,7 +217,6 @@ dart/spawn_shutdown_test: SkipSlow
cc/IsolateReload_KernelIncrementalCompile: Skip
cc/IsolateReload_KernelIncrementalCompileAppAndLib: Skip
cc/IsolateReload_KernelIncrementalCompileGenerics: Skip
cc/IsolateReload_KernelIncrementalCompileExpression: Skip
cc/Mixin_PrivateSuperResolution: Skip
cc/Mixin_PrivateSuperResolutionCrossLibraryShouldFail: Skip

View file

@ -33,7 +33,7 @@ import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
import 'package:front_end/src/fasta/kernel/utils.dart';
import 'package:front_end/src/fasta/hybrid_file_system.dart';
import 'package:kernel/kernel.dart' show Component, Procedure;
import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/target/targets.dart' show TargetFlags;
import 'package:kernel/target/vm.dart' show VmTarget;
import 'package:vm/incremental_compiler.dart';
@ -49,15 +49,10 @@ const String platformKernelFile = 'virtual_platform_kernel.dill';
// 1 - Update in-memory file system with in-memory sources (used by tests).
// 2 - Accept last compilation result.
// 3 - APP JIT snapshot training run for kernel_service.
// 4 - Compile an individual expression in some context (for debugging
// purposes).
const int kCompileTag = 0;
const int kUpdateSourcesTag = 1;
const int kAcceptTag = 2;
const int kTrainTag = 3;
const int kCompileExpressionTag = 4;
bool allowDartInternalImport = false;
abstract class Compiler {
final FileSystem fileSystem;
@ -182,10 +177,9 @@ class SingleShotCompilerWrapper extends Compiler {
}
}
final Map<int, IncrementalCompilerWrapper> isolateCompilers =
new Map<int, IncrementalCompilerWrapper>();
final Map<int, Compiler> isolateCompilers = new Map<int, Compiler>();
IncrementalCompilerWrapper lookupIncrementalCompiler(int isolateId) {
Compiler lookupIncrementalCompiler(int isolateId) {
return isolateCompilers[isolateId];
}
@ -248,60 +242,10 @@ void invalidateSources(IncrementalCompilerWrapper compiler, List sourceFiles) {
// Process a request from the runtime. See KernelIsolate::CompileToKernel in
// kernel_isolate.cc and Loader::SendKernelRequest in loader.cc.
Future _processExpressionCompilationRequest(request) async {
final SendPort port = request[1];
final int isolateId = request[2];
final String expression = request[3];
final List definitions = request[4];
final List typeDefinitions = request[5];
final String libraryUri = request[6];
final String klass = request[7]; // might be null
final bool isStatic = request[8];
IncrementalCompilerWrapper compiler = isolateCompilers[isolateId];
if (compiler == null) {
port.send(new CompilationResult.errors(
["No incremental compiler available for this isolate."]).toResponse());
return;
}
compiler.errors.clear();
CompilationResult result;
try {
Procedure procedure = await compiler.generator.compileExpression(
expression, definitions, typeDefinitions, libraryUri, klass, isStatic);
if (procedure == null) {
port.send(new CompilationResult.errors(["Invalid scope."]).toResponse());
return;
}
if (compiler.errors.isNotEmpty) {
// TODO(sigmund): the compiler prints errors to the console, so we
// shouldn't print those messages again here.
result = new CompilationResult.errors(compiler.errors);
} else {
result = new CompilationResult.ok(serializeProcedure(procedure));
}
} catch (error, stack) {
result = new CompilationResult.crash(error, stack);
}
port.send(result.toResponse());
}
Future _processLoadRequest(request) async {
if (verbose) print("DFE: request: $request");
int tag = request[0];
if (tag == kCompileExpressionTag) {
await _processExpressionCompilationRequest(request);
return;
}
final SendPort port = request[1];
final String inputFileUri = request[2];
final Uri script =

View file

@ -10,8 +10,6 @@ import 'package:front_end/src/api_prototype/compiler_options.dart';
import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
import 'package:kernel/kernel.dart';
const String kDebugProcedureName = ":Eval";
/// Wrapper around [IncrementalKernelGenerator] that keeps track of rejected
/// deltas and combines them together into resultant program until it is
/// accepted.
@ -76,30 +74,4 @@ class IncrementalCompiler {
_pendingDeltas.clear();
fullComponent = true;
}
Future<Procedure> compileExpression(
String expression,
List<String> definitions,
List<String> typeDefinitions,
String libraryUri,
String klass,
bool isStatic) {
Map<String, DartType> completeDefinitions = {};
for (String name in definitions) {
if (!isLegalIdentifier(name)) continue;
completeDefinitions[name] = new DynamicType();
}
List<TypeParameter> typeParameters = [];
for (String name in typeDefinitions) {
if (!isLegalIdentifier(name)) continue;
typeParameters.add(new TypeParameter(name, new DynamicType()));
}
Uri library = Uri.parse(libraryUri);
if (library == null) return null;
return _generator.compileExpression(expression, completeDefinitions,
typeParameters, kDebugProcedureName, library, klass, isStatic);
}
}

View file

@ -69,8 +69,7 @@ Future testAsync(Isolate isolate) async {
var hits = [];
isolate.rootLibrary.evaluate('testerReady = true').then((result) {
print(result);
isolate.rootLibrary.evaluate('testerReady = true;').then((result) {
expect((result as Instance).valueAsString, equals('true'));
});

View file

@ -72,11 +72,9 @@ var tests = <IsolateTest>[
expect(reasonForCancelling['type'], equals('ReasonForCancelling'));
expect(reasonForCancelling['message'], contains('library_isnt_here_man'));
// TODO(32341): enable in Dart 2
if (!Platform.executableArguments.contains("--preview_dart_2")) {
String v2 = await invokeTest(spawnedIsolate);
expect(v2, 'apple');
}
// Invoke test in v2.
String v2 = await invokeTest(spawnedIsolate);
expect(v2, 'apple');
}
];

View file

@ -32,7 +32,7 @@ var tests = <IsolateTest>[
});
// Start listening for events first.
await isolate.rootLibrary.evaluate('testeeDo()');
await isolate.rootLibrary.evaluate('testeeDo();');
return completer.future;
},
];

View file

@ -114,7 +114,7 @@ Future testMethod(Isolate isolate) async {
}
});
var result = await rootLib.evaluate('new C().method(3)');
var result = await rootLib.evaluate('new C().method(3);');
print("Result $result");
expect(hitBreakpoint, isTrue);
}
@ -163,7 +163,7 @@ Future testMethod2(Isolate isolate) async {
}
});
var result = await rootLib.evaluate('C.method2(3)');
var result = await rootLib.evaluate('C.method2(3);');
print("Result $result");
expect(hitBreakpoint, isTrue);
}
@ -204,7 +204,7 @@ Future testMethod3(Isolate isolate) async {
}
});
var result = await rootLib.evaluate('new C().method3(3)');
var result = await rootLib.evaluate('new C().method3(3);');
print("Result $result");
expect(hitBreakpoint, isTrue);
}

View file

@ -40,7 +40,7 @@ var tests = <IsolateTest>[
// Expect a simple path through variable x instead of long path filled
// with VM objects
(Isolate isolate) async {
var target1 = await eval(isolate, 'x');
var target1 = await eval(isolate, 'x;');
var params = {
'targetId': target1['id'],
'limit': 100,
@ -56,7 +56,7 @@ var tests = <IsolateTest>[
// Expect a simple path through variable fn instead of long path filled
// with VM objects
(Isolate isolate) async {
var target2 = await eval(isolate, 'fn');
var target2 = await eval(isolate, 'fn;');
var params = {
'targetId': target2['id'],
'limit': 100,

View file

@ -11,6 +11,7 @@ async_star_single_step_into_test: RuntimeError # Issue 29158, Async debugging
async_star_step_out_test: RuntimeError # Issue 29158, Async debugging
async_step_out_test: RuntimeError # Issue 29158, Async debugging
awaiter_async_stack_contents_test: RuntimeError # Issue 29158, Async debugging
eval_internal_class_test: RuntimeError
evaluate_activation_in_method_class_test: RuntimeError
evaluate_activation_test/instance: RuntimeError
evaluate_activation_test/scope: RuntimeError

View file

@ -55,7 +55,6 @@ dart/redirection_type_shuffling_test/none: RuntimeError
[ $compiler != dartk ]
cc/IsolateReload_KernelIncrementalCompile: SkipByDesign
cc/IsolateReload_KernelIncrementalCompileAppAndLib: SkipByDesign
cc/IsolateReload_KernelIncrementalCompileExpression: SkipByDesign
cc/IsolateReload_KernelIncrementalCompileGenerics: SkipByDesign
cc/Mixin_PrivateSuperResolution: Skip
cc/Mixin_PrivateSuperResolutionCrossLibraryShouldFail: Skip

View file

@ -336,7 +336,7 @@ static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) {
// The platform binary may contain other libraries (e.g., dart:_builtin or
// dart:io) that will not be bundled with application. Load them now.
const Object& result = Object::Handle(zone, loader.LoadProgram());
const Object& result = loader.LoadProgram();
if (result.IsError()) {
return Error::Cast(result).raw();
}

View file

@ -96,7 +96,7 @@ RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) {
// The platform binary may contain other libraries (e.g., dart:_builtin or
// dart:io) that will not be bundled with application. Load them now.
const Object& result = Object::Handle(loader.LoadProgram());
const Object& result = loader.LoadProgram();
if (result.IsError()) {
return Error::Cast(result).raw();
}

View file

@ -179,10 +179,6 @@ TEST_CASE(EvalExpression) {
}
ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) {
{ // Initialize an incremental compiler in DFE mode.
TransitionVMToNative transition(thread);
TestCase::LoadTestScript("", NULL);
}
Library& lib = Library::Handle(Library::CoreLibrary());
const String& expression = String::Handle(
@ -197,10 +193,6 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) {
}
ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) {
{ // Initialize an incremental compiler in DFE mode.
TransitionVMToNative transition(thread);
TestCase::LoadTestScript("", NULL);
}
Library& lib = Library::Handle(Library::CoreLibrary());
const String& expression = String::Handle(String::New("3 + 4"));

View file

@ -8,7 +8,6 @@
#include "vm/debugger_api_impl_test.h"
#include "vm/globals.h"
#include "vm/isolate.h"
#include "vm/kernel_loader.h"
#include "vm/lockers.h"
#include "vm/thread_barrier.h"
#include "vm/thread_pool.h"

View file

@ -52,7 +52,6 @@ const int KernelIsolate::kCompileTag = 0;
const int KernelIsolate::kUpdateSourcesTag = 1;
const int KernelIsolate::kAcceptTag = 2;
const int KernelIsolate::kTrainTag = 3;
const int KernelIsolate::kCompileExpressionTag = 4;
Dart_IsolateCreateCallback KernelIsolate::create_callback_ = NULL;
Monitor* KernelIsolate::monitor_ = new Monitor();
@ -341,125 +340,6 @@ class KernelCompilationRequest : public ValueObject {
delete monitor_;
}
Dart_KernelCompilationResult SendAndWaitForResponse(
Dart_Port kernel_port,
const char* expression,
const Array& definitions,
const Array& type_definitions,
char const* library_uri,
char const* klass,
bool is_static) {
Dart_CObject tag;
tag.type = Dart_CObject_kInt32;
tag.value.as_int32 = KernelIsolate::kCompileExpressionTag;
Dart_CObject send_port;
send_port.type = Dart_CObject_kSendPort;
send_port.value.as_send_port.id = port_;
send_port.value.as_send_port.origin_id = ILLEGAL_PORT;
Dart_CObject expression_object;
expression_object.type = Dart_CObject_kString;
expression_object.value.as_string = const_cast<char*>(expression);
Dart_CObject definitions_object;
intptr_t num_definitions = definitions.Length();
definitions_object.type = Dart_CObject_kArray;
definitions_object.value.as_array.length = num_definitions;
Dart_CObject** definitions_array = new Dart_CObject*[num_definitions];
for (intptr_t i = 0; i < num_definitions; ++i) {
definitions_array[i] = new Dart_CObject;
definitions_array[i]->type = Dart_CObject_kString;
definitions_array[i]->value.as_string = const_cast<char*>(
String::CheckedHandle(definitions.At(i)).ToCString());
}
definitions_object.value.as_array.values = definitions_array;
Dart_CObject type_definitions_object;
intptr_t num_type_definitions = type_definitions.Length();
type_definitions_object.type = Dart_CObject_kArray;
type_definitions_object.value.as_array.length = num_type_definitions;
Dart_CObject** type_definitions_array =
new Dart_CObject*[num_type_definitions];
for (intptr_t i = 0; i < num_type_definitions; ++i) {
type_definitions_array[i] = new Dart_CObject;
type_definitions_array[i]->type = Dart_CObject_kString;
type_definitions_array[i]->value.as_string = const_cast<char*>(
String::CheckedHandle(type_definitions.At(i)).ToCString());
}
type_definitions_object.value.as_array.values = type_definitions_array;
Dart_CObject library_uri_object;
library_uri_object.type = Dart_CObject_kString;
library_uri_object.value.as_string = const_cast<char*>(library_uri);
Dart_CObject class_object;
if (klass != NULL) {
class_object.type = Dart_CObject_kString;
class_object.value.as_string = const_cast<char*>(klass);
} else {
class_object.type = Dart_CObject_kNull;
}
Dart_CObject is_static_object;
is_static_object.type = Dart_CObject_kBool;
is_static_object.value.as_bool = is_static;
Isolate* isolate =
Thread::Current() != NULL ? Thread::Current()->isolate() : NULL;
ASSERT(isolate != NULL);
Dart_CObject isolate_id;
isolate_id.type = Dart_CObject_kInt64;
isolate_id.value.as_int64 =
isolate != NULL ? static_cast<int64_t>(isolate->main_port()) : 0;
Dart_CObject message;
message.type = Dart_CObject_kArray;
Dart_CObject suppress_warnings;
suppress_warnings.type = Dart_CObject_kBool;
suppress_warnings.value.as_bool = FLAG_suppress_fe_warnings;
Dart_CObject dart_sync_async;
dart_sync_async.type = Dart_CObject_kBool;
dart_sync_async.value.as_bool = FLAG_sync_async;
Dart_CObject* message_arr[] = {&tag,
&send_port,
&isolate_id,
&expression_object,
&definitions_object,
&type_definitions_object,
&library_uri_object,
&class_object,
&is_static_object,
&suppress_warnings,
&dart_sync_async};
message.value.as_array.values = message_arr;
message.value.as_array.length = ARRAY_SIZE(message_arr);
// Send the message.
Dart_PostCObject(kernel_port, &message);
// Wait for reply to arrive.
MonitorLocker ml(monitor_);
while (result_.status == Dart_KernelCompilationStatus_Unknown) {
ml.Wait();
}
for (intptr_t i = 0; i < num_definitions; ++i) {
delete definitions_array[i];
}
delete[] definitions_array;
for (intptr_t i = 0; i < num_type_definitions; ++i) {
delete type_definitions_array[i];
}
delete[] type_definitions_array;
return result_;
}
Dart_KernelCompilationResult SendAndWaitForResponse(
int request_tag,
Dart_Port kernel_port,
@ -722,27 +602,6 @@ Dart_KernelCompilationResult KernelIsolate::AcceptCompilation() {
0, NULL, true, NULL);
}
Dart_KernelCompilationResult KernelIsolate::CompileExpressionToKernel(
const char* expression,
const Array& definitions,
const Array& type_definitions,
const char* library_url,
const char* klass,
bool is_static) {
Dart_Port kernel_port = WaitForKernelPort();
if (kernel_port == ILLEGAL_PORT) {
Dart_KernelCompilationResult result;
result.status = Dart_KernelCompilationStatus_Unknown;
result.error = strdup("Error while initializing Kernel isolate");
return result;
}
KernelCompilationRequest request;
return request.SendAndWaitForResponse(kernel_port, expression, definitions,
type_definitions, library_url, klass,
is_static);
}
Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources(
int source_files_count,
Dart_SourceFile source_files[]) {

View file

@ -8,7 +8,6 @@
#if !defined(DART_PRECOMPILED_RUNTIME)
#include "include/dart_api.h"
#include "include/dart_native_api.h"
#include "vm/allocation.h"
#include "vm/dart.h"
@ -23,7 +22,6 @@ class KernelIsolate : public AllStatic {
static const int kUpdateSourcesTag;
static const int kAcceptTag;
static const int kTrainTag;
static const int kCompileExpressionTag;
static void Run();
@ -48,14 +46,6 @@ class KernelIsolate : public AllStatic {
int source_files_count,
Dart_SourceFile source_files[]);
static Dart_KernelCompilationResult CompileExpressionToKernel(
const char* expression,
const Array& definitions,
const Array& type_definitions,
const char* library_url,
const char* klass,
bool is_static);
protected:
static Monitor* monitor_;
static Dart_IsolateCreateCallback create_callback_;

View file

@ -195,7 +195,7 @@ Object& KernelLoader::LoadEntireProgram(Program* program,
bool process_pending_classes) {
if (program->is_single_program()) {
KernelLoader loader(program);
return Object::Handle(loader.LoadProgram(process_pending_classes));
return loader.LoadProgram(process_pending_classes);
}
kernel::Reader reader(program->kernel_data(), program->kernel_data_size());
@ -216,7 +216,7 @@ Object& KernelLoader::LoadEntireProgram(Program* program,
Program* subprogram = Program::ReadFrom(&reader, false);
ASSERT(subprogram->is_single_program());
KernelLoader loader(subprogram);
Object& load_result = Object::Handle(loader.LoadProgram(false));
Object& load_result = loader.LoadProgram(false);
if (load_result.IsError()) return load_result;
if (library.IsNull() && load_result.IsLibrary()) {
@ -545,7 +545,7 @@ void KernelLoader::LoadNativeExtensionLibraries(const Array& constant_table) {
potential_extension_libraries_ = GrowableObjectArray::null();
}
RawObject* KernelLoader::LoadProgram(bool process_pending_classes) {
Object& KernelLoader::LoadProgram(bool process_pending_classes) {
ASSERT(kernel_program_info_.constants() == Array::null());
if (!program_->is_single_program()) {
@ -557,15 +557,15 @@ RawObject* KernelLoader::LoadProgram(bool process_pending_classes) {
LongJumpScope jump;
if (setjmp(*jump.Set()) == 0) {
const intptr_t length = program_->library_count();
Object& last_library = Library::Handle(Z);
for (intptr_t i = 0; i < length; i++) {
last_library = LoadLibrary(i);
LoadLibrary(i);
}
if (process_pending_classes) {
if (!ClassFinalizer::ProcessPendingClasses()) {
// Class finalization failed -> sticky error would be set.
RawError* error = H.thread()->sticky_error();
Error& error = Error::Handle(Z);
error = H.thread()->sticky_error();
H.thread()->clear_sticky_error();
return error;
}
@ -586,18 +586,19 @@ RawObject* KernelLoader::LoadProgram(bool process_pending_classes) {
NameIndex main = program_->main_method();
if (main == -1) {
return Library::null();
return Library::Handle(Z);
}
NameIndex main_library = H.EnclosingName(main);
Library& library = LookupLibrary(main_library);
return library.raw();
return library;
}
// Either class finalization failed or we caught a compile error.
// In both cases sticky error would be set.
RawError* error = thread_->sticky_error();
Error& error = Error::Handle(Z);
error = thread_->sticky_error();
thread_->clear_sticky_error();
return error;
}
@ -682,7 +683,7 @@ void KernelLoader::CheckForInitializer(const Field& field) {
field.set_has_initializer(false);
}
RawLibrary* KernelLoader::LoadLibrary(intptr_t index) {
void KernelLoader::LoadLibrary(intptr_t index) {
if (!program_->is_single_program()) {
FATAL(
"Trying to load a concatenated dill file at a time where that is "
@ -712,16 +713,15 @@ RawLibrary* KernelLoader::LoadLibrary(intptr_t index) {
// snapshot so we skip loading 'dart:vmservice_io'.
skip_vmservice_library_ = library_helper.canonical_name_;
ASSERT(H.IsLibrary(skip_vmservice_library_));
return Library::null();
return;
}
}
Library& library =
Library::Handle(Z, LookupLibrary(library_helper.canonical_name_).raw());
Library& library = LookupLibrary(library_helper.canonical_name_);
// The Kernel library is external implies that it is already loaded.
ASSERT(!library_helper.IsExternal() || library.Loaded());
if (library.Loaded()) return library.raw();
if (library.Loaded()) return;
library_kernel_data_ =
TypedData::New(kTypedDataUint8ArrayCid, library_size, Heap::kOld);
@ -846,8 +846,6 @@ RawLibrary* KernelLoader::LoadLibrary(intptr_t index) {
toplevel_class.SetFunctions(Array::Handle(MakeFunctionsArray()));
classes.Add(toplevel_class, Heap::kOld);
if (!library.Loaded()) library.SetLoaded();
return library.raw();
}
void KernelLoader::LoadLibraryImportsAndExports(Library* library) {

View file

@ -128,7 +128,7 @@ class KernelLoader : public ValueObject {
// Returns the library containing the main procedure, null if there
// was no main procedure, or a failure object if there was an error.
RawObject* LoadProgram(bool process_pending_classes = true);
Object& LoadProgram(bool process_pending_classes = true);
// Finds all libraries that have been modified in this incremental
// version of the kernel program file.
@ -137,7 +137,7 @@ class KernelLoader : public ValueObject {
BitVector* modified_libs,
bool force_reload);
RawLibrary* LoadLibrary(intptr_t index);
void LoadLibrary(intptr_t index);
static void FinishLoading(const Class& klass);

View file

@ -34,8 +34,6 @@
#include "vm/heap.h"
#include "vm/isolate_reload.h"
#include "vm/kernel.h"
#include "vm/kernel_isolate.h"
#include "vm/kernel_loader.h"
#include "vm/native_symbol.h"
#include "vm/object_store.h"
#include "vm/parser.h"
@ -3197,14 +3195,6 @@ static RawString* BuildClosureSource(const Array& formal_params,
return String::ConcatAll(Array::Handle(Array::MakeFixedLength(src_pieces)));
}
static RawObject* EvaluateWithDFEHelper(const String& expression,
const Array& definitions,
const Array& type_definitions,
const String& library_url,
const String& klass,
bool is_static,
const Array& arguments);
RawFunction* Function::EvaluateHelper(const Class& cls,
const String& expr,
const Array& param_names,
@ -3231,12 +3221,6 @@ RawFunction* Function::EvaluateHelper(const Class& cls,
return func.raw();
}
#if !defined(DART_PRECOMPILED_RUNTIME)
static void ReleaseFetchedBytes(uint8_t* buffer) {
free(buffer);
}
#endif
RawObject* Class::Evaluate(const String& expr,
const Array& param_names,
const Array& param_values) const {
@ -3248,17 +3232,11 @@ RawObject* Class::Evaluate(const String& expr,
return UnhandledException::New(exception, stacktrace);
}
if (Library::Handle(library()).kernel_data() == TypedData::null()) {
const Function& eval_func = Function::Handle(
Function::EvaluateHelper(*this, expr, param_names, true));
return DartEntry::InvokeFunction(eval_func, param_values);
}
return EvaluateWithDFEHelper(
expr, param_names, Array::Handle(Array::New(0)),
String::Handle(Library::Handle(library()).url()),
IsTopLevel() ? String::Handle() : String::Handle(UserVisibleName()),
!IsTopLevel(), param_values);
const Function& eval_func = Function::Handle(
Function::EvaluateHelper(*this, expr, param_names, true));
const Object& result =
Object::Handle(DartEntry::InvokeFunction(eval_func, param_values));
return result.raw();
}
// Ensure that top level parsing of the class has been done.
@ -6055,9 +6033,6 @@ void Function::SetRedirectionTarget(const Function& target) const {
// This field is heavily overloaded:
// eval function: Script expression source
// kernel eval function: Array[0] = Script
// Array[1] = Kernel data
// Array[2] = Kernel offset of enclosing library
// signature function: SignatureData
// method extractor: Function extracted closure function
// noSuchMethod dispatcher: Array arguments descriptor
@ -7530,26 +7505,9 @@ RawClass* Function::origin() const {
return PatchClass::Cast(obj).origin_class();
}
void Function::SetKernelDataAndScript(const Script& script,
const TypedData& data,
intptr_t offset) {
Array& data_field = Array::Handle(Array::New(3));
data_field.SetAt(0, script);
data_field.SetAt(1, data);
data_field.SetAt(2, Smi::Handle(Smi::New(offset)));
set_data(data_field);
}
RawScript* Function::script() const {
// NOTE(turnidge): If you update this function, you probably want to
// update Class::PatchFieldsAndFunctions() at the same time.
Object& data = Object::Handle(raw_ptr()->data_);
if (data.IsArray()) {
Object& script = Object::Handle(Array::Cast(data).At(0));
if (script.IsScript()) {
return Script::Cast(script).raw();
}
}
if (token_pos() == TokenPosition::kMinSource) {
// Testing for position 0 is an optimization that relies on temporary
// eval functions having token position 0.
@ -7574,13 +7532,6 @@ RawScript* Function::script() const {
}
RawTypedData* Function::KernelData() const {
Object& data = Object::Handle(raw_ptr()->data_);
if (data.IsArray()) {
Object& script = Object::Handle(Array::Cast(data).At(0));
if (script.IsScript()) {
return TypedData::RawCast(Array::Cast(data).At(1));
}
}
if (IsClosureFunction()) {
Function& parent = Function::Handle(parent_function());
ASSERT(!parent.IsNull());
@ -7597,13 +7548,6 @@ RawTypedData* Function::KernelData() const {
}
intptr_t Function::KernelDataProgramOffset() const {
Object& data = Object::Handle(raw_ptr()->data_);
if (data.IsArray()) {
Object& script = Object::Handle(Array::Cast(data).At(0));
if (script.IsScript()) {
return Smi::Value(Smi::RawCast(Array::Cast(data).At(2)));
}
}
if (IsClosureFunction()) {
Function& parent = Function::Handle(parent_function());
ASSERT(!parent.IsNull());
@ -11366,15 +11310,10 @@ void Library::InitCoreLibrary(Isolate* isolate) {
RawObject* Library::Evaluate(const String& expr,
const Array& param_names,
const Array& param_values) const {
if (kernel_data() == TypedData::null()) {
// Evaluate the expression as a static function of the toplevel class.
Class& top_level_class = Class::Handle(toplevel_class());
ASSERT(top_level_class.is_finalized());
return top_level_class.Evaluate(expr, param_names, param_values);
}
return EvaluateWithDFEHelper(expr, param_names, Array::Handle(Array::New(0)),
String::Handle(url()), String::Handle(), false,
param_values);
// Evaluate the expression as a static function of the toplevel class.
Class& top_level_class = Class::Handle(toplevel_class());
ASSERT(top_level_class.is_finalized());
return top_level_class.Evaluate(expr, param_names, param_values);
}
void Library::InitNativeWrappersLibrary(Isolate* isolate, bool is_kernel) {
@ -11431,118 +11370,6 @@ class LibraryLookupTraits {
};
typedef UnorderedHashMap<LibraryLookupTraits> LibraryLookupMap;
static RawObject* EvaluateWithDFEHelper(const String& expression,
const Array& definitions,
const Array& type_definitions,
const String& library_url,
const String& klass,
bool is_static,
const Array& arguments) {
#if defined(DART_PRECOMPILED_RUNTIME)
const String& error_str = String::Handle(
String::New("Kernel service isolate not available in precompiled mode."));
return ApiError::New(error_str);
#else
Isolate* I = Isolate::Current();
Thread* T = Thread::Current();
Dart_KernelCompilationResult compilation_result;
{
TransitionVMToNative transition(T);
compilation_result = KernelIsolate::CompileExpressionToKernel(
expression.ToCString(), definitions, type_definitions,
library_url.ToCString(), klass.IsNull() ? NULL : klass.ToCString(),
is_static);
}
Function& callee = Function::Handle();
intptr_t num_cids = I->class_table()->NumCids();
intptr_t num_libs =
GrowableObjectArray::Handle(I->object_store()->libraries()).Length();
void* kernel_pgm = NULL;
if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
const String& prefix =
String::Handle(String::New("Kernel isolate rejected this request:\n"));
const String& error_str = String::Handle(String::Concat(
prefix, String::Handle(String::New(compilation_result.error))));
free(compilation_result.error);
return ApiError::New(error_str);
}
const uint8_t* kernel_file = compilation_result.kernel;
intptr_t kernel_length = compilation_result.kernel_size;
ASSERT(kernel_file != NULL);
kernel_pgm =
Dart_ReadKernelBinary(kernel_file, kernel_length, ReleaseFetchedBytes);
if (kernel_pgm == NULL) {
return ApiError::New(String::Handle(
String::New("Kernel isolate returned ill-formed kernel.")));
}
// Load the program with the debug procedure as a regular, independent
// program.
kernel::KernelLoader loader(reinterpret_cast<kernel::Program*>(kernel_pgm));
loader.LoadProgram();
ASSERT(I->class_table()->NumCids() > num_cids &&
GrowableObjectArray::Handle(I->object_store()->libraries()).Length() ==
num_libs + 1);
const String& fake_library_url =
String::Handle(String::New("evaluate:source"));
const Library& loaded =
Library::Handle(Library::LookupLibrary(T, fake_library_url));
ASSERT(!loaded.IsNull());
String& debug_name = String::Handle(
String::New(Symbols::Symbol(Symbols::kDebugProcedureNameId)));
Class& fake_class = Class::Handle();
if (!klass.IsNull()) {
fake_class = loaded.LookupClass(String::Handle(String::New(klass)));
ASSERT(!fake_class.IsNull());
callee = fake_class.LookupFunctionAllowPrivate(debug_name);
} else {
callee = loaded.LookupFunctionAllowPrivate(debug_name);
}
ASSERT(!callee.IsNull());
// Save the loaded library's kernel data to the generic "data" field of the
// callee, so it doesn't require access it's parent library during
// compilation.
callee.SetKernelDataAndScript(Script::Handle(callee.script()),
TypedData::Handle(loaded.kernel_data()),
loaded.kernel_offset());
// Reparent the callee to the real enclosing class so we can remove the fake
// class and library from the object store.
const Library& real_library =
Library::Handle(Library::LookupLibrary(T, library_url));
ASSERT(!real_library.IsNull());
Class& real_class = Class::Handle();
if (!klass.IsNull()) {
real_class = real_library.LookupClass(String::Handle(String::New(klass)));
} else {
real_class = real_library.toplevel_class();
}
ASSERT(!real_class.IsNull());
callee.set_owner(real_class);
// Unlink the fake library and class from the object store.
GrowableObjectArray::Handle(I->object_store()->libraries())
.SetLength(num_libs);
I->class_table()->SetNumCids(num_cids);
if (!fake_class.IsNull()) {
fake_class.set_id(kIllegalCid);
}
LibraryLookupMap libraries_map(I->object_store()->libraries_map());
bool removed = libraries_map.Remove(fake_library_url);
ASSERT(removed);
I->object_store()->set_libraries_map(libraries_map.Release());
return DartEntry::InvokeFunction(callee, arguments);
#endif
}
// Returns library with given url in current isolate, or NULL.
RawLibrary* Library::LookupLibrary(Thread* thread, const String& url) {
Zone* zone = thread->zone();
@ -15695,6 +15522,8 @@ RawObject* Instance::Evaluate(const Class& method_cls,
const String& expr,
const Array& param_names,
const Array& param_values) const {
const Function& eval_func = Function::Handle(
Function::EvaluateHelper(method_cls, expr, param_names, false));
const Array& args = Array::Handle(Array::New(1 + param_values.Length()));
PassiveObject& param = PassiveObject::Handle();
args.SetAt(0, *this);
@ -15702,18 +15531,7 @@ RawObject* Instance::Evaluate(const Class& method_cls,
param = param_values.At(i);
args.SetAt(i + 1, param);
}
const Library& library = Library::Handle(method_cls.library());
if (library.kernel_data() == TypedData::null()) {
const Function& eval_func = Function::Handle(
Function::EvaluateHelper(method_cls, expr, param_names, false));
return DartEntry::InvokeFunction(eval_func, args);
} else {
return EvaluateWithDFEHelper(
expr, param_names, Array::Handle(Array::New(0)),
String::Handle(Library::Handle(method_cls.library()).url()),
String::Handle(method_cls.UserVisibleName()), false, args);
}
return DartEntry::InvokeFunction(eval_func, args);
}
RawObject* Instance::HashCode() const {

View file

@ -2130,7 +2130,6 @@ class Function : public Object {
void ZeroEdgeCounters() const;
RawClass* Owner() const;
void set_owner(const Object& value) const;
RawClass* origin() const;
RawScript* script() const;
RawObject* RawOwner() const { return raw_ptr()->owner_; }
@ -2489,10 +2488,6 @@ class Function : public Object {
set_optimized_call_site_count(value);
}
void SetKernelDataAndScript(const Script& script,
const TypedData& data,
intptr_t offset);
intptr_t KernelDataProgramOffset() const;
RawTypedData* KernelData() const;
@ -2893,6 +2888,7 @@ class Function : public Object {
void set_name(const String& value) const;
void set_kind(RawFunction::Kind value) const;
void set_parent_function(const Function& value) const;
void set_owner(const Object& value) const;
RawFunction* implicit_closure_function() const;
void set_implicit_closure_function(const Function& value) const;
RawInstance* implicit_static_closure() const;

View file

@ -4495,7 +4495,6 @@ TEST_CASE(LinkedHashMap) {
LinkedHashMap& cc_map = LinkedHashMap::Handle(LinkedHashMap::NewDefault());
// 3. Expect them to have identical structure.
TransitionNativeToVM transition(thread);
CheckIdenticalHashStructure(dart_map, cc_map);
}

View file

@ -450,8 +450,7 @@ class ObjectPointerVisitor;
V(PrependTypeArguments, "_prependTypeArguments") \
V(DartDeveloperCausalAsyncStacks, "dart.developer.causal_async_stacks") \
V(_AsyncStarListenHelper, "_asyncStarListenHelper") \
V(GrowRegExpStack, "_growRegExpStack") \
V(DebugProcedureName, ":Eval")
V(GrowRegExpStack, "_growRegExpStack")
// Contains a list of frequently used strings in a canonicalized form. This
// list is kept in the vm_isolate in order to share the copy across isolates

View file

@ -267,13 +267,7 @@ char* TestCase::CompileTestScriptWithDFE(const char* url,
url, FLAG_strong ? platform_strong_dill : platform_dill,
FLAG_strong ? platform_strong_dill_size : platform_dill_size,
sourcefiles_count, sourcefiles, incrementally, NULL);
return ValidateCompilationResult(zone, compilation_result, kernel_pgm);
}
char* TestCase::ValidateCompilationResult(
Zone* zone,
Dart_KernelCompilationResult compilation_result,
void** kernel_pgm) {
if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
char* result =
OS::SCreate(zone, "Compilation failed %s", compilation_result.error);

View file

@ -379,10 +379,6 @@ class TestCase : TestCaseBase {
const char* name,
void* data = NULL);
static char* ValidateCompilationResult(Zone* zone,
Dart_KernelCompilationResult result,
void** kernel_pgm);
RunEntry* const run_;
};