OLD | NEW |
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 | 4 |
5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 char const* method_name); | 685 char const* method_name); |
686 | 686 |
687 // Type checks. | 687 // Type checks. |
688 // Check whether the map is for an object with special properties, such as a | 688 // Check whether the map is for an object with special properties, such as a |
689 // JSProxy or an object with interceptors. | 689 // JSProxy or an object with interceptors. |
690 Node* InstanceTypeEqual(Node* instance_type, int type); | 690 Node* InstanceTypeEqual(Node* instance_type, int type); |
691 Node* IsSpecialReceiverMap(Node* map); | 691 Node* IsSpecialReceiverMap(Node* map); |
692 Node* IsSpecialReceiverInstanceType(Node* instance_type); | 692 Node* IsSpecialReceiverInstanceType(Node* instance_type); |
693 Node* IsStringInstanceType(Node* instance_type); | 693 Node* IsStringInstanceType(Node* instance_type); |
694 Node* IsOneByteStringInstanceType(Node* instance_type); | 694 Node* IsOneByteStringInstanceType(Node* instance_type); |
| 695 Node* IsExternalStringInstanceType(Node* instance_type); |
| 696 Node* IsShortExternalStringInstanceType(Node* instance_type); |
695 Node* IsSequentialStringInstanceType(Node* instance_type); | 697 Node* IsSequentialStringInstanceType(Node* instance_type); |
696 Node* IsString(Node* object); | 698 Node* IsString(Node* object); |
697 Node* IsJSObject(Node* object); | 699 Node* IsJSObject(Node* object); |
698 Node* IsJSGlobalProxy(Node* object); | 700 Node* IsJSGlobalProxy(Node* object); |
699 Node* IsJSReceiverInstanceType(Node* instance_type); | 701 Node* IsJSReceiverInstanceType(Node* instance_type); |
700 Node* IsJSReceiver(Node* object); | 702 Node* IsJSReceiver(Node* object); |
701 Node* IsJSReceiverMap(Node* map); | 703 Node* IsJSReceiverMap(Node* map); |
702 Node* IsMap(Node* object); | 704 Node* IsMap(Node* object); |
703 Node* IsCallableMap(Node* map); | 705 Node* IsCallableMap(Node* map); |
704 Node* IsDeprecatedMap(Node* map); | 706 Node* IsDeprecatedMap(Node* map); |
(...skipping 26 matching lines...) Expand all Loading... |
731 // Return the single character string with only {code}. | 733 // Return the single character string with only {code}. |
732 Node* StringFromCharCode(Node* code); | 734 Node* StringFromCharCode(Node* code); |
733 // Return a new string object which holds a substring containing the range | 735 // Return a new string object which holds a substring containing the range |
734 // [from,to[ of string. |from| and |to| are expected to be tagged. | 736 // [from,to[ of string. |from| and |to| are expected to be tagged. |
735 Node* SubString(Node* context, Node* string, Node* from, Node* to); | 737 Node* SubString(Node* context, Node* string, Node* from, Node* to); |
736 | 738 |
737 // Return a new string object produced by concatenating |first| with |second|. | 739 // Return a new string object produced by concatenating |first| with |second|. |
738 Node* StringAdd(Node* context, Node* first, Node* second, | 740 Node* StringAdd(Node* context, Node* first, Node* second, |
739 AllocationFlags flags = kNone); | 741 AllocationFlags flags = kNone); |
740 | 742 |
741 // Tries to unpack |string| into a pseudo-sequential string. For instance, | |
742 // In addition to the work done by TryDerefExternalString and | |
743 // MaybeDerefIndirectString, this method can also unpack sliced strings into | |
744 // a (string, offset) pair. The same GC restrictions on the returned string | |
745 // value apply as for TryDerefExternalString. | |
746 void TryUnpackString(Variable* var_string, Variable* var_offset, | |
747 Variable* var_instance_type, Label* if_bailout); | |
748 | |
749 // Unpack the external string, returning a pointer that (offset-wise) looks | 743 // Unpack the external string, returning a pointer that (offset-wise) looks |
750 // like a sequential string. | 744 // like a sequential string. |
751 // Note that this pointer is not tagged and does not point to a real | 745 // Note that this pointer is not tagged and does not point to a real |
752 // sequential string instance, and may only be used to access the string | 746 // sequential string instance, and may only be used to access the string |
753 // data. The pointer is GC-safe as long as a reference to the container | 747 // data. The pointer is GC-safe as long as a reference to the container |
754 // ExternalString is live. | 748 // ExternalString is live. |
755 // |string| must be an external string. Bailout for short external strings. | 749 // |string| must be an external string. Bailout for short external strings. |
756 Node* TryDerefExternalString(Node* const string, Node* const instance_type, | 750 Node* TryDerefExternalString(Node* const string, Node* const instance_type, |
757 Label* if_bailout); | 751 Label* if_bailout); |
758 | 752 |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 private: | 1386 private: |
1393 Node* GetArguments(); | 1387 Node* GetArguments(); |
1394 | 1388 |
1395 CodeStubAssembler* assembler_; | 1389 CodeStubAssembler* assembler_; |
1396 CodeStubAssembler::ParameterMode argc_mode_; | 1390 CodeStubAssembler::ParameterMode argc_mode_; |
1397 Node* argc_; | 1391 Node* argc_; |
1398 Node* arguments_; | 1392 Node* arguments_; |
1399 Node* fp_; | 1393 Node* fp_; |
1400 }; | 1394 }; |
1401 | 1395 |
| 1396 class ToDirectStringAssembler : public CodeStubAssembler { |
| 1397 private: |
| 1398 enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING }; |
| 1399 |
| 1400 public: |
| 1401 explicit ToDirectStringAssembler(compiler::CodeAssemblerState* state, |
| 1402 Node* string); |
| 1403 |
| 1404 // Converts flat cons, thin, and sliced strings and returns the direct |
| 1405 // string. The result can be either a sequential or external string. |
| 1406 Node* TryToDirect(Label* if_bailout); |
| 1407 |
| 1408 // Returns a pointer to the beginning of the string data. |
| 1409 Node* PointerToData(Label* if_bailout) { |
| 1410 return TryToSequential(PTR_TO_DATA, if_bailout); |
| 1411 } |
| 1412 |
| 1413 // Returns a pointer that, offset-wise, looks like a String. |
| 1414 Node* PointerToString(Label* if_bailout) { |
| 1415 return TryToSequential(PTR_TO_STRING, if_bailout); |
| 1416 } |
| 1417 |
| 1418 Node* string() { return var_string_.value(); } |
| 1419 Node* instance_type() { return var_instance_type_.value(); } |
| 1420 Node* offset() { return var_offset_.value(); } |
| 1421 Node* is_external() { return var_is_external_.value(); } |
| 1422 |
| 1423 private: |
| 1424 Node* TryToSequential(StringPointerKind ptr_kind, Label* if_bailout); |
| 1425 |
| 1426 Variable var_string_; |
| 1427 Variable var_instance_type_; |
| 1428 Variable var_offset_; |
| 1429 Variable var_is_external_; |
| 1430 }; |
| 1431 |
1402 #ifdef DEBUG | 1432 #ifdef DEBUG |
1403 #define CSA_ASSERT(csa, x) \ | 1433 #define CSA_ASSERT(csa, x) \ |
1404 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) | 1434 (csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__) |
1405 #define CSA_ASSERT_JS_ARGC_OP(csa, Op, op, expected) \ | 1435 #define CSA_ASSERT_JS_ARGC_OP(csa, Op, op, expected) \ |
1406 (csa)->Assert( \ | 1436 (csa)->Assert( \ |
1407 [&] { \ | 1437 [&] { \ |
1408 const CodeAssemblerState* state = (csa)->state(); \ | 1438 const CodeAssemblerState* state = (csa)->state(); \ |
1409 /* See Linkage::GetJSCallDescriptor(). */ \ | 1439 /* See Linkage::GetJSCallDescriptor(). */ \ |
1410 int argc_index = state->parameter_count() - 2; \ | 1440 int argc_index = state->parameter_count() - 2; \ |
1411 compiler::Node* const argc = (csa)->Parameter(argc_index); \ | 1441 compiler::Node* const argc = (csa)->Parameter(argc_index); \ |
(...skipping 16 matching lines...) Expand all Loading... |
1428 } | 1458 } |
1429 #else | 1459 #else |
1430 #define CSA_SLOW_ASSERT(csa, x) ((void)0) | 1460 #define CSA_SLOW_ASSERT(csa, x) ((void)0) |
1431 #endif | 1461 #endif |
1432 | 1462 |
1433 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1463 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
1434 | 1464 |
1435 } // namespace internal | 1465 } // namespace internal |
1436 } // namespace v8 | 1466 } // namespace v8 |
1437 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1467 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |