Chromium Code Reviews

Unified Diff: src/code-stubs.cc

Issue 1765883002: [compiler] Reduce the code size of the ToBoolean stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index e72a43b430dbc331eb256581afa3bda8301ec34b..7b8cc9adbf986954f4439570f3cc8ab31d6f4b5a 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -1586,8 +1586,9 @@ void ToBooleanStub::GenerateAssembly(
assembler->Bind(&if_valueisnotsmi);
{
- Label if_valueisstring(assembler), if_valueisheapnumber(assembler),
- if_valueisoddball(assembler), if_valueisother(assembler);
+ Label if_valueisstring(assembler), if_valueisnotstring(assembler),
+ if_valueisheapnumber(assembler), if_valueisoddball(assembler),
+ if_valueisother(assembler);
// The {value} is a HeapObject, load its map.
Node* value_map = assembler->LoadObjectField(value, HeapObject::kMapOffset);
@@ -1599,24 +1600,20 @@ void ToBooleanStub::GenerateAssembly(
// Dispatch based on the instance type; we distinguish all String instance
// types, the HeapNumber type and the Oddball type.
- size_t const kNumCases = FIRST_NONSTRING_TYPE + 2;
+ assembler->Branch(
+ assembler->Int32LessThan(
+ value_instancetype, assembler->Int32Constant(FIRST_NONSTRING_TYPE)),
+ &if_valueisstring, &if_valueisnotstring);
+ assembler->Bind(&if_valueisnotstring);
+ size_t const kNumCases = 2;
Label* case_labels[kNumCases];
int32_t case_values[kNumCases];
- for (int32_t i = 0; i < FIRST_NONSTRING_TYPE; ++i) {
- case_labels[i] = new Label(assembler);
- case_values[i] = i;
- }
- case_labels[FIRST_NONSTRING_TYPE + 0] = &if_valueisheapnumber;
- case_values[FIRST_NONSTRING_TYPE + 0] = HEAP_NUMBER_TYPE;
- case_labels[FIRST_NONSTRING_TYPE + 1] = &if_valueisoddball;
- case_values[FIRST_NONSTRING_TYPE + 1] = ODDBALL_TYPE;
+ case_labels[0] = &if_valueisheapnumber;
+ case_values[0] = HEAP_NUMBER_TYPE;
+ case_labels[1] = &if_valueisoddball;
+ case_values[1] = ODDBALL_TYPE;
assembler->Switch(value_instancetype, &if_valueisother, case_values,
case_labels, arraysize(case_values));
- for (int32_t i = 0; i < FIRST_NONSTRING_TYPE; ++i) {
- assembler->Bind(case_labels[i]);
- assembler->Goto(&if_valueisstring);
- delete case_labels[i];
- }
assembler->Bind(&if_valueisstring);
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine