Skip to content

Commit 91c2c35

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm, bytecode] Plumb bytecode mode flags to VM unit tests.
- Make tests using eval fail instead of timing out. - Collect allocation stats in the interpreter. - And various EnsureDeclarationLoaded. Change-Id: I17377216cd6dde2615b205f1b28071e12e50e252 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107442 Reviewed-by: Alexander Markov <[email protected]> Reviewed-by: Régis Crelier <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent a68877f commit 91c2c35

11 files changed

Lines changed: 38 additions & 6 deletions

File tree

pkg/test_runner/lib/src/test_suite.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ class VMTestSuite extends TestSuite {
370370
var dfePath = Path(filename).absolute.toNativePath();
371371
// '--dfe' has to be the first argument for run_vm_test to pick it up.
372372
args.insert(0, '--dfe=$dfePath');
373+
args.addAll(configuration.vmOptions);
373374
}
374375
if (expectations.contains(Expectation.crash)) {
375376
args.insert(0, '--suppress-core-dump');

pkg/vm/bin/kernel_service.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,12 @@ Future _processLoadRequest(request) async {
534534
assert(incremental,
535535
"Incremental compiler required for use of 'kUpdateSourcesTag'");
536536
compiler = lookupIncrementalCompiler(isolateId);
537-
assert(compiler != null);
537+
if (compiler == null) {
538+
port.send(new CompilationResult.errors(
539+
["No incremental compiler available for this isolate."], null)
540+
.toResponse());
541+
return;
542+
}
538543
updateSources(compiler, sourceFiles);
539544
port.send(new CompilationResult.ok(null).toResponse());
540545
return;

runtime/tests/vm/vm.status

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dart/snapshot_version_test: RuntimeError
3535
dart/entrypoints/aot/*: SkipByDesign
3636

3737
[ $compiler == dartkb ]
38-
cc/*: Skip # Bytecode modes are not properly hooked up in run_vm_tests.
38+
cc/*: Skip # Too many timeouts and crashes for infrastructure to handle.
3939

4040
[ $compiler == dartkp ]
4141
dart/v8_snapshot_profile_writer_test: Pass, Slow # Can be slow due to re-invoking the precompiler.

runtime/vm/compiler/backend/il_test_helper.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ RawFunction* GetFunction(const Library& lib, const char* name) {
4545
}
4646

4747
void Invoke(const Library& lib, const char* name) {
48+
// These tests rely on running unoptimized code to collect type feedback. The
49+
// interpreter does not collect type feedback for interface calls.
50+
SetFlagScope<bool> sfs(&FLAG_enable_interpreter, false);
51+
4852
Thread* thread = Thread::Current();
4953
Dart_Handle api_lib = Api::NewHandle(thread, lib.raw());
5054
TransitionVMToNative transition(thread);

runtime/vm/compiler/backend/loops_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ ISOLATE_UNIT_TEST_CASE(WrapAroundAndDerived) {
307307
" WRAP(-99, LIN(0 + -1 * i))\n" // d
308308
" LIN(1 + 1 * i)\n" // add
309309
" ]\n";
310-
EXPECT_STREQ(ComputeInduction(thread, script_chars), expected);
310+
EXPECT_STREQ(expected, ComputeInduction(thread, script_chars));
311311
}
312312

313313
ISOLATE_UNIT_TEST_CASE(PeriodicAndDerived) {
@@ -342,7 +342,7 @@ ISOLATE_UNIT_TEST_CASE(PeriodicAndDerived) {
342342
" PERIOD(95, 5)\n" // p2
343343
" LIN(1 + 1 * i)\n" // add
344344
" ]\n";
345-
EXPECT_STREQ(ComputeInduction(thread, script_chars), expected);
345+
EXPECT_STREQ(expected, ComputeInduction(thread, script_chars));
346346
}
347347

348348
//

runtime/vm/dart_api_impl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5106,6 +5106,7 @@ DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library,
51065106
return Api::NewError("Class '%s' not found in library '%s'.",
51075107
cls_name.ToCString(), lib_name.ToCString());
51085108
}
5109+
cls.EnsureDeclarationLoaded();
51095110
CHECK_ERROR_HANDLE(cls.VerifyEntryPoint());
51105111
return Api::NewHandle(T, cls.RareType());
51115112
}

runtime/vm/interpreter.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,8 @@ DART_NOINLINE bool Interpreter::AllocateMint(Thread* thread,
13551355
const uword start = thread->top();
13561356
if (LIKELY((start + instance_size) < thread->end())) {
13571357
thread->set_top(start + instance_size);
1358+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1359+
kMintCid, instance_size));
13581360
RawMint* result =
13591361
Mint::RawCast(InitializeHeader(start, kMintCid, instance_size));
13601362
result->ptr()->value_ = value;
@@ -1385,6 +1387,8 @@ DART_NOINLINE bool Interpreter::AllocateDouble(Thread* thread,
13851387
const uword start = thread->top();
13861388
if (LIKELY((start + instance_size) < thread->end())) {
13871389
thread->set_top(start + instance_size);
1390+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1391+
kDoubleCid, instance_size));
13881392
RawDouble* result =
13891393
Double::RawCast(InitializeHeader(start, kDoubleCid, instance_size));
13901394
result->ptr()->value_ = value;
@@ -1415,6 +1419,8 @@ DART_NOINLINE bool Interpreter::AllocateFloat32x4(Thread* thread,
14151419
const uword start = thread->top();
14161420
if (LIKELY((start + instance_size) < thread->end())) {
14171421
thread->set_top(start + instance_size);
1422+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1423+
kFloat32x4Cid, instance_size));
14181424
RawFloat32x4* result = Float32x4::RawCast(
14191425
InitializeHeader(start, kFloat32x4Cid, instance_size));
14201426
value.writeTo(result->ptr()->value_);
@@ -1445,6 +1451,8 @@ DART_NOINLINE bool Interpreter::AllocateFloat64x2(Thread* thread,
14451451
const uword start = thread->top();
14461452
if (LIKELY((start + instance_size) < thread->end())) {
14471453
thread->set_top(start + instance_size);
1454+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1455+
kFloat64x2Cid, instance_size));
14481456
RawFloat64x2* result = Float64x2::RawCast(
14491457
InitializeHeader(start, kFloat64x2Cid, instance_size));
14501458
value.writeTo(result->ptr()->value_);
@@ -1479,6 +1487,8 @@ bool Interpreter::AllocateArray(Thread* thread,
14791487
const uword start = thread->top();
14801488
if (LIKELY((start + instance_size) < thread->end())) {
14811489
thread->set_top(start + instance_size);
1490+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1491+
kArrayCid, instance_size));
14821492
RawArray* result =
14831493
Array::RawCast(InitializeHeader(start, kArrayCid, instance_size));
14841494
result->ptr()->type_arguments_ = type_args;
@@ -1512,6 +1522,8 @@ bool Interpreter::AllocateContext(Thread* thread,
15121522
const uword start = thread->top();
15131523
if (LIKELY((start + instance_size) < thread->end())) {
15141524
thread->set_top(start + instance_size);
1525+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1526+
kContextCid, instance_size));
15151527
RawContext* result =
15161528
Context::RawCast(InitializeHeader(start, kContextCid, instance_size));
15171529
result->ptr()->num_variables_ = num_context_variables;
@@ -1542,6 +1554,8 @@ bool Interpreter::AllocateClosure(Thread* thread,
15421554
const uword start = thread->top();
15431555
if (LIKELY((start + instance_size) < thread->end())) {
15441556
thread->set_top(start + instance_size);
1557+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
1558+
kClosureCid, instance_size));
15451559
RawClosure* result =
15461560
Closure::RawCast(InitializeHeader(start, kClosureCid, instance_size));
15471561
RawObject* null_value = Object::null();
@@ -2481,6 +2495,8 @@ RawObject* Interpreter::Call(RawFunction* function,
24812495
const uword start = thread->top();
24822496
if (LIKELY((start + instance_size) < thread->end())) {
24832497
thread->set_top(start + instance_size);
2498+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
2499+
class_id, instance_size));
24842500
RawObject* result = InitializeHeader(start, class_id, instance_size);
24852501
for (intptr_t offset = sizeof(RawInstance); offset < instance_size;
24862502
offset += kWordSize) {
@@ -2512,6 +2528,8 @@ RawObject* Interpreter::Call(RawFunction* function,
25122528
const uword start = thread->top();
25132529
if (LIKELY((start + instance_size) < thread->end())) {
25142530
thread->set_top(start + instance_size);
2531+
NOT_IN_PRODUCT(thread->isolate()->class_table()->UpdateAllocatedNew(
2532+
class_id, instance_size));
25152533
RawObject* result = InitializeHeader(start, class_id, instance_size);
25162534
for (intptr_t offset = sizeof(RawInstance); offset < instance_size;
25172535
offset += kWordSize) {

runtime/vm/object.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,7 @@ bool Class::IsInFullSnapshot() const {
22762276
}
22772277

22782278
RawAbstractType* Class::RareType() const {
2279+
ASSERT(is_declaration_loaded());
22792280
const Type& type = Type::Handle(Type::New(
22802281
*this, Object::null_type_arguments(), TokenPosition::kNoSource));
22812282
return ClassFinalizer::FinalizeType(*this, type);
@@ -4152,6 +4153,7 @@ void Class::set_declaration_type(const Type& value) const {
41524153
}
41534154

41544155
RawType* Class::DeclarationType() const {
4156+
ASSERT(is_declaration_loaded());
41554157
if (declaration_type() != Type::null()) {
41564158
return declaration_type();
41574159
}

runtime/vm/source_report.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) {
569569
}
570570
ASSERT(cls.is_finalized());
571571
} else {
572+
cls.EnsureDeclarationLoaded();
572573
// Emit one range for the whole uncompiled class.
573574
JSONObject range(jsarr);
574575
script = cls.script();

runtime/vm/stack_frame_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void FUNCTION_NAME(StackFrame_equals)(Dart_NativeArguments args) {
4848
if (!expected.OperatorEquals(actual)) {
4949
OS::PrintErr("expected: '%s' actual: '%s'\n", expected.ToCString(),
5050
actual.ToCString());
51-
FATAL("Expect_equals fails.\n");
51+
EXPECT(false);
5252
}
5353
}
5454

0 commit comments

Comments
 (0)