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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11628011: Inline ByteArrayBase.length in the flow graph optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/flow_graph_optimizer.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 16262)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -974,7 +974,8 @@
}
-void FlowGraphOptimizer::InlineGArrayCapacityGetter(InstanceCallInstr* call) {
+void FlowGraphOptimizer::InlineGrowableArrayCapacityGetter(
+ InstanceCallInstr* call) {
// Check receiver class.
AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
@@ -1040,6 +1041,22 @@
}
+intptr_t OffsetForLengthGetter(MethodRecognizer::Kind kind) {
srdjan 2012/12/18 21:45:57 static ?
Florian Schneider 2012/12/19 09:51:29 Done.
+ switch (kind) {
+ case MethodRecognizer::kObjectArrayLength:
+ case MethodRecognizer::kImmutableArrayLength:
+ return Array::length_offset();
+ case MethodRecognizer::kByteArrayBaseLength:
+ return ByteArray::length_offset();
+ case MethodRecognizer::kGrowableArrayLength:
+ return GrowableObjectArray::length_offset();
+ default:
+ UNREACHABLE();
+ return 0;
+ }
+}
+
+
// Only unique implicit instance getters can be currently handled.
bool FlowGraphOptimizer::TryInlineInstanceGetter(InstanceCallInstr* call) {
ASSERT(call->HasICData());
@@ -1063,56 +1080,45 @@
MethodRecognizer::RecognizeKind(target);
// VM objects length getter.
- if ((recognized_kind == MethodRecognizer::kObjectArrayLength) ||
- (recognized_kind == MethodRecognizer::kImmutableArrayLength) ||
- (recognized_kind == MethodRecognizer::kGrowableArrayLength)) {
- if (!ic_data.HasOneTarget()) {
- // TODO(srdjan): Implement for mutiple targets.
- return false;
+ switch (recognized_kind) {
+ case MethodRecognizer::kObjectArrayLength:
+ case MethodRecognizer::kImmutableArrayLength:
+ case MethodRecognizer::kByteArrayBaseLength:
+ case MethodRecognizer::kGrowableArrayLength: {
+ if (!ic_data.HasOneTarget()) {
+ // TODO(srdjan): Implement for mutiple targets.
+ return false;
+ }
+ const bool is_immutable =
+ (recognized_kind != MethodRecognizer::kGrowableArrayLength);
+ InlineArrayLengthGetter(call,
+ OffsetForLengthGetter(recognized_kind),
+ is_immutable,
+ recognized_kind);
+ return true;
}
- switch (recognized_kind) {
- case MethodRecognizer::kObjectArrayLength:
- case MethodRecognizer::kImmutableArrayLength:
- InlineArrayLengthGetter(call,
- Array::length_offset(),
- true,
- recognized_kind);
- break;
- case MethodRecognizer::kGrowableArrayLength:
- InlineArrayLengthGetter(call,
- GrowableObjectArray::length_offset(),
- false,
- recognized_kind);
- break;
- default:
- UNREACHABLE();
- }
- return true;
- }
+ case MethodRecognizer::kGrowableArrayCapacity:
+ InlineGrowableArrayCapacityGetter(call);
+ return true;
srdjan 2012/12/18 21:45:57 I would remove empty lines between the case's.
Florian Schneider 2012/12/19 09:51:29 Done.
- if (recognized_kind == MethodRecognizer::kGrowableArrayCapacity) {
- InlineGArrayCapacityGetter(call);
- return true;
- }
+ case MethodRecognizer::kStringBaseLength:
+ if (!ic_data.HasOneTarget()) {
+ // Target is not only StringBase_get_length.
+ return false;
+ }
+ InlineStringLengthGetter(call);
+ return true;
- if (recognized_kind == MethodRecognizer::kStringBaseLength) {
- if (!ic_data.HasOneTarget()) {
- // Target is not only StringBase_get_length.
- return false;
- }
- InlineStringLengthGetter(call);
- return true;
+ case MethodRecognizer::kStringBaseIsEmpty:
+ if (!ic_data.HasOneTarget()) {
+ // Target is not only StringBase_get_isEmpty.
+ return false;
+ }
+ InlineStringIsEmptyGetter(call);
+ return true;
+ default:
+ ASSERT(recognized_kind == MethodRecognizer::kUnknown);
}
-
- if (recognized_kind == MethodRecognizer::kStringBaseIsEmpty) {
- if (!ic_data.HasOneTarget()) {
- // Target is not only StringBase_get_isEmpty.
- return false;
- }
- InlineStringIsEmptyGetter(call);
- return true;
- }
-
return false;
}
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698