Commit 0a7d4f49 authored by svenpanne's avatar svenpanne Committed by Commit bot

Added %_NewConsString intrinsic.

No compiler support for now (BTW: %_NewString, doesn't have that,
either), inline allocation will come later. Hopefully the last
intrisic to add for a StringAddStub POC...

Review URL: https://codereview.chromium.org/1041723002

Cr-Commit-Position: refs/heads/master@{#27508}
parent c24ed0a2
......@@ -538,10 +538,30 @@ MaybeHandle<String> Factory::NewConsString(Handle<String> left,
NewRawTwoByteString(length).ToHandleChecked(), left, right);
}
Handle<Map> map = (is_one_byte || is_one_byte_data_in_two_byte_string)
? cons_one_byte_string_map()
: cons_string_map();
Handle<ConsString> result = New<ConsString>(map, NEW_SPACE);
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);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
......
......@@ -196,6 +196,14 @@ class Factory FINAL {
// 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,
......
......@@ -1221,6 +1221,28 @@ RUNTIME_FUNCTION(Runtime_NewString) {
}
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);
......
......@@ -172,6 +172,7 @@ namespace internal {
F(StringToArray, 2, 1) \
F(NewStringWrapper, 1, 1) \
F(NewString, 2, 1) \
F(NewConsString, 4, 1) \
F(TruncateString, 2, 1) \
\
/* Numbers */ \
......
......@@ -63,7 +63,7 @@ TEST(IncrementStatsCounter) {
reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce())
->SetCounterFunction(LookupCounter);
FunctionTester T(
"(function() { %_IncrementStatsCounter(\"" COUNTER_NAME "\"); })", flags);
"(function() { %_IncrementStatsCounter('" COUNTER_NAME "'); })", flags);
StatsCounter counter(T.main_isolate(), COUNTER_NAME);
if (!counter.Enabled()) return;
......@@ -235,6 +235,18 @@ TEST(OneByteSeqStringSetChar) {
}
TEST(NewConsString) {
FLAG_turbo_deoptimization = true;
FunctionTester T(
"(function() { "
" return %_NewConsString(14, true, 'abcdefghi', 'jklmn');"
" })",
flags);
T.CheckCall(T.Val("abcdefghijklmn"));
}
TEST(SetValueOf) {
FLAG_turbo_deoptimization = true;
FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment