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

Unified Diff: src/ic.cc

Issue 106453003: Allocation site support for monomorphic StringAdds in BinaryOps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix NewStringAddStub flags bits. Created 7 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
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 25f875a8379308e3230592f8a74348dffa5672df..c5517b4e87e040e2cff67d360ca27bda9a4d3a64 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -2397,6 +2397,11 @@ void BinaryOpIC::State::GenerateAheadOfTime(
GENERATE(Token::ADD, SMI, NUMBER, NUMBER, OVERWRITE_RIGHT);
GENERATE(Token::ADD, SMI, SMI, INT32, OVERWRITE_LEFT);
GENERATE(Token::ADD, SMI, SMI, SMI, OVERWRITE_RIGHT);
+ GENERATE(Token::ADD, STRING, SMI, STRING, NO_OVERWRITE);
+ GENERATE(Token::ADD, SMI, STRING, STRING, NO_OVERWRITE);
+ GENERATE(Token::ADD, STRING, NUMBER, STRING, NO_OVERWRITE);
+ GENERATE(Token::ADD, NUMBER, STRING, STRING, NO_OVERWRITE);
+ GENERATE(Token::ADD, STRING, STRING, STRING, NO_OVERWRITE);
GENERATE(Token::BIT_AND, INT32, INT32, INT32, NO_OVERWRITE);
GENERATE(Token::BIT_AND, INT32, INT32, INT32, OVERWRITE_LEFT);
GENERATE(Token::BIT_AND, INT32, INT32, INT32, OVERWRITE_RIGHT);
@@ -2596,6 +2601,7 @@ void BinaryOpIC::State::Print(StringStream* stream) const {
stream->Add("(%s", Token::Name(op_));
if (mode_ == OVERWRITE_LEFT) stream->Add("_ReuseLeft");
else if (mode_ == OVERWRITE_RIGHT) stream->Add("_ReuseRight");
+ if (CanCreateAllocationMementos()) stream->Add("_CreateAllocationMementos");
stream->Add(":%s*", KindToString(left_kind_));
if (fixed_right_arg_.has_value) {
stream->Add("%d", fixed_right_arg_.value);
@@ -2635,6 +2641,18 @@ void BinaryOpIC::State::Update(Handle<Object> left,
}
}
+ // We don't want to distinguish INT32 and NUMBER for string add (because
+ // NumberToString can't make use of this anyway).
+ if (left_kind_ == STRING && right_kind_ == INT32) {
+ ASSERT_EQ(STRING, result_kind_);
+ ASSERT_EQ(Token::ADD, op_);
+ right_kind_ = NUMBER;
+ } else if (right_kind_ == STRING && left_kind_ == INT32) {
+ ASSERT_EQ(STRING, result_kind_);
+ ASSERT_EQ(Token::ADD, op_);
+ left_kind_ = NUMBER;
+ }
+
// Reset overwrite mode unless we can actually make use of it, or may be able
// to make use of it at some point in the future.
if ((mode_ == OVERWRITE_LEFT && left_kind_ > NUMBER) ||
@@ -2720,7 +2738,9 @@ Handle<Type> BinaryOpIC::State::KindToType(Kind kind, Isolate* isolate) {
}
-MaybeObject* BinaryOpIC::Transition(Handle<Object> left, Handle<Object> right) {
+MaybeObject* BinaryOpIC::Transition(Handle<AllocationSite> allocation_site,
+ Handle<Object> left,
+ Handle<Object> right) {
State state(target()->extended_extra_ic_state());
// Compute the actual result using the builtin for the binary operation.
@@ -2736,9 +2756,29 @@ MaybeObject* BinaryOpIC::Transition(Handle<Object> left, Handle<Object> right) {
State old_state = state;
state.Update(left, right, result);
- // Install the new stub.
- BinaryOpICStub stub(state);
- set_target(*stub.GetCode(isolate()));
+ // Check if we have a string operation here.
+ Handle<Code> target;
+ if (!allocation_site.is_null() || state.ShouldCreateAllocationMementos()) {
+ // Setup the allocation site on-demand.
+ if (allocation_site.is_null()) {
+ allocation_site = isolate()->factory()->NewAllocationSite();
+ }
+
+ // Install the stub with an allocation site.
+ BinaryOpICWithAllocationSiteStub stub(state);
+ target = stub.GetCodeCopyFromTemplate(isolate(), allocation_site);
+
+ // Sanity check the trampoline stub.
+ ASSERT_EQ(*allocation_site, target->FindFirstAllocationSite());
+ } else {
+ // Install the generic stub.
+ BinaryOpICStub stub(state);
+ target = stub.GetCode(isolate());
+
+ // Sanity check the generic stub.
+ ASSERT_EQ(NULL, target->FindFirstAllocationSite());
+ }
+ set_target(*target);
if (FLAG_trace_ic) {
char buffer[150];
@@ -2749,9 +2789,12 @@ MaybeObject* BinaryOpIC::Transition(Handle<Object> left, Handle<Object> right) {
old_state.Print(&stream);
stream.Add(" => ");
state.Print(&stream);
- stream.Add(" @ %p <- ", static_cast<void*>(*target()));
+ stream.Add(" @ %p <- ", static_cast<void*>(*target));
stream.OutputToStdOut();
JavaScriptFrame::PrintTop(isolate(), stdout, false, true);
+ if (!allocation_site.is_null()) {
+ PrintF(" using allocation site %p", static_cast<void*>(*allocation_site));
+ }
PrintF("]\n");
}
@@ -2771,7 +2814,20 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss) {
Handle<Object> left = args.at<Object>(BinaryOpICStub::kLeft);
Handle<Object> right = args.at<Object>(BinaryOpICStub::kRight);
BinaryOpIC ic(isolate);
- return ic.Transition(left, right);
+ return ic.Transition(Handle<AllocationSite>::null(), left, right);
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite) {
+ HandleScope scope(isolate);
+ Handle<AllocationSite> allocation_site = args.at<AllocationSite>(
+ BinaryOpWithAllocationSiteStub::kAllocationSite);
+ Handle<Object> left = args.at<Object>(
+ BinaryOpWithAllocationSiteStub::kLeft);
+ Handle<Object> right = args.at<Object>(
+ BinaryOpWithAllocationSiteStub::kRight);
+ BinaryOpIC ic(isolate);
+ return ic.Transition(allocation_site, left, right);
}

Powered by Google App Engine
This is Rietveld 408576698