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