-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array inject accept strings #3425
Open
wasabigeek
wants to merge
2
commits into
oracle:master
Choose a base branch
from
Shopify:array-inject-accept-strings
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1305,27 +1305,30 @@ private static final class State { | |||||
|
||||||
// Uses block and no Symbol | ||||||
|
||||||
@Specialization(guards = { "isEmptyArray(array)", "wasProvided(initialOrSymbol)" }) | ||||||
Object injectEmptyArray(RubyArray array, Object initialOrSymbol, NotProvided symbol, RubyProc block) { | ||||||
return initialOrSymbol; | ||||||
@Specialization(guards = { "isEmptyArray(array)", "wasProvided(initialOrSymbolOrString)" }) | ||||||
Object injectEmptyArray( | ||||||
RubyArray array, Object initialOrSymbolOrString, NotProvided symbolOrString, RubyProc block) { | ||||||
return initialOrSymbolOrString; | ||||||
} | ||||||
|
||||||
@Specialization(guards = { "isEmptyArray(array)" }) | ||||||
Object injectEmptyArrayNoInitial( | ||||||
RubyArray array, NotProvided initialOrSymbol, NotProvided symbol, RubyProc block) { | ||||||
RubyArray array, NotProvided initialOrSymbolOrString, NotProvided symbolOrString, RubyProc block) { | ||||||
return nil; | ||||||
} | ||||||
|
||||||
@Specialization(guards = { "!isEmptyArray(array)", "wasProvided(initialOrSymbol)" }) | ||||||
Object injectWithInitial(RubyArray array, Object initialOrSymbol, NotProvided symbol, RubyProc block, | ||||||
@Specialization(guards = { "!isEmptyArray(array)", "wasProvided(initialOrSymbolOrString)" }) | ||||||
Object injectWithInitial( | ||||||
RubyArray array, Object initialOrSymbolOrString, NotProvided symbolOrString, RubyProc block, | ||||||
@Cached @Shared ArrayEachIteratorNode iteratorNode) { | ||||||
return injectBlockHelper(array, block, initialOrSymbol, 0, iteratorNode); | ||||||
return injectBlockHelper(array, block, initialOrSymbolOrString, 0, iteratorNode); | ||||||
} | ||||||
|
||||||
@Specialization( | ||||||
guards = { "!isEmptyArray(array)" }, | ||||||
limit = "storageStrategyLimit()") | ||||||
Object injectNoInitial(RubyArray array, NotProvided initialOrSymbol, NotProvided symbol, RubyProc block, | ||||||
Object injectNoInitial( | ||||||
RubyArray array, NotProvided initialOrSymbolOrString, NotProvided symbolOrString, RubyProc block, | ||||||
@Bind("array.getStore()") Object store, | ||||||
@CachedLibrary("store") ArrayStoreLibrary stores, | ||||||
@Cached @Shared ArrayEachIteratorNode iteratorNode) { | ||||||
|
@@ -1353,23 +1356,28 @@ public void accept(Node node, CallBlockNode yieldNode, RubyArray array, Object s | |||||
|
||||||
@Specialization(guards = { "isEmptyArray(array)" }) | ||||||
Object injectSymbolEmptyArrayNoInitial( | ||||||
RubyArray array, RubySymbol initialOrSymbol, NotProvided symbol, Nil block) { | ||||||
RubyArray array, RubySymbol initialOrSymbolOrString, NotProvided symbolOrString, Nil block) { | ||||||
return nil; | ||||||
} | ||||||
|
||||||
@Specialization( | ||||||
guards = { | ||||||
"isEmptyArray(array)", | ||||||
"wasProvided(initialOrSymbol)" }) | ||||||
Object injectSymbolEmptyArray(RubyArray array, Object initialOrSymbol, RubySymbol symbol, Nil block) { | ||||||
return initialOrSymbol; | ||||||
"wasProvided(initialOrSymbolOrString)" }) | ||||||
Object injectSymbolEmptyArray( | ||||||
RubyArray array, Object initialOrSymbolOrString, RubySymbol symbolOrString, Nil block) { | ||||||
return initialOrSymbolOrString; | ||||||
} | ||||||
|
||||||
@Specialization( | ||||||
guards = { "!isEmptyArray(array)" }, | ||||||
limit = "storageStrategyLimit()") | ||||||
Object injectSymbolNoInitial( | ||||||
VirtualFrame frame, RubyArray array, RubySymbol initialOrSymbol, NotProvided symbol, Nil block, | ||||||
VirtualFrame frame, | ||||||
RubyArray array, | ||||||
RubySymbol initialOrSymbolOrString, | ||||||
NotProvided symbolOrString, | ||||||
Nil block, | ||||||
@Bind("array.getStore()") Object store, | ||||||
@CachedLibrary("store") ArrayStoreLibrary stores, | ||||||
@Cached @Shared IntValueProfile arraySizeProfile, | ||||||
|
@@ -1378,7 +1386,7 @@ Object injectSymbolNoInitial( | |||||
return injectSymbolHelper( | ||||||
frame, | ||||||
array, | ||||||
toJavaString.execute(this, initialOrSymbol), | ||||||
toJavaString.execute(this, initialOrSymbolOrString), | ||||||
stores, | ||||||
store, | ||||||
stores.read(store, 0), | ||||||
|
@@ -1390,10 +1398,14 @@ Object injectSymbolNoInitial( | |||||
@Specialization( | ||||||
guards = { | ||||||
"!isEmptyArray(array)", | ||||||
"wasProvided(initialOrSymbol)" }, | ||||||
"wasProvided(initialOrSymbolOrString)" }, | ||||||
limit = "storageStrategyLimit()") | ||||||
Object injectSymbolWithInitial( | ||||||
VirtualFrame frame, RubyArray array, Object initialOrSymbol, RubySymbol symbol, Nil block, | ||||||
VirtualFrame frame, | ||||||
RubyArray array, | ||||||
Object initialOrSymbolOrString, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
RubySymbol symbolOrString, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(or |
||||||
Nil block, | ||||||
@Bind("array.getStore()") Object store, | ||||||
@CachedLibrary("store") ArrayStoreLibrary stores, | ||||||
@Cached @Shared IntValueProfile arraySizeProfile, | ||||||
|
@@ -1402,23 +1414,95 @@ Object injectSymbolWithInitial( | |||||
return injectSymbolHelper( | ||||||
frame, | ||||||
array, | ||||||
toJavaString.execute(this, symbol), | ||||||
toJavaString.execute(this, symbolOrString), | ||||||
stores, | ||||||
store, | ||||||
initialOrSymbol, | ||||||
initialOrSymbolOrString, | ||||||
0, | ||||||
arraySizeProfile, | ||||||
loopProfile); | ||||||
} | ||||||
|
||||||
private Object injectSymbolHelper(VirtualFrame frame, RubyArray array, String symbol, | ||||||
// Uses String and no block | ||||||
|
||||||
@Specialization(guards = { "isEmptyArray(array)" }) | ||||||
Object injectStringEmptyArrayNoInitial( | ||||||
RubyArray array, RubyString initialOrSymbolOrString, NotProvided symbolOrString, Nil block) { | ||||||
return nil; | ||||||
} | ||||||
|
||||||
@Specialization( | ||||||
guards = { | ||||||
"isEmptyArray(array)", | ||||||
"wasProvided(initialOrSymbolOrString)" }) | ||||||
Object injectStringEmptyArray( | ||||||
RubyArray array, Object initialOrSymbolOrString, RubyString symbolOrString, Nil block) { | ||||||
return initialOrSymbolOrString; | ||||||
} | ||||||
|
||||||
@Specialization( | ||||||
guards = { "!isEmptyArray(array)" }, | ||||||
limit = "storageStrategyLimit()") | ||||||
Object injectStringNoInitial( | ||||||
VirtualFrame frame, | ||||||
RubyArray array, | ||||||
RubyString initialOrSymbolOrString, | ||||||
NotProvided symbolOrString, | ||||||
Nil block, | ||||||
@Bind("array.getStore()") Object store, | ||||||
@CachedLibrary("store") ArrayStoreLibrary stores, | ||||||
@Cached @Shared IntValueProfile arraySizeProfile, | ||||||
@Cached @Exclusive LoopConditionProfile loopProfile, | ||||||
@Cached @Shared ToJavaStringNode toJavaString) { | ||||||
return injectSymbolHelper( | ||||||
frame, | ||||||
array, | ||||||
toJavaString.execute(this, initialOrSymbolOrString), | ||||||
stores, | ||||||
store, | ||||||
stores.read(store, 0), | ||||||
1, | ||||||
arraySizeProfile, | ||||||
loopProfile); | ||||||
} | ||||||
|
||||||
@Specialization( | ||||||
guards = { | ||||||
"!isEmptyArray(array)", | ||||||
"wasProvided(initialOrSymbolOrString)" }, | ||||||
limit = "storageStrategyLimit()") | ||||||
Object injectSymbolWithInitial( | ||||||
VirtualFrame frame, | ||||||
RubyArray array, | ||||||
Object initialOrSymbolOrString, | ||||||
RubyString symbolOrString, | ||||||
Nil block, | ||||||
@Bind("array.getStore()") Object store, | ||||||
@CachedLibrary("store") ArrayStoreLibrary stores, | ||||||
@Cached @Shared IntValueProfile arraySizeProfile, | ||||||
@Cached @Exclusive LoopConditionProfile loopProfile, | ||||||
@Cached @Shared ToJavaStringNode toJavaString) { | ||||||
return injectSymbolHelper( | ||||||
frame, | ||||||
array, | ||||||
toJavaString.execute(this, symbolOrString), | ||||||
stores, | ||||||
store, | ||||||
initialOrSymbolOrString, | ||||||
0, | ||||||
arraySizeProfile, | ||||||
loopProfile); | ||||||
} | ||||||
|
||||||
private Object injectSymbolHelper(VirtualFrame frame, RubyArray array, String symbolOrString, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
ArrayStoreLibrary stores, Object store, Object initial, int start, | ||||||
IntValueProfile arraySizeProfile, LoopConditionProfile loopProfile) { | ||||||
Object accumulator = initial; | ||||||
int n = start; | ||||||
try { | ||||||
for (; loopProfile.inject(n < arraySizeProfile.profile(array.size)); n++) { | ||||||
accumulator = dispatch.callWithFrame(PUBLIC, frame, accumulator, symbol, stores.read(store, n)); | ||||||
accumulator = dispatch.callWithFrame(PUBLIC, frame, accumulator, symbolOrString, | ||||||
stores.read(store, n)); | ||||||
TruffleSafepoint.poll(this); | ||||||
} | ||||||
} finally { | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symbol or method