Skip to content

Commit

Permalink
Turn the VM's dart:typed_data into a patch
Browse files Browse the repository at this point in the history
Before, the VM's dart:typed_data was a complete replacement of the SDK's
dart:typed_data implementation instead of a patch.  This is unlike all
the other SDK libraries.  This difference requires special-casing for
dart:typed_data in tools that handle the SDK libraries (e.g., the
Analyzer's patching support, the GN build).

This change makes dart:typed_data back into a patch to the SDK's
implementation.  It reintroduces a distinction between abstract
interface and concrete implementation classes, so there are more
classes.

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2571563005 .
  • Loading branch information
Kevin Millikin committed Dec 21, 2016
1 parent 889b003 commit a9b906d
Show file tree
Hide file tree
Showing 17 changed files with 955 additions and 2,049 deletions.
2,526 changes: 683 additions & 1,843 deletions runtime/lib/typed_data.dart → runtime/lib/typed_data_patch.dart

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions runtime/lib/typed_data_sources.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
{
'sources': [
'typed_data.cc',
'typed_data.dart',
'typed_data_patch.dart',
'simd128.cc',
],
}

56 changes: 28 additions & 28 deletions runtime/observatory/lib/src/service/object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2551,33 +2551,33 @@ M.InstanceKind stringToInstanceKind(String s) {
return M.InstanceKind.float64x2;
case 'Int32x4':
return M.InstanceKind.int32x4;
case 'Uint8ClampedList':
case '_Uint8ClampedList':
return M.InstanceKind.uint8ClampedList;
case 'Uint8List':
case '_Uint8List':
return M.InstanceKind.uint8List;
case 'Uint16List':
case '_Uint16List':
return M.InstanceKind.uint16List;
case 'Uint32List':
case '_Uint32List':
return M.InstanceKind.uint32List;
case 'Uint64List':
case '_Uint64List':
return M.InstanceKind.uint64List;
case 'Int8List':
case '_Int8List':
return M.InstanceKind.int8List;
case 'Int16List':
case '_Int16List':
return M.InstanceKind.int16List;
case 'Int32List':
case '_Int32List':
return M.InstanceKind.int32List;
case 'Int64List':
case '_Int64List':
return M.InstanceKind.int64List;
case 'Float32List':
case '_Float32List':
return M.InstanceKind.float32List;
case 'Float64List':
case '_Float64List':
return M.InstanceKind.float64List;
case 'Int32x4List':
case '_Int32x4List':
return M.InstanceKind.int32x4List;
case 'Float32x4List':
case '_Float32x4List':
return M.InstanceKind.float32x4List;
case 'Float64x2List':
case '_Float64x2List':
return M.InstanceKind.float64x2List;
case 'StackTrace':
return M.InstanceKind.stackTrace;
Expand Down Expand Up @@ -2791,46 +2791,46 @@ class Instance extends HeapObject implements M.Instance {
if (map['bytes'] != null) {
Uint8List bytes = BASE64.decode(map['bytes']);
switch (map['kind']) {
case "Uint8ClampedList":
case "_Uint8ClampedList":
typedElements = bytes.buffer.asUint8ClampedList();
break;
case "Uint8List":
case "_Uint8List":
typedElements = bytes.buffer.asUint8List();
break;
case "Uint16List":
case "_Uint16List":
typedElements = bytes.buffer.asUint16List();
break;
case "Uint32List":
case "_Uint32List":
typedElements = bytes.buffer.asUint32List();
break;
case "Uint64List":
case "_Uint64List":
typedElements = bytes.buffer.asUint64List();
break;
case "Int8List":
case "_Int8List":
typedElements = bytes.buffer.asInt8List();
break;
case "Int16List":
case "_Int16List":
typedElements = bytes.buffer.asInt16List();
break;
case "Int32List":
case "_Int32List":
typedElements = bytes.buffer.asInt32List();
break;
case "Int64List":
case "_Int64List":
typedElements = bytes.buffer.asInt64List();
break;
case "Float32List":
case "_Float32List":
typedElements = bytes.buffer.asFloat32List();
break;
case "Float64List":
case "_Float64List":
typedElements = bytes.buffer.asFloat64List();
break;
case "Int32x4List":
case "_Int32x4List":
typedElements = bytes.buffer.asInt32x4List();
break;
case "Float32x4List":
case "_Float32x4List":
typedElements = bytes.buffer.asFloat32x4List();
break;
case "Float64x2List":
case "_Float64x2List":
typedElements = bytes.buffer.asFloat64x2List();
break;
}
Expand Down
32 changes: 16 additions & 16 deletions runtime/observatory/tests/service/get_object_rpc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint8List'));
expect(result['kind'], equals('_Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint8List'));
expect(result['class']['name'], equals('_Uint8List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -462,12 +462,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint8List'));
expect(result['kind'], equals('_Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint8List'));
expect(result['class']['name'], equals('_Uint8List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -489,12 +489,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint8List'));
expect(result['kind'], equals('_Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint8List'));
expect(result['class']['name'], equals('_Uint8List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -516,12 +516,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint8List'));
expect(result['kind'], equals('_Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint8List'));
expect(result['class']['name'], equals('_Uint8List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -539,12 +539,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint64List'));
expect(result['kind'], equals('_Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint64List'));
expect(result['class']['name'], equals('_Uint64List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -565,12 +565,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint64List'));
expect(result['kind'], equals('_Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint64List'));
expect(result['class']['name'], equals('_Uint64List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -592,12 +592,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint64List'));
expect(result['kind'], equals('_Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint64List'));
expect(result['class']['name'], equals('_Uint64List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand All @@ -619,12 +619,12 @@ var tests = [
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
expect(result['kind'], equals('Uint64List'));
expect(result['kind'], equals('_Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
expect(result['class']['type'], equals('@Class'));
expect(result['class']['name'], equals('Uint64List'));
expect(result['class']['name'], equals('_Uint64List'));
expect(result['size'], isPositive);
expect(result['fields'], isEmpty);
expect(result['length'], equals(3));
Expand Down
7 changes: 4 additions & 3 deletions runtime/vm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,12 @@ generate_core_libraries("core_libraries") {
],
[
"typed_data",
processed_gypis.typed_data_sdk_sources,
"../../sdk/lib/typed_data",
"typed_data",
true,
processed_gypis.typed_data_runtime_sources,
"../lib",
"typed_data",
false,
],
[
"_vmservice",
Expand Down Expand Up @@ -428,7 +430,6 @@ template("generate_patched_sdk") {
# Files below are not patches, they will not be in [concatenation_files]
# but the `patch_sdk.dart` script will copy them into the patched sdk.
inputs += [
"../lib/typed_data.dart",
"../bin/builtin.dart",
"../bin/vmservice/vmservice_io.dart",
"../bin/vmservice/loader.dart",
Expand Down
1 change: 0 additions & 1 deletion runtime/vm/bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ enum {


const char** Bootstrap::profiler_patch_paths_ = NULL;
const char** Bootstrap::typed_data_patch_paths_ = NULL;


#define MAKE_PROPERTIES(CamelName, name) \
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class Bootstrap : public AllStatic {
static const char* isolate_patch_paths_[];
static const char* math_patch_paths_[];
static const char* mirrors_patch_paths_[];
static const char* typed_data_patch_paths_[];
static const char* _vmservice_patch_paths_[];

// NULL patch paths for libraries that do not have patch files.
static const char** profiler_patch_paths_;
static const char** typed_data_patch_paths_;
};

} // namespace dart
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/dart_api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3539,8 +3539,8 @@ DART_EXPORT Dart_Handle Dart_NewByteBuffer(Dart_Handle typed_data) {
RETURN_TYPE_ERROR(Z, typed_data, 'TypedData');
}
Object& result = Object::Handle(Z);
result = GetByteBufferConstructor(T, Symbols::ByteBuffer(),
Symbols::ByteBufferDot_New(), 1);
result = GetByteBufferConstructor(T, Symbols::_ByteBuffer(),
Symbols::_ByteBufferDot_New(), 1);
ASSERT(!result.IsNull());
ASSERT(result.IsFunction());
const Function& factory = Function::Cast(result);
Expand Down
11 changes: 5 additions & 6 deletions runtime/vm/flow_graph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ uword FlowGraphBuilder::FindDoubleConstant(double value) {
}


#define RECOGNIZE_FACTORY(test_factory_symbol, cid, fp) \
{Symbols::k##test_factory_symbol##Id, cid, fp, \
#test_factory_symbol ", " #cid}, // NOLINT
#define RECOGNIZE_FACTORY(symbol, class_name, constructor_name, cid, fp) \
{Symbols::k##symbol##Id, cid, fp, #symbol ", " #cid}, // NOLINT

static struct {
intptr_t symbold_id;
intptr_t symbol_id;
intptr_t cid;
intptr_t finger_print;
const char* name;
Expand All @@ -98,10 +97,10 @@ intptr_t FactoryRecognizer::ResultCid(const Function& factory) {
(lib.raw() == Library::TypedDataLibrary()));
const String& factory_name = String::Handle(factory.name());
for (intptr_t i = 0;
factory_recognizer_list[i].symbold_id != Symbols::kIllegal; i++) {
factory_recognizer_list[i].symbol_id != Symbols::kIllegal; i++) {
if (String::EqualsIgnoringPrivateKey(
factory_name,
Symbols::Symbol(factory_recognizer_list[i].symbold_id))) {
Symbols::Symbol(factory_recognizer_list[i].symbol_id))) {
return factory_recognizer_list[i].cid;
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/gypi_contents.gni
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ _core_library_gypis = [
"../../sdk/lib/math/math_sources.gypi",
"../../sdk/lib/mirrors/mirrors_sources.gypi",
"../../sdk/lib/profiler/profiler_sources.gypi",
"../../sdk/lib/typed_data/typed_data_sources.gypi",
"../../sdk/lib/vmservice/vmservice_sources.gypi",
"../bin/io_sources.gypi",
]
Expand Down
Loading

0 comments on commit a9b906d

Please sign in to comment.