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

Side by Side Diff: runtime/vm/kernel_to_il.cc

Issue 3001883002: [vm] Read interface_target_reference from kernel binaries (Closed)
Patch Set: Add assertion Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 6
7 #include "vm/kernel_to_il.h" 7 #include "vm/kernel_to_il.h"
8 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/intermediate_language.h" 10 #include "vm/intermediate_language.h"
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 } 1052 }
1053 1053
1054 Fragment FlowGraphBuilder::IntConstant(int64_t value) { 1054 Fragment FlowGraphBuilder::IntConstant(int64_t value) {
1055 return Fragment( 1055 return Fragment(
1056 Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld)))); 1056 Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))));
1057 } 1057 }
1058 1058
1059 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position, 1059 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
1060 const dart::String& name, 1060 const dart::String& name,
1061 Token::Kind kind, 1061 Token::Kind kind,
1062 intptr_t argument_count,
1063 intptr_t checked_argument_count) {
1064 const intptr_t kTypeArgsLen = 0;
1065 return InstanceCall(position, name, kind, kTypeArgsLen, argument_count,
1066 Array::null_array(), checked_argument_count);
1067 }
1068
1069 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
1070 const dart::String& name,
1071 Token::Kind kind,
1072 intptr_t type_args_len, 1062 intptr_t type_args_len,
1073 intptr_t argument_count, 1063 intptr_t argument_count,
1074 const Array& argument_names, 1064 const Array& argument_names,
1075 intptr_t checked_argument_count) { 1065 intptr_t checked_argument_count,
1066 const Function& interface_target) {
1076 const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0); 1067 const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0);
1077 ArgumentArray arguments = GetArguments(total_count); 1068 ArgumentArray arguments = GetArguments(total_count);
1078 InstanceCallInstr* call = new (Z) InstanceCallInstr( 1069 InstanceCallInstr* call = new (Z)
1079 position, name, kind, arguments, type_args_len, argument_names, 1070 InstanceCallInstr(position, name, kind, arguments, type_args_len,
1080 checked_argument_count, ic_data_array_, GetNextDeoptId()); 1071 argument_names, checked_argument_count, ic_data_array_,
1072 GetNextDeoptId(), interface_target);
1081 Push(call); 1073 Push(call);
1082 return Fragment(call); 1074 return Fragment(call);
1083 } 1075 }
1084 1076
1085 Fragment FlowGraphBuilder::ClosureCall(intptr_t type_args_len, 1077 Fragment FlowGraphBuilder::ClosureCall(intptr_t type_args_len,
1086 intptr_t argument_count, 1078 intptr_t argument_count,
1087 const Array& argument_names) { 1079 const Array& argument_names) {
1088 Value* function = Pop(); 1080 Value* function = Pop();
1089 const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0); 1081 const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0);
1090 ArgumentArray arguments = GetArguments(total_count); 1082 ArgumentArray arguments = GetArguments(total_count);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 } 1496 }
1505 1497
1506 RawFunction* FlowGraphBuilder::LookupMethodByMember( 1498 RawFunction* FlowGraphBuilder::LookupMethodByMember(
1507 NameIndex target, 1499 NameIndex target,
1508 const dart::String& method_name) { 1500 const dart::String& method_name) {
1509 NameIndex kernel_class = H.EnclosingName(target); 1501 NameIndex kernel_class = H.EnclosingName(target);
1510 dart::Class& klass = 1502 dart::Class& klass =
1511 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class)); 1503 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class));
1512 1504
1513 RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); 1505 RawFunction* function = klass.LookupFunctionAllowPrivate(method_name);
1506 #ifdef DEBUG
1507 if (function == Object::null()) {
1508 OS::PrintErr("Unable to find \'%s\' in %s\n", method_name.ToCString(),
1509 klass.ToCString());
1510 }
1511 #endif
1514 ASSERT(function != Object::null()); 1512 ASSERT(function != Object::null());
1515 return function; 1513 return function;
1516 } 1514 }
1517 1515
1518 LocalVariable* FlowGraphBuilder::MakeTemporary() { 1516 LocalVariable* FlowGraphBuilder::MakeTemporary() {
1519 char name[64]; 1517 char name[64];
1520 intptr_t index = stack_->definition()->temp_index(); 1518 intptr_t index = stack_->definition()->temp_index();
1521 OS::SNPrint(name, 64, ":temp%" Pd, index); 1519 OS::SNPrint(name, 64, ":temp%" Pd, index);
1522 LocalVariable* variable = 1520 LocalVariable* variable =
1523 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, 1521 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 LocalVariable* closure = NULL; 2163 LocalVariable* closure = NULL;
2166 if (is_closure_call) { 2164 if (is_closure_call) {
2167 closure = scope->VariableAt(0); 2165 closure = scope->VariableAt(0);
2168 2166
2169 // The closure itself is the first argument. 2167 // The closure itself is the first argument.
2170 body += LoadLocal(closure); 2168 body += LoadLocal(closure);
2171 } else { 2169 } else {
2172 // Invoke the getter to get the field value. 2170 // Invoke the getter to get the field value.
2173 body += LoadLocal(scope->VariableAt(0)); 2171 body += LoadLocal(scope->VariableAt(0));
2174 body += PushArgument(); 2172 body += PushArgument();
2175 body += 2173 const intptr_t kTypeArgsLen = 0;
2176 InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET, 1); 2174 const intptr_t kNumArgsChecked = 1;
2175 body += InstanceCall(TokenPosition::kMinSource, getter_name, Token::kGET,
2176 kTypeArgsLen, 1, Array::null_array(), kNumArgsChecked,
2177 Function::null_function());
2177 } 2178 }
2178 2179
2179 body += PushArgument(); 2180 body += PushArgument();
2180 2181
2181 // Push all arguments onto the stack. 2182 // Push all arguments onto the stack.
2182 intptr_t pos = 1; 2183 intptr_t pos = 1;
2183 for (; pos < descriptor.Count(); pos++) { 2184 for (; pos < descriptor.Count(); pos++) {
2184 body += LoadLocal(scope->VariableAt(pos)); 2185 body += LoadLocal(scope->VariableAt(pos));
2185 body += PushArgument(); 2186 body += PushArgument();
2186 } 2187 }
2187 2188
2188 if (is_closure_call) { 2189 if (is_closure_call) {
2189 // Lookup the function in the closure. 2190 // Lookup the function in the closure.
2190 body += LoadLocal(closure); 2191 body += LoadLocal(closure);
2191 body += LoadField(Closure::function_offset()); 2192 body += LoadField(Closure::function_offset());
2192 2193
2193 body += ClosureCall(descriptor.TypeArgsLen(), descriptor.Count(), 2194 body += ClosureCall(descriptor.TypeArgsLen(), descriptor.Count(),
2194 argument_names); 2195 argument_names);
2195 } else { 2196 } else {
2197 const intptr_t kNumArgsChecked = 1;
2196 body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(), 2198 body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(),
2197 Token::kILLEGAL, descriptor.TypeArgsLen(), 2199 Token::kILLEGAL, descriptor.TypeArgsLen(),
2198 descriptor.Count(), argument_names); 2200 descriptor.Count(), argument_names, kNumArgsChecked,
2201 Function::null_function());
2199 } 2202 }
2200 2203
2201 body += Return(TokenPosition::kNoSource); 2204 body += Return(TokenPosition::kNoSource);
2202 2205
2203 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); 2206 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1);
2204 } 2207 }
2205 2208
2206 TargetEntryInstr* FlowGraphBuilder::BuildTargetEntry() { 2209 TargetEntryInstr* FlowGraphBuilder::BuildTargetEntry() {
2207 return new (Z) 2210 return new (Z)
2208 TargetEntryInstr(AllocateBlockId(), CurrentTryIndex(), GetNextDeoptId()); 2211 TargetEntryInstr(AllocateBlockId(), CurrentTryIndex(), GetNextDeoptId());
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 array_object = AsSortedDuplicateFreeArray(&token_positions); 2418 array_object = AsSortedDuplicateFreeArray(&token_positions);
2416 script.set_debug_positions(array_object); 2419 script.set_debug_positions(array_object);
2417 array_object = AsSortedDuplicateFreeArray(&yield_positions); 2420 array_object = AsSortedDuplicateFreeArray(&yield_positions);
2418 script.set_yield_positions(array_object); 2421 script.set_yield_positions(array_object);
2419 } 2422 }
2420 2423
2421 } // namespace kernel 2424 } // namespace kernel
2422 } // namespace dart 2425 } // namespace dart
2423 2426
2424 #endif // !defined(DART_PRECOMPILED_RUNTIME) 2427 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« 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