[vm] Remove Dart_CreateNativeWrapperClass API.

This API does not work in CFE world because CFE does not see classes
created dynamically.

Fix UseDartAPI benchmark that was using this API and was broken as a result.

Change-Id: If691373d32ac5b8ff23e350ce2eb5ed44045b1f1
Reviewed-on: https://dart-review.googlesource.com/c/87183
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Vyacheslav Egorov 2018-12-14 15:25:53 +00:00 committed by commit-bot@chromium.org
parent 6376482e20
commit 2e3788898a
4 changed files with 4 additions and 52 deletions

View file

@ -2458,15 +2458,6 @@ DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
* ===========================
*/
/**
* Creates a native wrapper class.
*
* TODO(turnidge): Document.
*/
DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
Dart_Handle class_name,
int field_count);
/**
* Gets the number of native instance fields in an object.
*/

View file

@ -182,7 +182,6 @@ cc/SourceReport_Coverage_UnusedClass_ForceCompileError: Crash
cc/SourceReport_Coverage_UnusedClass_NoForceCompile: Fail
cc/SourceReport_MultipleReports: Fail
cc/SourceReport_PossibleBreakpoints_Simple: Fail
cc/UseDartApi: Fail
dart/data_uri_import_test/utf16: MissingRuntimeError
dart/spawn_shutdown_test: SkipSlow

View file

@ -240,7 +240,6 @@ BENCHMARK(CorelibIsolateStartup) {
// Measure invocation of Dart API functions.
//
static void InitNativeFields(Dart_NativeArguments args) {
Dart_EnterScope();
int count = Dart_GetNativeArgumentCount(args);
EXPECT_EQ(1, count);
@ -248,8 +247,6 @@ static void InitNativeFields(Dart_NativeArguments args) {
EXPECT_VALID(recv);
Dart_Handle result = Dart_SetNativeInstanceField(recv, 0, 7);
EXPECT_VALID(result);
Dart_ExitScope();
}
// The specific api functions called here are a bit arbitrary. We are
@ -300,7 +297,8 @@ static Dart_NativeFunction bm_uda_lookup(Dart_Handle name,
BENCHMARK(UseDartApi) {
const int kNumIterations = 1000000;
const char* kScriptChars =
"class Class extends NativeFieldsWrapper{\n"
"import 'dart:nativewrappers';\n"
"class Class extends NativeFieldWrapperClass1 {\n"
" int init() native 'init';\n"
" int method(int param1, int param2) native 'method';\n"
"}\n"
@ -316,12 +314,7 @@ BENCHMARK(UseDartApi) {
Dart_Handle lib = TestCase::LoadTestScript(
kScriptChars, reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup),
USER_TEST_URI, false);
// Create a native wrapper class with native fields.
Dart_Handle result =
Dart_CreateNativeWrapperClass(lib, NewString("NativeFieldsWrapper"), 1);
EXPECT_VALID(result);
result = Dart_FinalizeLoading(false);
Dart_Handle result = Dart_FinalizeLoading(false);
EXPECT_VALID(result);
Dart_Handle args[1];

View file

@ -4401,38 +4401,6 @@ DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
// --- Native fields and functions ---
DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
Dart_Handle name,
int field_count) {
#if defined(DART_PRECOMPILED_RUNTIME)
return Api::NewError("%s: Cannot compile on an AOT runtime.", CURRENT_FUNC);
#else
DARTSCOPE(Thread::Current());
const String& cls_name = Api::UnwrapStringHandle(Z, name);
if (cls_name.IsNull()) {
RETURN_TYPE_ERROR(Z, name, String);
}
const Library& lib = Api::UnwrapLibraryHandle(Z, library);
if (lib.IsNull()) {
RETURN_TYPE_ERROR(Z, library, Library);
}
if (!Utils::IsUint(16, field_count)) {
return Api::NewError(
"Invalid field_count passed to Dart_CreateNativeWrapperClass");
}
CHECK_CALLBACK_STATE(T);
String& cls_symbol = String::Handle(Z, Symbols::New(T, cls_name));
const Class& cls =
Class::Handle(Z, Class::NewNativeWrapper(lib, cls_symbol, field_count));
if (cls.IsNull()) {
return Api::NewError(
"Unable to create native wrapper class : already exists");
}
return Api::NewHandle(T, cls.RareType());
#endif // defined(DART_PRECOMPILED_RUNTIME)
}
DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj,
int* count) {
Thread* thread = Thread::Current();
@ -4659,6 +4627,7 @@ Dart_GetNativeFieldsOfArgument(Dart_NativeArguments args,
DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args,
intptr_t* value) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
TransitionNativeToVM transition(arguments->thread());
ASSERT(arguments->thread()->isolate() == Isolate::Current());
if (value == NULL) {
RETURN_NULL_ERROR(value);