Commit 7b6ac70a authored by bmeurer's avatar bmeurer Committed by Commit bot

[builtins] Pass NotNullOrUndefined to ToPrimitive calls.

For calls from ToPrimitive we already now that the receiver cannot be
null or undefined, since a property lookup succeeded before the call,
which would have thrown an exception in case of null or undefined.

R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2649093002
Cr-Commit-Position: refs/heads/master@{#42589}
parent 66f2d7b6
......@@ -24,6 +24,7 @@ Handle<Code> Builtins::NonPrimitiveToPrimitive(ToPrimitiveHint hint) {
}
namespace {
// ES6 section 7.1.1 ToPrimitive ( input [ , PreferredType ] )
void Generate_NonPrimitiveToPrimitive(CodeStubAssembler* assembler,
ToPrimitiveHint hint) {
......@@ -52,7 +53,8 @@ void Generate_NonPrimitiveToPrimitive(CodeStubAssembler* assembler,
{
// Invoke the {exotic_to_prim} method on the {input} with a string
// representation of the {hint}.
Callable callable = CodeFactory::Call(assembler->isolate());
Callable callable = CodeFactory::Call(
assembler->isolate(), ConvertReceiverMode::kNotNullOrUndefined);
Node* hint_string = assembler->HeapConstant(
assembler->factory()->ToPrimitiveHintString(hint));
Node* result = assembler->CallJS(callable, context, exotic_to_prim, input,
......@@ -93,7 +95,8 @@ void Generate_NonPrimitiveToPrimitive(CodeStubAssembler* assembler,
assembler->TailCallStub(callable, context, input);
}
}
} // anonymous namespace
} // namespace
void Builtins::Generate_NonPrimitiveToPrimitive_Default(
compiler::CodeAssemblerState* state) {
......@@ -221,6 +224,7 @@ Handle<Code> Builtins::OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint) {
}
namespace {
// 7.1.1.1 OrdinaryToPrimitive ( O, hint )
void Generate_OrdinaryToPrimitive(CodeStubAssembler* assembler,
OrdinaryToPrimitiveHint hint) {
......@@ -263,7 +267,8 @@ void Generate_OrdinaryToPrimitive(CodeStubAssembler* assembler,
assembler->Bind(&if_methodiscallable);
{
// Call the {method} on the {input}.
Callable callable = CodeFactory::Call(assembler->isolate());
Callable callable = CodeFactory::Call(
assembler->isolate(), ConvertReceiverMode::kNotNullOrUndefined);
Node* result = assembler->CallJS(callable, context, method, input);
var_result.Bind(result);
......@@ -287,7 +292,8 @@ void Generate_OrdinaryToPrimitive(CodeStubAssembler* assembler,
assembler->Bind(&return_result);
assembler->Return(var_result.value());
}
} // anonymous namespace
} // namespace
void Builtins::Generate_OrdinaryToPrimitive_Number(
compiler::CodeAssemblerState* state) {
......
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