Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(871)

Side by Side Diff: src/code-stub-assembler.cc

Issue 2435953002: Add CodeStubAssembler::FlattenString (Closed)
Patch Set: deferred block Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 #include "src/ic/handler-configuration.h" 8 #include "src/ic/handler-configuration.h"
9 #include "src/ic/stub-cache.h" 9 #include "src/ic/stub-cache.h"
10 10
(...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 Bind(&runtime); 3612 Bind(&runtime);
3613 { 3613 {
3614 result.Bind(CallRuntime(Runtime::kToString, context, input)); 3614 result.Bind(CallRuntime(Runtime::kToString, context, input));
3615 Goto(&done); 3615 Goto(&done);
3616 } 3616 }
3617 3617
3618 Bind(&done); 3618 Bind(&done);
3619 return result.value(); 3619 return result.value();
3620 } 3620 }
3621 3621
3622 Node* CodeStubAssembler::FlattenString(Node* string) {
3623 Variable var_result(this, MachineRepresentation::kTagged);
3624 var_result.Bind(string);
3625
3626 Node* instance_type = LoadInstanceType(string);
3627
3628 // Check if the {string} is not a ConsString (i.e. already flat).
3629 Label is_cons(this, Label::kDeferred), is_flat_in_cons(this), end(this);
3630 {
3631 GotoUnless(Word32Equal(Word32And(instance_type,
3632 Int32Constant(kStringRepresentationMask)),
3633 Int32Constant(kConsStringTag)),
3634 &end);
3635
3636 // Check whether the right hand side is the empty string (i.e. if
3637 // this is really a flat string in a cons string).
3638 Node* rhs = LoadObjectField(string, ConsString::kSecondOffset);
3639 Branch(WordEqual(rhs, EmptyStringConstant()), &is_flat_in_cons, &is_cons);
3640 }
3641
3642 // Bail out to the runtime.
3643 Bind(&is_cons);
3644 {
3645 var_result.Bind(
3646 CallRuntime(Runtime::kFlattenString, NoContextConstant(), string));
3647 Goto(&end);
3648 }
3649
3650 Bind(&is_flat_in_cons);
3651 {
3652 var_result.Bind(LoadObjectField(string, ConsString::kFirstOffset));
3653 Goto(&end);
3654 }
3655
3656 Bind(&end);
3657 return var_result.value();
3658 }
3659
3622 Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) { 3660 Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) {
3623 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); 3661 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
3624 Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this); 3662 Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this);
3625 Variable result(this, MachineRepresentation::kTagged); 3663 Variable result(this, MachineRepresentation::kTagged);
3626 Label done(this, &result); 3664 Label done(this, &result);
3627 3665
3628 GotoIf(TaggedIsSmi(input), &if_isnotreceiver); 3666 GotoIf(TaggedIsSmi(input), &if_isnotreceiver);
3629 3667
3630 Node* map = LoadMap(input); 3668 Node* map = LoadMap(input);
3631 Node* instance_type = LoadMapInstanceType(map); 3669 Node* instance_type = LoadMapInstanceType(map);
(...skipping 4675 matching lines...) Expand 10 before | Expand all | Expand 10 after
8307 Node* buffer_bit_field = LoadObjectField( 8345 Node* buffer_bit_field = LoadObjectField(
8308 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); 8346 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32());
8309 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); 8347 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask);
8310 8348
8311 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), 8349 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask),
8312 Int32Constant(0)); 8350 Int32Constant(0));
8313 } 8351 }
8314 8352
8315 } // namespace internal 8353 } // namespace internal
8316 } // namespace v8 8354 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698