dart-sdk/runtime/lib/weak_property.cc
Ryan Macnak 28fe36c637 [vm, compiler] Recognize WeakProperty's accessors.
The layout of WeakProperty is defined in C++ instead of Dart. Add missing recognition of its accessors so the compiler can use direct field access instead of always going through natives. Compare LinkedHashMap.

Change the sentinel for WeakProperty lists to object null so that no special constructor is needed.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/44333
Change-Id: I8686383053c2c345c972b6615b514a1381e79fda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175001
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-12-04 22:25:12 +00:00

42 lines
1.4 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/bootstrap_natives.h"
#include "vm/exceptions.h"
#include "vm/native_entry.h"
#include "vm/object.h"
namespace dart {
DEFINE_NATIVE_ENTRY(WeakProperty_getKey, 0, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(WeakProperty, weak_property,
arguments->NativeArgAt(0));
return weak_property.key();
}
DEFINE_NATIVE_ENTRY(WeakProperty_setKey, 0, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(WeakProperty, weak_property,
arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
weak_property.set_key(key);
return Object::null();
}
DEFINE_NATIVE_ENTRY(WeakProperty_getValue, 0, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(WeakProperty, weak_property,
arguments->NativeArgAt(0));
return weak_property.value();
}
DEFINE_NATIVE_ENTRY(WeakProperty_setValue, 0, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(WeakProperty, weak_property,
arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(1));
weak_property.set_value(value);
return Object::null();
}
} // namespace dart