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

Unified Diff: src/code-stub-assembler.h

Issue 2744263002: [string] Refactor direct string conversions (Closed)
Patch Set: Tweaks Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins/builtins-regexp.cc ('k') | src/code-stub-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.h
diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h
index 538d548af89dcdb07d4eeaf044b8c99a751866ea..5139f402fe3009b5c06d73e55242dc861e5bb699 100644
--- a/src/code-stub-assembler.h
+++ b/src/code-stub-assembler.h
@@ -692,6 +692,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* IsSpecialReceiverInstanceType(Node* instance_type);
Node* IsStringInstanceType(Node* instance_type);
Node* IsOneByteStringInstanceType(Node* instance_type);
+ Node* IsExternalStringInstanceType(Node* instance_type);
+ Node* IsShortExternalStringInstanceType(Node* instance_type);
Node* IsSequentialStringInstanceType(Node* instance_type);
Node* IsString(Node* object);
Node* IsJSObject(Node* object);
@@ -738,14 +740,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* StringAdd(Node* context, Node* first, Node* second,
AllocationFlags flags = kNone);
- // Tries to unpack |string| into a pseudo-sequential string. For instance,
- // In addition to the work done by TryDerefExternalString and
- // MaybeDerefIndirectString, this method can also unpack sliced strings into
- // a (string, offset) pair. The same GC restrictions on the returned string
- // value apply as for TryDerefExternalString.
- void TryUnpackString(Variable* var_string, Variable* var_offset,
- Variable* var_instance_type, Label* if_bailout);
-
// Unpack the external string, returning a pointer that (offset-wise) looks
// like a sequential string.
// Note that this pointer is not tagged and does not point to a real
@@ -1399,6 +1393,42 @@ class CodeStubArguments {
Node* fp_;
};
+class ToDirectStringAssembler : public CodeStubAssembler {
+ private:
+ enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING };
+
+ public:
+ explicit ToDirectStringAssembler(compiler::CodeAssemblerState* state,
+ Node* string);
+
+ // Converts flat cons, thin, and sliced strings and returns the direct
+ // string. The result can be either a sequential or external string.
+ Node* TryToDirect(Label* if_bailout);
+
+ // Returns a pointer to the beginning of the string data.
+ Node* PointerToData(Label* if_bailout) {
+ return TryToSequential(PTR_TO_DATA, if_bailout);
+ }
+
+ // Returns a pointer that, offset-wise, looks like a String.
+ Node* PointerToString(Label* if_bailout) {
+ return TryToSequential(PTR_TO_STRING, if_bailout);
+ }
+
+ Node* string() { return var_string_.value(); }
+ Node* instance_type() { return var_instance_type_.value(); }
+ Node* offset() { return var_offset_.value(); }
+ Node* is_external() { return var_is_external_.value(); }
+
+ private:
+ Node* TryToSequential(StringPointerKind ptr_kind, Label* if_bailout);
+
+ Variable var_string_;
+ Variable var_instance_type_;
+ Variable var_offset_;
+ Variable var_is_external_;
+};
+
#ifdef DEBUG
#define CSA_ASSERT(csa, x) \
(csa)->Assert([&] { return (x); }, #x, __FILE__, __LINE__)
« no previous file with comments | « src/builtins/builtins-regexp.cc ('k') | src/code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698