NewRawTwoByteString(length).ToHandleChecked(), left, right);
}
- return (is_one_byte || is_one_byte_data_in_two_byte_string)
- ? NewOneByteConsString(length, left, right)
- : NewTwoByteConsString(length, left, right);
-}
-
-
-MaybeHandle<String> Factory::NewOneByteConsString(int length,
- Handle<String> left,
- Handle<String> right) {
- return NewRawConsString(cons_one_byte_string_map(), length, left, right);
-}
-
-
-MaybeHandle<String> Factory::NewTwoByteConsString(int length,
- Handle<String> left,
- Handle<String> right) {
- return NewRawConsString(cons_string_map(), length, left, right);
-}
-
-
-MaybeHandle<String> Factory::NewRawConsString(Handle<Map> map, int length,
- Handle<String> left,
- Handle<String> right) {
- Handle<ConsString> result = New<ConsString>(map, NEW_SPACE);
+ Handle<ConsString> result =
+ (is_one_byte || is_one_byte_data_in_two_byte_string)
+ ? New<ConsString>(cons_one_byte_string_map(), NEW_SPACE)
+ : New<ConsString>(cons_string_map(), NEW_SPACE);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
// Allocates an internalized string in old space based on the character
// stream.
- MUST_USE_RESULT Handle<String> NewInternalizedStringFromUtf8(
- Vector<const char> str,
- int chars,
- uint32_t hash_field);
+ Handle<String> NewInternalizedStringFromUtf8(Vector<const char> str,
+ int chars, uint32_t hash_field);
- MUST_USE_RESULT Handle<String> NewOneByteInternalizedString(
- Vector<const uint8_t> str, uint32_t hash_field);
+ Handle<String> NewOneByteInternalizedString(Vector<const uint8_t> str,
+ uint32_t hash_field);
- MUST_USE_RESULT Handle<String> NewOneByteInternalizedSubString(
+ Handle<String> NewOneByteInternalizedSubString(
Handle<SeqOneByteString> string, int offset, int length,
uint32_t hash_field);
- MUST_USE_RESULT Handle<String> NewTwoByteInternalizedString(
- Vector<const uc16> str,
- uint32_t hash_field);
+ Handle<String> NewTwoByteInternalizedString(Vector<const uc16> str,
+ uint32_t hash_field);
- MUST_USE_RESULT Handle<String> NewInternalizedStringImpl(
- Handle<String> string, int chars, uint32_t hash_field);
+ Handle<String> NewInternalizedStringImpl(Handle<String> string, int chars,
+ uint32_t hash_field);
// Compute the matching internalized string map for a string if possible.
// Empty handle is returned if string is in new space or not flattened.
// Create a new cons string object which consists of a pair of strings.
MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
Handle<String> right);
- MUST_USE_RESULT MaybeHandle<String> NewOneByteConsString(
- int length, Handle<String> left, Handle<String> right);
- MUST_USE_RESULT MaybeHandle<String> NewTwoByteConsString(
- int length, Handle<String> left, Handle<String> right);
- MUST_USE_RESULT MaybeHandle<String> NewRawConsString(Handle<Map> map,
- int length,
- Handle<String> left,
- Handle<String> right);
// Create a new string object which holds a proper substring of a string.
Handle<String> NewProperSubString(Handle<String> str,
}
-RUNTIME_FUNCTION(Runtime_NewConsString) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 4);
- CONVERT_INT32_ARG_CHECKED(length, 0);
- CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1);
- CONVERT_ARG_HANDLE_CHECKED(String, left, 2);
- CONVERT_ARG_HANDLE_CHECKED(String, right, 3);
-
- Handle<String> result;
- if (is_one_byte) {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- isolate->factory()->NewOneByteConsString(length, left, right));
- } else {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- isolate->factory()->NewTwoByteConsString(length, left, right));
- }
- return *result;
-}
-
-
RUNTIME_FUNCTION(Runtime_StringEquals) {
HandleScope handle_scope(isolate);
DCHECK(args.length() == 2);
F(StringTrim, 3, 1) \
F(TruncateString, 2, 1) \
F(NewString, 2, 1) \
- F(NewConsString, 4, 1) \
F(StringEquals, 2, 1) \
F(FlattenString, 1, 1) \
F(StringCharFromCode, 1, 1) \
}
-TEST(NewConsString) {
- FunctionTester T(
- "(function() { "
- " return %_NewConsString(14, true, 'abcdefghi', 'jklmn');"
- " })",
- flags);
-
- T.CheckCall(T.Val("abcdefghijklmn"));
-}
-
-
TEST(SetValueOf) {
FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags);