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

Unified Diff: pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart

Issue 2746033006: dart2js: replace calls to codeUnitAt when index has favourable type (Closed)
Patch Set: dartfmt Created 3 years, 9 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 | « no previous file | sdk/lib/_internal/js_runtime/lib/js_string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
diff --git a/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart b/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
index b6514c4d1dd3ec5daf59c24cb9d814f21ff5c7d0..137411bcaf5527d639b46414fe7de923f14e20b8 100644
--- a/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
+++ b/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
@@ -41,6 +41,15 @@ class InvokeDynamicSpecializer {
instruction.setUseGvn();
}
+ Selector renameToOptimizedSelector(
+ String name, Selector selector, Compiler compiler) {
+ if (selector.name == name) return selector;
+ JavaScriptBackend backend = compiler.backend;
+ return new Selector.call(
+ new Name(name, backend.helpers.interceptorsLibrary),
+ new CallStructure(selector.argumentCount));
+ }
+
Operation operation(ConstantSystem constantSystem) => null;
static InvokeDynamicSpecializer lookupSpecializer(Selector selector) {
@@ -241,15 +250,6 @@ abstract class BinaryArithmeticSpecializer extends InvokeDynamicSpecializer {
HInstruction newBuiltinVariant(
HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld);
-
- Selector renameToOptimizedSelector(
- String name, Selector selector, Compiler compiler) {
- if (selector.name == name) return selector;
- JavaScriptBackend backend = compiler.backend;
- return new Selector.call(
- new Name(name, backend.helpers.interceptorsLibrary),
- new CallStructure(selector.argumentCount));
- }
}
class AddSpecializer extends BinaryArithmeticSpecializer {
@@ -553,7 +553,7 @@ abstract class BinaryBitOpSpecializer extends BinaryArithmeticSpecializer {
if (instruction is HBitAnd) {
return low == 0 &&
(argumentInRange(instruction.inputs[0], low, high) ||
- argumentInRange(instruction.inputs[1], low, high));
+ argumentInRange(instruction.inputs[1], low, high));
}
return false;
}
@@ -866,6 +866,10 @@ class CodeUnitAtSpecializer extends InvokeDynamicSpecializer {
// String.codeUnitAt does not have any side effect (other than throwing),
// and that it can be GVN'ed.
clearAllSideEffects(instruction);
+ if (instruction.inputs.last.isPositiveInteger(closedWorld)) {
+ instruction.selector = renameToOptimizedSelector(
+ '_codeUnitAt', instruction.selector, compiler);
+ }
}
return null;
}
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/js_string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698