Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2425)

Unified Diff: runtime/vm/kernel_to_il.cc

Issue 2931773005: [kernel] Delete most of the AST (Closed)
Patch Set: Review Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_to_il.cc
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index dbdc84646d694079295e28969e23839f445fdffc..fb9a6aee1e9a32c861a26361141445e4692612a7 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -383,11 +383,6 @@ const dart::String& TranslationHelper::DartSetterName(NameIndex setter) {
}
-const dart::String& TranslationHelper::DartSetterName(Name* setter_name) {
- return DartSetterName(setter_name->library(), setter_name->string_index());
-}
-
-
const dart::String& TranslationHelper::DartSetterName(NameIndex parent,
StringIndex setter) {
// The names flowing into [setter] are coming from the Kernel file:
@@ -422,11 +417,6 @@ const dart::String& TranslationHelper::DartGetterName(NameIndex getter) {
}
-const dart::String& TranslationHelper::DartGetterName(Name* getter_name) {
- return DartGetterName(getter_name->library(), getter_name->string_index());
-}
-
-
const dart::String& TranslationHelper::DartGetterName(NameIndex parent,
StringIndex getter) {
dart::String& name = DartString(getter);
@@ -436,12 +426,6 @@ const dart::String& TranslationHelper::DartGetterName(NameIndex parent,
}
-const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) {
- dart::String& name = DartString(kernel_name->string_index());
- return ManglePrivateName(kernel_name->library(), &name);
-}
-
-
const dart::String& TranslationHelper::DartFieldName(NameIndex parent,
StringIndex field) {
dart::String& name = DartString(field);
@@ -449,26 +433,12 @@ const dart::String& TranslationHelper::DartFieldName(NameIndex parent,
}
-const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) {
- // The [DartFieldName] will take care of mangling the name.
- dart::String& name =
- dart::String::Handle(Z, DartFieldName(kernel_name).raw());
- name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name);
- return name;
-}
-
-
const dart::String& TranslationHelper::DartMethodName(NameIndex method) {
return DartMethodName(CanonicalNameParent(method),
CanonicalNameString(method));
}
-const dart::String& TranslationHelper::DartMethodName(Name* method_name) {
- return DartMethodName(method_name->library(), method_name->string_index());
-}
-
-
const dart::String& TranslationHelper::DartMethodName(NameIndex parent,
StringIndex method) {
dart::String& name = DartString(method);
@@ -646,18 +616,6 @@ dart::String& TranslationHelper::ManglePrivateName(NameIndex parent,
}
-const Array& TranslationHelper::ArgumentNames(List<NamedExpression>* named) {
- if (named->length() == 0) return Array::ZoneHandle(Z);
-
- const Array& names =
- Array::ZoneHandle(Z, Array::New(named->length(), Heap::kOld));
- for (intptr_t i = 0; i < named->length(); ++i) {
- names.SetAt(i, DartSymbol((*named)[i]->name()));
- }
- return names;
-}
-
-
FlowGraphBuilder::FlowGraphBuilder(
intptr_t kernel_offset,
ParsedFunction* parsed_function,
@@ -1155,9 +1113,9 @@ Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
const dart::String& name,
Token::Kind kind,
intptr_t argument_count,
- intptr_t num_args_checked) {
+ intptr_t checked_argument_count) {
return InstanceCall(position, name, kind, argument_count, Array::null_array(),
- num_args_checked);
+ checked_argument_count);
}
@@ -1166,12 +1124,12 @@ Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
Token::Kind kind,
intptr_t argument_count,
const Array& argument_names,
- intptr_t num_args_checked) {
+ intptr_t checked_argument_count) {
ArgumentArray arguments = GetArguments(argument_count);
const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported.
InstanceCallInstr* call = new (Z) InstanceCallInstr(
position, name, kind, arguments, kTypeArgsLen, argument_names,
- num_args_checked, ic_data_array_, GetNextDeoptId());
+ checked_argument_count, ic_data_array_, GetNextDeoptId());
Push(call);
return Fragment(call);
}
@@ -1670,13 +1628,6 @@ intptr_t FlowGraphBuilder::CurrentTryIndex() {
}
-LocalVariable* FlowGraphBuilder::LookupVariable(VariableDeclaration* var) {
- LocalVariable* local = scopes_->locals.Lookup(var->kernel_offset_no_tag());
- ASSERT(local != NULL);
- return local;
-}
-
-
dart::LocalVariable* FlowGraphBuilder::LookupVariable(intptr_t kernel_offset) {
LocalVariable* local = scopes_->locals.Lookup(kernel_offset);
ASSERT(local != NULL);
@@ -2446,6 +2397,96 @@ RawObject* BuildParameterDescriptor(const Function& function) {
}
}
+static int LowestFirst(const intptr_t* a, const intptr_t* b) {
+ return *a - *b;
+}
+
+/**
+ * If index exists as sublist in list, sort the sublist from lowest to highest,
+ * then copy it, as Smis and without duplicates,
+ * to a new Array in Heap::kOld which is returned.
+ * Note that the source list is both sorted and de-duplicated as well, but will
+ * possibly contain duplicate and unsorted data at the end.
+ * Otherwise (when sublist doesn't exist in list) return new empty array.
+ */
+static RawArray* AsSortedDuplicateFreeArray(GrowableArray<intptr_t>* source) {
+ intptr_t size = source->length();
+ if (size == 0) {
+ return Array::New(0);
+ }
+
+ source->Sort(LowestFirst);
+
+ intptr_t last = 0;
+ for (intptr_t current = 1; current < size; ++current) {
+ if (source->At(last) != source->At(current)) {
+ (*source)[++last] = source->At(current);
+ }
+ }
+ Array& array_object = Array::Handle();
+ array_object = Array::New(last + 1, Heap::kOld);
+ Smi& smi_value = Smi::Handle();
+ for (intptr_t i = 0; i <= last; ++i) {
+ smi_value = Smi::New(source->At(i));
+ array_object.SetAt(i, smi_value);
+ }
+ return array_object.raw();
+}
+
+void CollectTokenPositionsFor(const Script& const_script) {
+ Thread* thread = Thread::Current();
+ Zone* zone_ = thread->zone();
+ Script& script = Script::Handle(Z, const_script.raw());
+ TranslationHelper helper(thread);
+ helper.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
+ helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
+ helper.SetCanonicalNames(
+ TypedData::Handle(Z, script.kernel_canonical_names()));
+
+ GrowableArray<intptr_t> token_positions(10);
+ GrowableArray<intptr_t> yield_positions(1);
+ StreamingFlowGraphBuilder streaming_flow_graph_builder(
+ &helper, zone_, script.kernel_data(), script.kernel_data_size());
+ streaming_flow_graph_builder.CollectTokenPositionsFor(
+ script.kernel_script_index(), &token_positions, &yield_positions);
+ Array& array_object = Array::Handle(Z);
+ array_object = AsSortedDuplicateFreeArray(&token_positions);
+ script.set_debug_positions(array_object);
+ array_object = AsSortedDuplicateFreeArray(&yield_positions);
+ script.set_yield_positions(array_object);
+}
+
+String& GetSourceFor(const Script& const_script) {
+ Thread* thread = Thread::Current();
+ Zone* zone_ = thread->zone();
+ Script& script = Script::Handle(Z, const_script.raw());
+ TranslationHelper helper(thread);
+ helper.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
+ helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
+ helper.SetCanonicalNames(
+ TypedData::Handle(Z, script.kernel_canonical_names()));
+
+ StreamingFlowGraphBuilder streaming_flow_graph_builder(
+ &helper, zone_, script.kernel_data(), script.kernel_data_size());
+ return streaming_flow_graph_builder.GetSourceFor(
+ script.kernel_script_index());
+}
+
+Array& GetLineStartsFor(const Script& const_script) {
+ Thread* thread = Thread::Current();
+ Zone* zone_ = thread->zone();
+ Script& script = Script::Handle(Z, const_script.raw());
+ TranslationHelper helper(thread);
+ helper.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
+ helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
+ helper.SetCanonicalNames(
+ TypedData::Handle(Z, script.kernel_canonical_names()));
+
+ StreamingFlowGraphBuilder streaming_flow_graph_builder(
+ &helper, zone_, script.kernel_data(), script.kernel_data_size());
+ return streaming_flow_graph_builder.GetLineStartsFor(
+ script.kernel_script_index());
+}
} // namespace kernel
} // namespace dart
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698