Commit 6266a9d6 authored by bmeurer's avatar bmeurer Committed by Commit bot

[crankshaft] Add support for %_ToString.

Also support %_ToString in Crankshaft utilizing the ToStringStub, which
is also used in TurboFan and fullcodegen. This is necessary to repair a
regression on Octane that was introduced when switching from the hand
crafted NonStringToString/ToString magic to %_ToString (which properly
supports @@toPrimitive).

BUG=chromium:535953,v8:4307
LOG=n

Review URL: https://codereview.chromium.org/1373743002

Cr-Commit-Position: refs/heads/master@{#30955}
parent bac284ee
......@@ -8,6 +8,7 @@
#include "src/allocation-site-scopes.h"
#include "src/ast-numbering.h"
#include "src/code-factory.h"
#include "src/full-codegen/full-codegen.h"
#include "src/hydrogen-bce.h"
#include "src/hydrogen-bch.h"
......@@ -12224,6 +12225,24 @@ void HOptimizedGraphBuilder::GenerateToObject(CallRuntime* call) {
}
void HOptimizedGraphBuilder::GenerateToString(CallRuntime* call) {
DCHECK_EQ(1, call->arguments()->length());
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
Callable callable = CodeFactory::ToString(isolate());
HValue* input = Pop();
if (input->type().IsString()) {
return ast_context()->ReturnValue(input);
} else {
HValue* stub = Add<HConstant>(callable.code());
HValue* values[] = {context(), input};
HInstruction* result =
New<HCallWithDescriptor>(stub, 0, callable.descriptor(),
Vector<HValue*>(values, arraysize(values)));
return ast_context()->ReturnInstruction(result, call->id());
}
}
void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) {
DCHECK(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
......
......@@ -2224,6 +2224,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
F(TwoByteSeqStringSetChar) \
F(ObjectEquals) \
F(ToObject) \
F(ToString) \
F(IsFunction) \
F(IsSpecObject) \
F(MathPow) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment