Commit 0e76a9c3 authored by jgruber's avatar jgruber Committed by Commit bot

[stubs] Add IsCallableMap predicate to CSA

Add an IsCallableMap predicate to code-stub-assembler which tests
whether the given map is callable, and adjust all use sites.

BUG=

Review-Url: https://chromiumcodereview.appspot.com/2435283002
Cr-Commit-Position: refs/heads/master@{#40502}
parent eb10dc4c
...@@ -250,13 +250,8 @@ void Generate_OrdinaryToPrimitive(CodeStubAssembler* assembler, ...@@ -250,13 +250,8 @@ void Generate_OrdinaryToPrimitive(CodeStubAssembler* assembler,
if_methodisnotcallable(assembler, Label::kDeferred); if_methodisnotcallable(assembler, Label::kDeferred);
assembler->GotoIf(assembler->TaggedIsSmi(method), &if_methodisnotcallable); assembler->GotoIf(assembler->TaggedIsSmi(method), &if_methodisnotcallable);
Node* method_map = assembler->LoadMap(method); Node* method_map = assembler->LoadMap(method);
Node* method_bit_field = assembler->LoadMapBitField(method_map); assembler->Branch(assembler->IsCallableMap(method_map),
assembler->Branch( &if_methodiscallable, &if_methodisnotcallable);
assembler->Word32Equal(
assembler->Word32And(method_bit_field, assembler->Int32Constant(
1 << Map::kIsCallable)),
assembler->Int32Constant(0)),
&if_methodisnotcallable, &if_methodiscallable);
assembler->Bind(&if_methodiscallable); assembler->Bind(&if_methodiscallable);
{ {
......
...@@ -443,13 +443,8 @@ void Builtins::Generate_ObjectProtoToString(CodeStubAssembler* assembler) { ...@@ -443,13 +443,8 @@ void Builtins::Generate_ObjectProtoToString(CodeStubAssembler* assembler) {
Node* map = assembler->LoadMap(receiver); Node* map = assembler->LoadMap(receiver);
// Return object if the proxy {receiver} is not callable. // Return object if the proxy {receiver} is not callable.
assembler->Branch( assembler->Branch(assembler->IsCallableMap(map), &return_function,
assembler->Word32Equal( &return_object);
assembler->Word32And(
assembler->LoadMapBitField(map),
assembler->Int32Constant(1 << Map::kIsCallable)),
assembler->Int32Constant(0)),
&return_object, &return_function);
} }
// Default // Default
......
...@@ -1599,11 +1599,8 @@ void Builtins::Generate_RegExpPrototypeReplace(CodeStubAssembler* a) { ...@@ -1599,11 +1599,8 @@ void Builtins::Generate_RegExpPrototypeReplace(CodeStubAssembler* a) {
a->GotoIf(a->TaggedIsSmi(replace_value), &checkreplacestring); a->GotoIf(a->TaggedIsSmi(replace_value), &checkreplacestring);
Node* const replace_value_map = a->LoadMap(replace_value); Node* const replace_value_map = a->LoadMap(replace_value);
a->Branch( a->Branch(a->IsCallableMap(replace_value_map), &if_iscallable,
a->Word32Equal(a->Word32And(a->LoadMapBitField(replace_value_map), &checkreplacestring);
a->Int32Constant(1 << Map::kIsCallable)),
a->Int32Constant(0)),
&checkreplacestring, &if_iscallable);
// 3. Does ToString({replace_value}) contain '$'? // 3. Does ToString({replace_value}) contain '$'?
a->Bind(&checkreplacestring); a->Bind(&checkreplacestring);
......
...@@ -2569,6 +2569,12 @@ Node* CodeStubAssembler::IsJSReceiverInstanceType(Node* instance_type) { ...@@ -2569,6 +2569,12 @@ Node* CodeStubAssembler::IsJSReceiverInstanceType(Node* instance_type) {
Int32Constant(FIRST_JS_RECEIVER_TYPE)); Int32Constant(FIRST_JS_RECEIVER_TYPE));
} }
Node* CodeStubAssembler::IsCallableMap(Node* map) {
return Word32NotEqual(
Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)),
Int32Constant(0));
}
Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) {
// Translate the {index} into a Word. // Translate the {index} into a Word.
index = SmiToWord(index); index = SmiToWord(index);
...@@ -4295,10 +4301,7 @@ Node* CodeStubAssembler::CallGetterIfAccessor(Node* value, Node* details, ...@@ -4295,10 +4301,7 @@ Node* CodeStubAssembler::CallGetterIfAccessor(Node* value, Node* details,
// Return undefined if the {getter} is not callable. // Return undefined if the {getter} is not callable.
var_value.Bind(UndefinedConstant()); var_value.Bind(UndefinedConstant());
GotoIf(Word32Equal(Word32And(LoadMapBitField(getter_map), GotoUnless(IsCallableMap(getter_map), &done);
Int32Constant(1 << Map::kIsCallable)),
Int32Constant(0)),
&done);
// Call the accessor. // Call the accessor.
Callable callable = CodeFactory::Call(isolate()); Callable callable = CodeFactory::Call(isolate());
...@@ -8096,10 +8099,7 @@ compiler::Node* CodeStubAssembler::InstanceOf(compiler::Node* object, ...@@ -8096,10 +8099,7 @@ compiler::Node* CodeStubAssembler::InstanceOf(compiler::Node* object,
// Check if {callable} is a valid receiver. // Check if {callable} is a valid receiver.
GotoIf(TaggedIsSmi(callable), &return_runtime); GotoIf(TaggedIsSmi(callable), &return_runtime);
GotoIf(Word32Equal(Word32And(LoadMapBitField(LoadMap(callable)), GotoUnless(IsCallableMap(LoadMap(callable)), &return_runtime);
Int32Constant(1 << Map::kIsCallable)),
Int32Constant(0)),
&return_runtime);
// Use the inline OrdinaryHasInstance directly. // Use the inline OrdinaryHasInstance directly.
result.Bind(OrdinaryHasInstance(context, callable, object)); result.Bind(OrdinaryHasInstance(context, callable, object));
......
...@@ -595,6 +595,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -595,6 +595,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
compiler::Node* IsStringInstanceType(compiler::Node* instance_type); compiler::Node* IsStringInstanceType(compiler::Node* instance_type);
compiler::Node* IsJSReceiverInstanceType(compiler::Node* instance_type); compiler::Node* IsJSReceiverInstanceType(compiler::Node* instance_type);
compiler::Node* IsCallableMap(compiler::Node* map);
// String helpers. // String helpers.
// Load a character from a String (might flatten a ConsString). // Load a character from a String (might flatten a ConsString).
compiler::Node* StringCharCodeAt(compiler::Node* string, compiler::Node* StringCharCodeAt(compiler::Node* string,
......
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