Skip to content

Commit 8e303dd

Browse files
hashseedCommit bot
authored andcommitted
Fix %FunctionGetName and %_ClassOf for bound functions.
[email protected] BUG=v8:5010 Review-Url: https://codereview.chromium.org/1980463002 Cr-Commit-Position: refs/heads/master@{#36276}
1 parent 551e0aa commit 8e303dd

15 files changed

Lines changed: 64 additions & 34 deletions

src/crankshaft/arm/lithium-codegen-arm.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,11 +2436,12 @@ void LCodeGen::EmitClassOfTest(Label* is_true,
24362436

24372437
__ JumpIfSmi(input, is_false);
24382438

2439-
__ CompareObjectType(input, temp, temp2, JS_FUNCTION_TYPE);
2439+
__ CompareObjectType(input, temp, temp2, FIRST_FUNCTION_TYPE);
2440+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
24402441
if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2441-
__ b(eq, is_true);
2442+
__ b(hs, is_true);
24422443
} else {
2443-
__ b(eq, is_false);
2444+
__ b(hs, is_false);
24442445
}
24452446

24462447
// Check if the constructor in the map is a function.

src/crankshaft/arm64/lithium-codegen-arm64.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,11 +2250,12 @@ void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) {
22502250
__ JumpIfSmi(input, false_label);
22512251

22522252
Register map = scratch2;
2253-
__ CompareObjectType(input, map, scratch1, JS_FUNCTION_TYPE);
2253+
__ CompareObjectType(input, map, scratch1, FIRST_FUNCTION_TYPE);
2254+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
22542255
if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2255-
__ B(eq, true_label);
2256+
__ B(hs, true_label);
22562257
} else {
2257-
__ B(eq, false_label);
2258+
__ B(hs, false_label);
22582259
}
22592260

22602261
// Check if the constructor in the map is a function.

src/crankshaft/ia32/lithium-codegen-ia32.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,11 +2232,12 @@ void LCodeGen::EmitClassOfTest(Label* is_true,
22322232
DCHECK(!temp.is(temp2));
22332233
__ JumpIfSmi(input, is_false);
22342234

2235-
__ CmpObjectType(input, JS_FUNCTION_TYPE, temp);
2235+
__ CmpObjectType(input, FIRST_FUNCTION_TYPE, temp);
2236+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
22362237
if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2237-
__ j(equal, is_true);
2238+
__ j(above_equal, is_true);
22382239
} else {
2239-
__ j(equal, is_false);
2240+
__ j(above_equal, is_false);
22402241
}
22412242

22422243
// Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range.

src/crankshaft/mips/lithium-codegen-mips.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,10 +2324,11 @@ void LCodeGen::EmitClassOfTest(Label* is_true,
23242324

23252325
__ JumpIfSmi(input, is_false);
23262326
__ GetObjectType(input, temp, temp2);
2327+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
23272328
if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2328-
__ Branch(is_true, eq, temp2, Operand(JS_FUNCTION_TYPE));
2329+
__ Branch(is_true, hs, temp2, Operand(FIRST_FUNCTION_TYPE));
23292330
} else {
2330-
__ Branch(is_false, eq, temp2, Operand(JS_FUNCTION_TYPE));
2331+
__ Branch(is_false, hs, temp2, Operand(FIRST_FUNCTION_TYPE));
23312332
}
23322333

23332334
// Check if the constructor in the map is a function.

src/crankshaft/mips64/lithium-codegen-mips64.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,10 +2443,11 @@ void LCodeGen::EmitClassOfTest(Label* is_true,
24432443
__ JumpIfSmi(input, is_false);
24442444

24452445
__ GetObjectType(input, temp, temp2);
2446+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
24462447
if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2447-
__ Branch(is_true, eq, temp2, Operand(JS_FUNCTION_TYPE));
2448+
__ Branch(is_true, hs, temp2, Operand(FIRST_FUNCTION_TYPE));
24482449
} else {
2449-
__ Branch(is_false, eq, temp2, Operand(JS_FUNCTION_TYPE));
2450+
__ Branch(is_false, hs, temp2, Operand(FIRST_FUNCTION_TYPE));
24502451
}
24512452

