Chromium Code Reviews| Index: src/code-stub-assembler.cc |
| diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
| index f23b82829ecc3d8dbc81cf1a7622977a6a67bdca..8e129d4b23e70fd772fce29d2b83a51315bd6b6d 100644 |
| --- a/src/code-stub-assembler.cc |
| +++ b/src/code-stub-assembler.cc |
| @@ -3610,15 +3610,44 @@ Node* CodeStubAssembler::ToString(Node* context, Node* input) { |
| } |
| Bind(&runtime); |
| - { |
| - result.Bind(CallRuntime(Runtime::kToString, context, input)); |
| - Goto(&done); |
| - } |
| + result.Bind(CallRuntime(Runtime::kToString, context, input)); |
|
danno
2016/10/20 08:35:52
After our discussion, not sure if you want this wh
|
| + Goto(&done); |
| Bind(&done); |
| return result.value(); |
| } |
| +Node* CodeStubAssembler::FlattenString(Node* string) { |
| + Variable var_result(this, MachineRepresentation::kTagged); |
| + var_result.Bind(string); |
| + |
| + Node* instance_type = LoadInstanceType(string); |
| + |
| + // Check if the {string} is not a ConsString (i.e. already flat). |
| + Label is_flat_in_cons(this), end(this); |
| + GotoUnless(Word32Equal(Word32And(instance_type, |
| + Int32Constant(kStringRepresentationMask)), |
| + Int32Constant(kConsStringTag)), |
| + &end); |
| + |
| + // Check whether the right hand side is the empty string (i.e. if |
| + // this is really a flat string in a cons string). |
| + Node* rhs = LoadObjectField(string, ConsString::kSecondOffset); |
| + GotoIf(WordEqual(rhs, EmptyStringConstant()), &is_flat_in_cons); |
| + |
| + // Bail out to the runtime. |
|
danno
2016/10/20 08:35:52
Make this label deferred. You can make that effici
|
| + var_result.Bind( |
| + CallRuntime(Runtime::kFlattenString, NoContextConstant(), string)); |
| + Goto(&end); |
| + |
| + Bind(&is_flat_in_cons); |
| + var_result.Bind(LoadObjectField(string, ConsString::kFirstOffset)); |
| + Goto(&end); |
| + |
| + Bind(&end); |
| + return var_result.value(); |
| +} |
| + |
| Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) { |
| STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this); |