24522453
// Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range.

src/crankshaft/x64/lithium-codegen-x64.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,11 +2381,12 @@ void LCodeGen::EmitClassOfTest(Label* is_true,
23812381

23822382
__ JumpIfSmi(input, is_false);
23832383

2384-
__ CmpObjectType(input, JS_FUNCTION_TYPE, temp);
2384+
__ CmpObjectType(input, FIRST_FUNCTION_TYPE, temp);
2385+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
23852386
if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2386-
__ j(equal, is_true);
2387+
__ j(above_equal, is_true);
23872388
} else {
2388-
__ j(equal, is_false);
2389+
__ j(above_equal, is_false);
23892390
}
23902391

23912392
// Check if the constructor in the map is a function.

src/full-codegen/arm/full-codegen-arm.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,9 +2834,10 @@ void FullCodeGenerator::EmitClassOf(CallRuntime* expr) {
28342834
// Map is now in r0.
28352835
__ b(lt, &null);
28362836

2837-
// Return 'Function' for JSFunction objects.
2838-
__ cmp(r1, Operand(JS_FUNCTION_TYPE));
2839-
__ b(eq, &function);
2837+
// Return 'Function' for JSFunction and JSBoundFunction objects.
2838+
__ cmp(r1, Operand(FIRST_FUNCTION_TYPE));
2839+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
2840+
__ b(hs, &function);
28402841

28412842
// Check if the constructor in the map is a JS function.
28422843
Register instance_type = r2;

src/full-codegen/arm64/full-codegen-arm64.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,8 +2741,9 @@ void FullCodeGenerator::EmitClassOf(CallRuntime* expr) {
27412741
__ B(lt, &null);
27422742

27432743
// Return 'Function' for JSFunction objects.
2744-
__ Cmp(x11, JS_FUNCTION_TYPE);
2745-
__ B(eq, &function);
2744+
__ Cmp(x11, FIRST_FUNCTION_TYPE);
2745+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
2746+
__ B(hs, &function);
27462747

27472748
// Check if the constructor in the map is a JS function.
27482749
Register instance_type = x14;

src/full-codegen/ia32/full-codegen-ia32.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,9 +2723,10 @@ void FullCodeGenerator::EmitClassOf(CallRuntime* expr) {
27232723
__ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, eax);
27242724
__ j(below, &null, Label::kNear);
27252725

2726-
// Return 'Function' for JSFunction objects.
2727-
__ CmpInstanceType(eax, JS_FUNCTION_TYPE);
2728-
__ j(equal, &function, Label::kNear);
2726+
// Return 'Function' for JSFunction and JSBoundFunction objects.
2727+
__ CmpInstanceType(eax, FIRST_FUNCTION_TYPE);
2728+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
2729+
__ j(above_equal, &function, Label::kNear);
27292730

27302731
// Check if the constructor in the map is a JS function.
27312732
__ GetMapConstructor(eax, eax, ebx);

src/full-codegen/mips/full-codegen-mips.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,8 +2839,9 @@ void FullCodeGenerator::EmitClassOf(CallRuntime* expr) {
28392839
__ GetObjectType(v0, v0, a1); // Map is now in v0.
28402840
__ Branch(&null, lt, a1, Operand(FIRST_JS_RECEIVER_TYPE));
28412841

2842-
// Return 'Function' for JSFunction objects.
2843-
__ Branch(&function, eq, a1, Operand(JS_FUNCTION_TYPE));
2842+
// Return 'Function' for JSFunction and JSBoundFunction objects.
2843+
STATIC_ASSERT(LAST_FUNCTION_TYPE == LAST_TYPE);
2844+
__ Branch(&function, hs, a1, Operand(FIRST_FUNCTION_TYPE));
28442845

28452846
// Check if the constructor in the map is a JS function.
28462847
Register instance_type = a2;

0 commit comments

Comments
 (0)