enum Encoding {
UNKNOWN_ENCODING = 0x1,
TWO_BYTE_ENCODING = 0x0,
- ASCII_ENCODING = 0x4,
+ ASCII_ENCODING = 0x4, // TODO(yangguo): deprecate this.
ONE_BYTE_ENCODING = 0x4
};
/**
NO_OPTIONS = 0,
HINT_MANY_WRITES_EXPECTED = 1,
NO_NULL_TERMINATION = 2,
- PRESERVE_ASCII_NULL = 4,
+ PRESERVE_ASCII_NULL = 4, // TODO(yangguo): deprecate this.
+ PRESERVE_ONE_BYTE_NULL = 4,
// Used by WriteUtf8 to replace orphan surrogate code units with the
// unicode replacement character. Needs to be set to guarantee valid UTF-8
// output.
bool IsExternal() const;
/**
- * Returns true if the string is both external and ASCII
+ * Returns true if the string is both external and one-byte.
*/
- bool IsExternalAscii() const;
+ bool IsExternalOneByte() const;
+
+ // TODO(yangguo): deprecate this.
+ bool IsExternalAscii() const { return IsExternalOneByte(); }
class V8_EXPORT ExternalStringResourceBase { // NOLINT
public:
};
/**
- * An ExternalAsciiStringResource is a wrapper around an ASCII
+ * An ExternalOneByteStringResource is a wrapper around an one-byte
* string buffer that resides outside V8's heap. Implement an
- * ExternalAsciiStringResource to manage the life cycle of the
+ * ExternalOneByteStringResource to manage the life cycle of the
* underlying buffer. Note that the string data must be immutable
- * and that the data must be strict (7-bit) ASCII, not Latin-1 or
- * UTF-8, which would require special treatment internally in the
- * engine and, in the case of UTF-8, do not allow efficient indexing.
- * Use String::New or convert to 16 bit data for non-ASCII.
+ * and that the data must be Latin-1 and not UTF-8, which would require
+ * special treatment internally in the engine and do not allow efficient
+ * indexing. Use String::New or convert to 16 bit data for non-Latin1.
*/
- class V8_EXPORT ExternalAsciiStringResource
+ class V8_EXPORT ExternalOneByteStringResource
: public ExternalStringResourceBase {
public:
/**
* Override the destructor to manage the life cycle of the underlying
* buffer.
*/
- virtual ~ExternalAsciiStringResource() {}
+ virtual ~ExternalOneByteStringResource() {}
/** The string data from the underlying buffer.*/
virtual const char* data() const = 0;
- /** The number of ASCII characters in the string.*/
+ /** The number of Latin-1 characters in the string.*/
virtual size_t length() const = 0;
protected:
- ExternalAsciiStringResource() {}
+ ExternalOneByteStringResource() {}
};
- typedef ExternalAsciiStringResource ExternalOneByteStringResource;
+ typedef ExternalOneByteStringResource ExternalAsciiStringResource;
/**
* If the string is an external string, return the ExternalStringResourceBase
V8_INLINE ExternalStringResource* GetExternalStringResource() const;
/**
- * Get the ExternalAsciiStringResource for an external ASCII string.
- * Returns NULL if IsExternalAscii() doesn't return true.
+ * Get the ExternalOneByteStringResource for an external one-byte string.
+ * Returns NULL if IsExternalOneByte() doesn't return true.
*/
- const ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
+ const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
+
+ // TODO(yangguo): deprecate this.
+ const ExternalAsciiStringResource* GetExternalAsciiStringResource() const {
+ return GetExternalOneByteStringResource();
+ }
V8_INLINE static String* Cast(v8::Value* obj);
bool MakeExternal(ExternalStringResource* resource);
/**
- * Creates a new external string using the ASCII data defined in the given
+ * Creates a new external string using the one-byte data defined in the given
* resource. When the external string is no longer live on V8's heap the
* resource will be disposed by calling its Dispose method. The caller of
* this function should not otherwise delete or modify the resource. Neither
* destructor of the external string resource.
*/
static Local<String> NewExternal(Isolate* isolate,
- ExternalAsciiStringResource* resource);
+ ExternalOneByteStringResource* resource);
/**
* Associate an external string resource with this string by transforming it
* The string is not modified if the operation fails. See NewExternal for
* information on the lifetime of the resource.
*/
- bool MakeExternal(ExternalAsciiStringResource* resource);
+ bool MakeExternal(ExternalOneByteStringResource* resource);
/**
* Returns true if this string can be made external.
// --- Extensions ---
-class V8_EXPORT ExternalAsciiStringResourceImpl
- : public String::ExternalAsciiStringResource {
+class V8_EXPORT ExternalOneByteStringResourceImpl
+ : public String::ExternalOneByteStringResource {
public:
- ExternalAsciiStringResourceImpl() : data_(0), length_(0) {}
- ExternalAsciiStringResourceImpl(const char* data, size_t length)
+ ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
+ ExternalOneByteStringResourceImpl(const char* data, size_t length)
: data_(data), length_(length) {}
const char* data() const { return data_; }
size_t length() const { return length_; }
const char* name() const { return name_; }
size_t source_length() const { return source_length_; }
- const String::ExternalAsciiStringResource* source() const {
+ const String::ExternalOneByteStringResource* source() const {
return &source_; }
int dependency_count() { return dep_count_; }
const char** dependencies() { return deps_; }
private:
const char* name_;
size_t source_length_; // expected to initialize before source_
- ExternalAsciiStringResourceImpl source_;
+ ExternalOneByteStringResourceImpl source_;
int dep_count_;
const char** deps_;
bool auto_enable_;
static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02;
- static const int kExternalAsciiRepresentationTag = 0x06;
+ static const int kExternalOneByteRepresentationTag = 0x06;
static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
static const int kAmountOfExternalAllocatedMemoryOffset =
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
ExternalStringResourceBase* resource = NULL;
- if (type == I::kExternalAsciiRepresentationTag ||
+ if (type == I::kExternalOneByteRepresentationTag ||
type == I::kExternalTwoByteRepresentationTag) {
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
resource = static_cast<ExternalStringResourceBase*>(value);
Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("column_offset")));
+ STATIC_CHAR_VECTOR("column_offset")));
return MakeAccessor(isolate,
name,
&ScriptColumnOffsetGetter,
Handle<AccessorInfo> Accessors::ScriptIdInfo(
Isolate* isolate, PropertyAttributes attributes) {
- Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("id")));
+ Handle<String> name(
+ isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id")));
return MakeAccessor(isolate,
name,
&ScriptIdGetter,
Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("line_offset")));
+ STATIC_CHAR_VECTOR("line_offset")));
return MakeAccessor(isolate,
name,
&ScriptLineOffsetGetter,
Handle<AccessorInfo> Accessors::ScriptTypeInfo(
Isolate* isolate, PropertyAttributes attributes) {
- Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("type")));
+ Handle<String> name(
+ isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type")));
return MakeAccessor(isolate,
name,
&ScriptTypeGetter,
Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("compilation_type")));
+ STATIC_CHAR_VECTOR("compilation_type")));
return MakeAccessor(isolate,
name,
&ScriptCompilationTypeGetter,
Handle<AccessorInfo> Accessors::ScriptLineEndsInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("line_ends")));
+ STATIC_CHAR_VECTOR("line_ends")));
return MakeAccessor(isolate,
name,
&ScriptLineEndsGetter,
Handle<AccessorInfo> Accessors::ScriptContextDataInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("context_data")));
+ STATIC_CHAR_VECTOR("context_data")));
return MakeAccessor(isolate,
name,
&ScriptContextDataGetter,
Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("eval_from_script")));
+ STATIC_CHAR_VECTOR("eval_from_script")));
return MakeAccessor(isolate,
name,
&ScriptEvalFromScriptGetter,
Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("eval_from_script_position")));
+ STATIC_CHAR_VECTOR("eval_from_script_position")));
return MakeAccessor(isolate,
name,
&ScriptEvalFromScriptPositionGetter,
Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("eval_from_function_name")));
+ STATIC_CHAR_VECTOR("eval_from_function_name")));
return MakeAccessor(isolate,
name,
&ScriptEvalFromFunctionNameGetter,
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
i::Handle<i::String> property_name =
isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("displayName"));
+ STATIC_CHAR_VECTOR("displayName"));
i::Handle<i::Object> value =
i::JSObject::GetDataProperty(func, property_name);
void VisitOneByteString(const uint8_t* chars, int length) {
int utf8_length = 0;
- // Add in length 1 for each non-ASCII character.
+ // Add in length 1 for each non-Latin1 character.
for (int i = 0; i < length; i++) {
utf8_length += *chars++ >> 7;
}
// First check that the buffer is large enough.
int utf8_bytes = v8::Utf8Length(*str, str->GetIsolate());
if (utf8_bytes <= capacity) {
- // ASCII fast path.
+ // one-byte fast path.
if (utf8_bytes == string_length) {
WriteOneByte(reinterpret_cast<uint8_t*>(buffer), 0, capacity, options);
if (nchars_ref != NULL) *nchars_ref = string_length;
}
-bool v8::String::IsExternalAscii() const {
+bool v8::String::IsExternalOneByte() const {
i::Handle<i::String> str = Utils::OpenHandle(this);
- return i::StringShape(*str).IsExternalAscii();
+ return i::StringShape(*str).IsExternalOneByte();
}
i::Handle<i::String> str = Utils::OpenHandle(this);
const v8::String::ExternalStringResourceBase* expected;
Encoding expectedEncoding;
- if (i::StringShape(*str).IsExternalAscii()) {
+ if (i::StringShape(*str).IsExternalOneByte()) {
const void* resource =
- i::Handle<i::ExternalAsciiString>::cast(str)->resource();
+ i::Handle<i::ExternalOneByteString>::cast(str)->resource();
expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
- expectedEncoding = ASCII_ENCODING;
+ expectedEncoding = ONE_BYTE_ENCODING;
} else if (i::StringShape(*str).IsExternalTwoByte()) {
const void* resource =
i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
expectedEncoding = TWO_BYTE_ENCODING;
} else {
expected = NULL;
- expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
- : TWO_BYTE_ENCODING;
+ expectedEncoding =
+ str->IsOneByteRepresentation() ? ONE_BYTE_ENCODING : TWO_BYTE_ENCODING;
}
CHECK_EQ(expected, value);
CHECK_EQ(expectedEncoding, encoding);
}
-const v8::String::ExternalAsciiStringResource*
-v8::String::GetExternalAsciiStringResource() const {
+const v8::String::ExternalOneByteStringResource*
+v8::String::GetExternalOneByteStringResource() const {
i::Handle<i::String> str = Utils::OpenHandle(this);
- if (i::StringShape(*str).IsExternalAscii()) {
+ if (i::StringShape(*str).IsExternalOneByte()) {
const void* resource =
- i::Handle<i::ExternalAsciiString>::cast(str)->resource();
- return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
+ i::Handle<i::ExternalOneByteString>::cast(str)->resource();
+ return reinterpret_cast<const ExternalOneByteStringResource*>(resource);
} else {
return NULL;
}
}
-static i::Handle<i::String> NewExternalAsciiStringHandle(
- i::Isolate* isolate,
- v8::String::ExternalAsciiStringResource* resource) {
+static i::Handle<i::String> NewExternalOneByteStringHandle(
+ i::Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
// We do not expect this to fail. Change this if it does.
- return isolate->factory()->NewExternalStringFromAscii(
- resource).ToHandleChecked();
+ return isolate->factory()
+ ->NewExternalStringFromOneByte(resource)
+ .ToHandleChecked();
}
Local<String> v8::String::NewExternal(
- Isolate* isolate,
- v8::String::ExternalAsciiStringResource* resource) {
+ Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
LOG_API(i_isolate, "String::NewExternal");
ENTER_V8(i_isolate);
CHECK(resource && resource->data());
i::Handle<i::String> result =
- NewExternalAsciiStringHandle(i_isolate, resource);
+ NewExternalOneByteStringHandle(i_isolate, resource);
i_isolate->heap()->external_string_table()->AddString(*result);
return Utils::ToLocal(result);
}
bool v8::String::MakeExternal(
- v8::String::ExternalAsciiStringResource* resource) {
+ v8::String::ExternalOneByteStringResource* resource) {
i::Handle<i::String> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
if (i::StringShape(*obj).IsExternal()) {
i::Handle<i::JSObject> debug(
isolate_debug->debug_context()->global_object());
i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("MakeMirror"));
+ STATIC_CHAR_VECTOR("MakeMirror"));
i::Handle<i::Object> fun_obj =
i::Object::GetProperty(debug, name).ToHandleChecked();
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
masm, lhs, rhs, &flat_string_check, &slow);
}
- // Check for both being sequential ASCII strings, and inline if that is the
- // case.
+ // Check for both being sequential one-byte strings,
+ // and inline if that is the case.
__ bind(&flat_string_check);
- __ JumpIfNonSmisNotBothSequentialAsciiStrings(lhs, rhs, r2, r3, &slow);
+ __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, r2, r3, &slow);
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r2,
r3);
if (cc == eq) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, r2, r3, r4);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, r2, r3, r4);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, r2, r3, r4,
- r5);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, r2, r3, r4,
+ r5);
}
// Never falls through to here.
STATIC_ASSERT(kTwoByteStringTag == 0);
__ and_(r0, r0, Operand(kStringEncodingMask));
__ mov(r3, Operand(r0, ASR, 2), SetCC);
- __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne);
+ __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset),
+ ne);
__ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq);
// (E) Carry on. String handling is done.
__ JumpIfSmi(r6, &runtime);
// r1: previous index
- // r3: encoding of subject string (1 if ASCII, 0 if two_byte);
+ // r3: encoding of subject string (1 if one_byte, 0 if two_byte);
// r6: code
// subject: Subject string
// regexp_data: RegExp data (FixedArray)
__ str(r0, MemOperand(sp, 1 * kPointerSize));
// For arguments 4 and 3 get string length, calculate start of string data and
- // calculate the shift of the index (0 for ASCII and 1 for two byte).
+ // calculate the shift of the index (0 for one-byte and 1 for two-byte).
__ add(r7, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag));
__ eor(r3, r3, Operand(1));
// Load the length from the original subject string from the previous stack
// StringCharCodeAtGenerator
void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
- Label flat_string;
- Label ascii_string;
- Label got_char_code;
- Label sliced_string;
-
// If the receiver is a smi trigger the non-string case.
__ JumpIfSmi(object_, receiver_not_string_);
__ b(ne, &slow_case_);
__ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex);
- // At this point code register contains smi tagged ASCII char code.
+ // At this point code register contains smi tagged one-byte char code.
__ add(result_, result_, Operand::PointerOffsetFromSmiKey(code_));
__ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize));
__ CompareRoot(result_, Heap::kUndefinedValueRootIndex);
}
-enum CopyCharactersFlags {
- COPY_ASCII = 1,
- DEST_ALWAYS_ALIGNED = 2
-};
+enum CopyCharactersFlags { COPY_ONE_BYTE = 1, DEST_ALWAYS_ALIGNED = 2 };
void StringHelper::GenerateCopyCharacters(MacroAssembler* masm,
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ tst(r1, Operand(kStringEncodingMask));
__ b(eq, &two_byte_slice);
- __ AllocateAsciiSlicedString(r0, r2, r6, r4, &runtime);
+ __ AllocateOneByteSlicedString(r0, r2, r6, r4, &runtime);
__ jmp(&set_slice_header);
__ bind(&two_byte_slice);
__ AllocateTwoByteSlicedString(r0, r2, r6, r4, &runtime);
__ tst(r1, Operand(kStringEncodingMask));
__ b(eq, &two_byte_sequential);
- // Allocate and copy the resulting ASCII string.
- __ AllocateAsciiString(r0, r2, r4, r6, r1, &runtime);
+ // Allocate and copy the resulting one-byte string.
+ __ AllocateOneByteString(r0, r2, r4, r6, r1, &runtime);
// Locate first character of substring to copy.
__ add(r5, r5, r3);
}
-void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left, Register right,
- Register scratch1,
- Register scratch2,
- Register scratch3) {
+void StringHelper::GenerateFlatOneByteStringEquals(
+ MacroAssembler* masm, Register left, Register right, Register scratch1,
+ Register scratch2, Register scratch3) {
Register length = scratch1;
// Compare lengths.
// Compare characters.
__ bind(&compare_chars);
- GenerateAsciiCharsCompareLoop(masm,
- left, right, length, scratch2, scratch3,
- &strings_not_equal);
+ GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, scratch3,
+ &strings_not_equal);
// Characters are equal.
__ mov(r0, Operand(Smi::FromInt(EQUAL)));
}
-void StringHelper::GenerateCompareFlatAsciiStrings(
+void StringHelper::GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3, Register scratch4) {
Label result_not_equal, compare_lengths;
__ b(eq, &compare_lengths);
// Compare loop.
- GenerateAsciiCharsCompareLoop(masm,
- left, right, min_length, scratch2, scratch4,
- &result_not_equal);
+ GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2,
+ scratch4, &result_not_equal);
// Compare lengths - strings up to min-length are equal.
__ bind(&compare_lengths);
}
-void StringHelper::GenerateAsciiCharsCompareLoop(
+void StringHelper::GenerateOneByteCharsCompareLoop(
MacroAssembler* masm, Register left, Register right, Register length,
Register scratch1, Register scratch2, Label* chars_not_equal) {
// Change index to run from -length to -1 by adding length to string
__ bind(¬_same);
- // Check that both objects are sequential ASCII strings.
- __ JumpIfNotBothSequentialAsciiStrings(r1, r0, r2, r3, &runtime);
+ // Check that both objects are sequential one-byte strings.
+ __ JumpIfNotBothSequentialOneByteStrings(r1, r0, r2, r3, &runtime);
- // Compare flat ASCII strings natively. Remove arguments from stack first.
+ // Compare flat one-byte strings natively. Remove arguments from stack first.
__ IncrementCounter(counters->string_compare_native(), 1, r2, r3);
__ add(sp, sp, Operand(2 * kPointerSize));
- StringHelper::GenerateCompareFlatAsciiStrings(masm, r1, r0, r2, r3, r4, r5);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, r1, r0, r2, r3, r4, r5);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ Ret(eq);
}
- // Check that both strings are sequential ASCII.
+ // Check that both strings are sequential one-byte.
Label runtime;
- __ JumpIfBothInstanceTypesAreNotSequentialAscii(
- tmp1, tmp2, tmp3, tmp4, &runtime);
+ __ JumpIfBothInstanceTypesAreNotSequentialOneByte(tmp1, tmp2, tmp3, tmp4,
+ &runtime);
- // Compare flat ASCII strings. Returns when done.
+ // Compare flat one-byte strings. Returns when done.
if (equality) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2,
- tmp3);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1, tmp2,
+ tmp3);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
- tmp3, tmp4);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1,
+ tmp2, tmp3, tmp4);
}
// Handle more complex cases in runtime.
Register scratch,
String::Encoding encoding);
- // Compares two flat ASCII strings and returns result in r0.
- static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
- Register left,
- Register right,
+ // Compares two flat one-byte strings and returns result in r0.
+ static void GenerateCompareFlatOneByteStrings(
+ MacroAssembler* masm, Register left, Register right, Register scratch1,
+ Register scratch2, Register scratch3, Register scratch4);
+
+ // Compares two flat one-byte strings for equality and returns result in r0.
+ static void GenerateFlatOneByteStringEquals(MacroAssembler* masm,
+ Register left, Register right,
Register scratch1,
Register scratch2,
- Register scratch3,
- Register scratch4);
-
- // Compares two flat ASCII strings for equality and returns result in r0.
- static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left,
- Register right,
- Register scratch1,
- Register scratch2,
- Register scratch3);
+ Register scratch3);
private:
- static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
- Register left,
- Register right,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* chars_not_equal);
+ static void GenerateOneByteCharsCompareLoop(
+ MacroAssembler* masm, Register left, Register right, Register length,
+ Register scratch1, Register scratch2, Label* chars_not_equal);
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
};
__ b(ne, call_runtime);
__ ldr(string, FieldMemOperand(string, ExternalString::kResourceDataOffset));
- Label ascii, done;
+ Label one_byte, done;
__ bind(&check_encoding);
STATIC_ASSERT(kTwoByteStringTag == 0);
__ tst(result, Operand(kStringEncodingMask));
- __ b(ne, &ascii);
+ __ b(ne, &one_byte);
// Two-byte string.
__ ldrh(result, MemOperand(string, index, LSL, 1));
__ jmp(&done);
- __ bind(&ascii);
- // Ascii string.
+ __ bind(&one_byte);
+ // One-byte string.
__ ldrb(result, MemOperand(string, index));
__ bind(&done);
}
}
-void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
+void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
Label bailout, done, one_char_separator, long_separator, non_trivial_array,
not_size_one_array, loop, empty_separator_loop, one_char_separator_loop,
one_char_separator_loop_entry, long_separator_loop;
__ ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset));
array = no_reg; // End of array's live range.
- // Check that all array elements are sequential ASCII strings, and
+ // Check that all array elements are sequential one-byte strings, and
// accumulate the sum of their lengths, as a smi-encoded value.
__ mov(string_length, Operand::Zero());
__ add(element,
// elements_end: Array end.
if (generate_debug_code_) {
__ cmp(array_length, Operand::Zero());
- __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin);
+ __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin);
}
__ bind(&loop);
__ ldr(string, MemOperand(element, kPointerSize, PostIndex));
__ JumpIfSmi(string, &bailout);
__ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
__ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
- __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout);
+ __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch, scratch, &bailout);
__ ldr(scratch, FieldMemOperand(string, SeqOneByteString::kLengthOffset));
__ add(string_length, string_length, Operand(scratch), SetCC);
__ b(vs, &bailout);
// string_length: Sum of string lengths (smi).
// elements: FixedArray of strings.
- // Check that the separator is a flat ASCII string.
+ // Check that the separator is a flat one-byte string.
__ JumpIfSmi(separator, &bailout);
__ ldr(scratch, FieldMemOperand(separator, HeapObject::kMapOffset));
__ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
- __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout);
+ __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch, scratch, &bailout);
// Add (separator length times array_length) - separator length to the
// string_length to get the length of the result string. array_length is not
// separator: Separator string
// string_length: Length of result string (not smi)
// array_length: Length of the array.
- __ AllocateAsciiString(result,
- string_length,
- scratch,
- string, // used as scratch
- elements_end, // used as scratch
- &bailout);
+ __ AllocateOneByteString(result, string_length, scratch,
+ string, // used as scratch
+ elements_end, // used as scratch
+ &bailout);
// Prepare for looping. Set up elements_end to end of the array. Set
// result_pos to the position of the result where to write the first
// character.
// One-character separator case
__ bind(&one_char_separator);
- // Replace separator with its ASCII character value.
+ // Replace separator with its one-byte character value.
__ ldrb(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize));
// Jump into the loop after the code that copies the separator, so the first
// element is not preceded by a separator
// result_pos: the position to which we are currently copying characters.
// element: Current array element.
// elements_end: Array end.
- // separator: Single separator ASCII char (in lower byte).
+ // separator: Single separator one-byte char (in lower byte).
// Copy the separator character to the result.
__ strb(separator, MemOperand(result_pos, 1, PostIndex));
// Objects with a non-function constructor have class 'Object'.
__ CompareObjectType(temp, temp2, temp2, JS_FUNCTION_TYPE);
- if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Object"))) {
+ if (class_name->IsOneByteEqualTo(STATIC_CHAR_VECTOR("Object"))) {
__ b(ne, is_true);
} else {
__ b(ne, is_false);
}
-void MacroAssembler::AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3,
+ Label* gc_required) {
// Calculate the number of bytes needed for the characters in the string while
// observing object alignment.
DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0);
Operand(kObjectAlignmentMask + SeqOneByteString::kHeaderSize));
and_(scratch1, scratch1, Operand(~kObjectAlignmentMask));
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(scratch1,
result,
scratch2,
TAG_OBJECT);
// Set the map, length and hash field.
- InitializeNewString(result,
- length,
- Heap::kAsciiStringMapRootIndex,
- scratch1,
- scratch2);
+ InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex,
+ scratch1, scratch2);
}
}
-void MacroAssembler::AllocateAsciiConsString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteConsString(Register result, Register length,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
Allocate(ConsString::kSize,
result,
scratch1,
gc_required,
TAG_OBJECT);
- InitializeNewString(result,
- length,
- Heap::kConsAsciiStringMapRootIndex,
- scratch1,
- scratch2);
+ InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex,
+ scratch1, scratch2);
}
}
-void MacroAssembler::AllocateAsciiSlicedString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteSlicedString(Register result,
+ Register length,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
TAG_OBJECT);
- InitializeNewString(result,
- length,
- Heap::kSlicedAsciiStringMapRootIndex,
- scratch1,
- scratch2);
+ InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex,
+ scratch1, scratch2);
}
}
-void MacroAssembler::JumpIfNonSmisNotBothSequentialAsciiStrings(
- Register first,
- Register second,
- Register scratch1,
- Register scratch2,
+void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings(
+ Register first, Register second, Register scratch1, Register scratch2,
Label* failure) {
- // Test that both first and second are sequential ASCII strings.
+ // Test that both first and second are sequential one-byte strings.
// Assume that they are non-smis.
ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset));
ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset));
ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
ldrb(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset));
- JumpIfBothInstanceTypesAreNotSequentialAscii(scratch1,
- scratch2,
- scratch1,
- scratch2,
- failure);
+ JumpIfBothInstanceTypesAreNotSequentialOneByte(scratch1, scratch2, scratch1,
+ scratch2, failure);
}
-void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register first,
- Register second,
- Register scratch1,
- Register scratch2,
- Label* failure) {
+void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register first,
+ Register second,
+ Register scratch1,
+ Register scratch2,
+ Label* failure) {
// Check that neither is a smi.
and_(scratch1, first, Operand(second));
JumpIfSmi(scratch1, failure);
- JumpIfNonSmisNotBothSequentialAsciiStrings(first,
- second,
- scratch1,
- scratch2,
- failure);
+ JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1,
+ scratch2, failure);
}
}
-void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialAscii(
- Register first,
- Register second,
- Register scratch1,
- Register scratch2,
+void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte(
+ Register first, Register second, Register scratch1, Register scratch2,
Label* failure) {
- const int kFlatAsciiStringMask =
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
- and_(scratch1, first, Operand(kFlatAsciiStringMask));
- and_(scratch2, second, Operand(kFlatAsciiStringMask));
- cmp(scratch1, Operand(kFlatAsciiStringTag));
+ and_(scratch1, first, Operand(kFlatOneByteStringMask));
+ and_(scratch2, second, Operand(kFlatOneByteStringMask));
+ cmp(scratch1, Operand(kFlatOneByteStringTag));
// Ignore second test if first test failed.
- cmp(scratch2, Operand(kFlatAsciiStringTag), eq);
+ cmp(scratch2, Operand(kFlatOneByteStringTag), eq);
b(ne, failure);
}
-void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(Register type,
- Register scratch,
- Label* failure) {
- const int kFlatAsciiStringMask =
+void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(Register type,
+ Register scratch,
+ Label* failure) {
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
- and_(scratch, type, Operand(kFlatAsciiStringMask));
- cmp(scratch, Operand(kFlatAsciiStringTag));
+ and_(scratch, type, Operand(kFlatOneByteStringMask));
+ cmp(scratch, Operand(kFlatOneByteStringTag));
b(ne, failure);
}
mov(length, Operand(ExternalString::kSize), LeaveCC, ne);
b(ne, &is_data_object);
- // Sequential string, either ASCII or UC16.
- // For ASCII (char-size of 1) we shift the smi tag away to get the length.
+ // Sequential string, either Latin1 or UC16.
+ // For Latin1 (char-size of 1) we shift the smi tag away to get the length.
// For UC16 (char-size of 2) we just leave the smi tag in place, thereby
// getting the length multiplied by 2.
DCHECK(kOneByteStringTag == 4 && kStringEncodingMask == 4);
Register scratch2,
Register scratch3,
Label* gc_required);
- void AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required);
+ void AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3, Label* gc_required);
void AllocateTwoByteConsString(Register result,
Register length,
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiConsString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteConsString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Label* gc_required);
void AllocateTwoByteSlicedString(Register result,
Register length,
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiSlicedString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteSlicedString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Label* gc_required);
// Allocates a heap number or jumps to the gc_required label if the young
// space is full and a scavenge is needed. All registers are clobbered also
Register scratch3,
Label* not_found);
- // Checks if both objects are sequential ASCII strings and jumps to label
+ // Checks if both objects are sequential one-byte strings and jumps to label
// if either is not. Assumes that neither object is a smi.
- void JumpIfNonSmisNotBothSequentialAsciiStrings(Register object1,
- Register object2,
- Register scratch1,
- Register scratch2,
- Label* failure);
+ void JumpIfNonSmisNotBothSequentialOneByteStrings(Register object1,
+ Register object2,
+ Register scratch1,
+ Register scratch2,
+ Label* failure);
- // Checks if both objects are sequential ASCII strings and jumps to label
+ // Checks if both objects are sequential one-byte strings and jumps to label
// if either is not.
- void JumpIfNotBothSequentialAsciiStrings(Register first,
- Register second,
- Register scratch1,
- Register scratch2,
- Label* not_flat_ascii_strings);
+ void JumpIfNotBothSequentialOneByteStrings(Register first, Register second,
+ Register scratch1,
+ Register scratch2,
+ Label* not_flat_one_byte_strings);
- // Checks if both instance types are sequential ASCII strings and jumps to
+ // Checks if both instance types are sequential one-byte strings and jumps to
// label if either is not.
- void JumpIfBothInstanceTypesAreNotSequentialAscii(
- Register first_object_instance_type,
- Register second_object_instance_type,
- Register scratch1,
- Register scratch2,
- Label* failure);
-
- // Check if instance type is sequential ASCII string and jump to label if
+ void JumpIfBothInstanceTypesAreNotSequentialOneByte(
+ Register first_object_instance_type, Register second_object_instance_type,
+ Register scratch1, Register scratch2, Label* failure);
+
+ // Check if instance type is sequential one-byte string and jump to label if
// it is not.
- void JumpIfInstanceTypeIsNotSequentialAscii(Register type,
- Register scratch,
- Label* failure);
+ void JumpIfInstanceTypeIsNotSequentialOneByte(Register type, Register scratch,
+ Label* failure);
void JumpIfNotUniqueName(Register reg, Label* not_unique_name);
__ cmn(r1, Operand(current_input_offset()));
BranchOrBacktrack(gt, on_no_match);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
Label success;
Label fail;
Label loop_check;
Label loop;
__ bind(&loop);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
__ ldrb(r3, MemOperand(r0, char_size(), PostIndex));
__ ldrb(r4, MemOperand(r2, char_size(), PostIndex));
} else {
Handle<ByteArray> table,
Label* on_bit_set) {
__ mov(r0, Operand(table));
- if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) {
+ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) {
__ and_(r1, current_character(), Operand(kTableSize - 1));
__ add(r1, r1, Operand(ByteArray::kHeaderSize - kHeapObjectTag));
} else {
switch (type) {
case 's':
// Match space-characters
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
Label success;
__ cmp(current_character(), Operand(' '));
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c
__ sub(r0, r0, Operand(0x0b));
__ cmp(r0, Operand(0x0c - 0x0b));
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
BranchOrBacktrack(hi, on_no_match);
} else {
Label done;
return true;
}
case 'w': {
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ cmp(current_character(), Operand('z'));
BranchOrBacktrack(hi, on_no_match);
}
}
case 'W': {
Label done;
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ cmp(current_character(), Operand('z'));
__ b(hi, &done);
}
__ ldrb(r0, MemOperand(r0, current_character()));
__ cmp(r0, Operand::Zero());
BranchOrBacktrack(ne, on_no_match);
- if (mode_ != ASCII) {
+ if (mode_ != LATIN1) {
__ bind(&done);
}
return true;
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
- bool is_ascii = subject->IsOneByteRepresentationUnderneath();
+ bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
DCHECK(re_code->instruction_start() <= *return_address);
DCHECK(*return_address <=
}
// String might have changed.
- if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
- // If we changed between an ASCII and an UC16 string, the specialized
+ if (subject_tmp->IsOneByteRepresentation() != is_one_byte) {
+ // If we changed between an Latin1 and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).
return RETRY;
DCHECK(characters == 1);
}
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
if (characters == 4) {
__ ldr(current_character(), MemOperand(end_of_input_address(), offset));
} else if (characters == 2) {
MacroAssembler* masm_;
- // Which mode to generate code for (ASCII or UC16).
+ // Which mode to generate code for (Latin1 or UC16).
Mode mode_;
// One greater than maximal register index actually used.
&flat_string_check, &slow);
}
- // Check for both being sequential ASCII strings, and inline if that is the
- // case.
+ // Check for both being sequential one-byte strings,
+ // and inline if that is the case.
__ Bind(&flat_string_check);
- __ JumpIfBothInstanceTypesAreNotSequentialAscii(lhs_type, rhs_type, x14,
- x15, &slow);
+ __ JumpIfBothInstanceTypesAreNotSequentialOneByte(lhs_type, rhs_type, x14,
+ x15, &slow);
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1, x10,
x11);
if (cond == eq) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, x10, x11, x12);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, x10, x11,
+ x12);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, x10, x11, x12,
- x13);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, x10, x11,
+ x12, x13);
}
// Never fall through to here.
// w0 string_type type of subject string
// x2 jsstring_length subject string length
// x3 jsregexp_object JSRegExp object
- // w4 string_encoding ASCII or UC16
+ // w4 string_encoding Latin1 or UC16
// w5 sliced_string_offset if the string is a SlicedString
// offset to the underlying string
// w6 string_representation groups attributes of the string:
STATIC_ASSERT(kStringEncodingMask == 0x04);
// Find the code object based on the assumptions above.
- // kDataAsciiCodeOffset and kDataUC16CodeOffset are adjacent, adds an offset
+ // kDataOneByteCodeOffset and kDataUC16CodeOffset are adjacent, adds an offset
// of kPointerSize to reach the latter.
- DCHECK_EQ(JSRegExp::kDataAsciiCodeOffset + kPointerSize,
+ DCHECK_EQ(JSRegExp::kDataOneByteCodeOffset + kPointerSize,
JSRegExp::kDataUC16CodeOffset);
__ Mov(x10, kPointerSize);
- // We will need the encoding later: ASCII = 0x04
- // UC16 = 0x00
+ // We will need the encoding later: Latin1 = 0x04
+ // UC16 = 0x00
__ Ands(string_encoding, string_type, kStringEncodingMask);
__ CzeroX(x10, ne);
__ Add(x10, regexp_data, x10);
- __ Ldr(code_object, FieldMemOperand(x10, JSRegExp::kDataAsciiCodeOffset));
+ __ Ldr(code_object, FieldMemOperand(x10, JSRegExp::kDataOneByteCodeOffset));
// (E) Carry on. String handling is done.
__ Ldr(length, UntagSmiFieldMemOperand(subject, String::kLengthOffset));
// Handle UC16 encoding, two bytes make one character.
- // string_encoding: if ASCII: 0x04
- // if UC16: 0x00
+ // string_encoding: if Latin1: 0x04
+ // if UC16: 0x00
STATIC_ASSERT(kStringEncodingMask == 0x04);
__ Ubfx(string_encoding, string_encoding, 2, 1);
__ Eor(string_encoding, string_encoding, 1);
- // string_encoding: if ASCII: 0
- // if UC16: 1
+ // string_encoding: if Latin1: 0
+ // if UC16: 1
// Convert string positions from characters to bytes.
// Previous index is in x1.
__ B(hi, &slow_case_);
__ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex);
- // At this point code register contains smi tagged ASCII char code.
+ // At this point code register contains smi tagged one-byte char code.
__ Add(result_, result_, Operand::UntagSmiAndScale(code_, kPointerSizeLog2));
__ Ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize));
__ JumpIfRoot(result_, Heap::kUndefinedValueRootIndex, &slow_case_);
__ Bind(¬_internalized_strings);
}
- // Check that both strings are sequential ASCII.
+ // Check that both strings are sequential one-byte.
Label runtime;
- __ JumpIfBothInstanceTypesAreNotSequentialAscii(
- lhs_type, rhs_type, x12, x13, &runtime);
+ __ JumpIfBothInstanceTypesAreNotSequentialOneByte(lhs_type, rhs_type, x12,
+ x13, &runtime);
- // Compare flat ASCII strings. Returns when done.
+ // Compare flat one-byte strings. Returns when done.
if (equality) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, x10, x11, x12);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, x10, x11,
+ x12);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, x10, x11, x12,
- x13);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, x10, x11,
+ x12, x13);
}
// Handle more complex cases in runtime.
STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0);
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ Tbz(input_type, MaskToBit(kStringEncodingMask), &two_byte_slice);
- __ AllocateAsciiSlicedString(result_string, result_length, x3, x4,
- &runtime);
+ __ AllocateOneByteSlicedString(result_string, result_length, x3, x4,
+ &runtime);
__ B(&set_slice_header);
__ Bind(&two_byte_slice);
SeqOneByteString::kHeaderSize - kHeapObjectTag);
__ Bind(&allocate_result);
- // Sequential ASCII string. Allocate the result.
+ // Sequential one-byte string. Allocate the result.
STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0);
__ Tbz(input_type, MaskToBit(kStringEncodingMask), &two_byte_sequential);
- // Allocate and copy the resulting ASCII string.
- __ AllocateAsciiString(result_string, result_length, x3, x4, x5, &runtime);
+ // Allocate and copy the resulting one-byte string.
+ __ AllocateOneByteString(result_string, result_length, x3, x4, x5, &runtime);
// Locate first character of substring to copy.
__ Add(substring_char0, unpacked_char0, from);
}
-void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left, Register right,
- Register scratch1,
- Register scratch2,
- Register scratch3) {
+void StringHelper::GenerateFlatOneByteStringEquals(
+ MacroAssembler* masm, Register left, Register right, Register scratch1,
+ Register scratch2, Register scratch3) {
DCHECK(!AreAliased(left, right, scratch1, scratch2, scratch3));
Register result = x0;
Register left_length = scratch1;
// Compare characters. Falls through if all characters are equal.
__ Bind(&compare_chars);
- GenerateAsciiCharsCompareLoop(masm, left, right, left_length, scratch2,
- scratch3, &strings_not_equal);
+ GenerateOneByteCharsCompareLoop(masm, left, right, left_length, scratch2,
+ scratch3, &strings_not_equal);
// Characters in strings are equal.
__ Mov(result, Smi::FromInt(EQUAL));
}
-void StringHelper::GenerateCompareFlatAsciiStrings(
+void StringHelper::GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3, Register scratch4) {
DCHECK(!AreAliased(left, right, scratch1, scratch2, scratch3, scratch4));
__ Cbz(min_length, &compare_lengths);
// Compare loop.
- GenerateAsciiCharsCompareLoop(masm,
- left, right, min_length, scratch2, scratch4,
- &result_not_equal);
+ GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2,
+ scratch4, &result_not_equal);
// Compare lengths - strings up to min-length are equal.
__ Bind(&compare_lengths);
}
-void StringHelper::GenerateAsciiCharsCompareLoop(
+void StringHelper::GenerateOneByteCharsCompareLoop(
MacroAssembler* masm, Register left, Register right, Register length,
Register scratch1, Register scratch2, Label* chars_not_equal) {
DCHECK(!AreAliased(left, right, length, scratch1, scratch2));
__ Bind(¬_same);
- // Check that both objects are sequential ASCII strings.
- __ JumpIfEitherIsNotSequentialAsciiStrings(left, right, x12, x13, &runtime);
+ // Check that both objects are sequential one-byte strings.
+ __ JumpIfEitherIsNotSequentialOneByteStrings(left, right, x12, x13, &runtime);
- // Compare flat ASCII strings natively. Remove arguments from stack first,
+ // Compare flat one-byte strings natively. Remove arguments from stack first,
// as this function will generate a return.
__ IncrementCounter(counters->string_compare_native(), 1, x3, x4);
- StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, x12, x13,
- x14, x15);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, x12, x13,
+ x14, x15);
__ Bind(&runtime);
class StringHelper : public AllStatic {
public:
- // Compares two flat ASCII strings and returns result in x0.
- static void GenerateCompareFlatAsciiStrings(
+ // Compares two flat one-byte strings and returns result in x0.
+ static void GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3, Register scratch4);
- // Compare two flat ASCII strings for equality and returns result in x0.
- static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, Register left,
- Register right, Register scratch1,
- Register scratch2,
- Register scratch3);
+ // Compare two flat one-byte strings for equality and returns result in x0.
+ static void GenerateFlatOneByteStringEquals(MacroAssembler* masm,
+ Register left, Register right,
+ Register scratch1,
+ Register scratch2,
+ Register scratch3);
private:
- static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, Register left,
- Register right, Register length,
- Register scratch1,
- Register scratch2,
- Label* chars_not_equal);
+ static void GenerateOneByteCharsCompareLoop(
+ MacroAssembler* masm, Register left, Register right, Register length,
+ Register scratch1, Register scratch2, Label* chars_not_equal);
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
};
__ B(ne, call_runtime);
__ Ldr(string, FieldMemOperand(string, ExternalString::kResourceDataOffset));
- Label ascii, done;
+ Label one_byte, done;
__ Bind(&check_encoding);
STATIC_ASSERT(kTwoByteStringTag == 0);
- __ TestAndBranchIfAnySet(result, kStringEncodingMask, &ascii);
+ __ TestAndBranchIfAnySet(result, kStringEncodingMask, &one_byte);
// Two-byte string.
__ Ldrh(result, MemOperand(string, index, SXTW, 1));
__ B(&done);
- __ Bind(&ascii);
- // Ascii string.
+ __ Bind(&one_byte);
+ // One-byte string.
__ Ldrb(result, MemOperand(string, index, SXTW));
__ Bind(&done);
}
}
-void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
- ASM_LOCATION("FullCodeGenerator::EmitFastAsciiArrayJoin");
+void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
+ ASM_LOCATION("FullCodeGenerator::EmitFastOneByteArrayJoin");
ZoneList<Expression*>* args = expr->arguments();
DCHECK(args->length() == 2);
// Get the FixedArray containing array's elements.
__ Ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset));
- // Check that all array elements are sequential ASCII strings, and
+ // Check that all array elements are sequential one-byte strings, and
// accumulate the sum of their lengths.
__ Mov(string_length, 0);
__ Add(element, elements, FixedArray::kHeaderSize - kHeapObjectTag);
// elements_end: Array end.
if (FLAG_debug_code) {
__ Cmp(array_length, 0);
- __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin);
+ __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin);
}
__ Bind(&loop);
__ Ldr(string, MemOperand(element, kPointerSize, PostIndex));
__ JumpIfSmi(string, &bailout);
__ Ldr(scratch1, FieldMemOperand(string, HeapObject::kMapOffset));
__ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
- __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout);
+ __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout);
__ Ldrsw(scratch1,
UntagSmiFieldMemOperand(string, SeqOneByteString::kLengthOffset));
__ Adds(string_length, string_length, scratch1);
// string_length: Sum of string lengths (not smi).
// elements: FixedArray of strings.
- // Check that the separator is a flat ASCII string.
+ // Check that the separator is a flat one-byte string.
__ JumpIfSmi(separator, &bailout);
__ Ldr(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset));
__ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
- __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout);
+ __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout);
// Add (separator length times array_length) - separator length to the
// string_length to get the length of the result string.
// separator: Separator string
// string_length: Length of result string (not smi)
// array_length: Length of the array (not smi).
- __ AllocateAsciiString(result, string_length, scratch1, scratch2, scratch3,
- &bailout);
+ __ AllocateOneByteString(result, string_length, scratch1, scratch2, scratch3,
+ &bailout);
// Prepare for looping. Set up elements_end to end of the array. Set
// result_pos to the position of the result where to write the first
// character.
- // TODO(all): useless unless AllocateAsciiString trashes the register.
+ // TODO(all): useless unless AllocateOneByteString trashes the register.
__ Add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2));
__ Add(result_pos, result, SeqOneByteString::kHeaderSize - kHeapObjectTag);
// One-character separator case
__ Bind(&one_char_separator);
- // Replace separator with its ASCII character value.
+ // Replace separator with its one-byte character value.
__ Ldrb(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize));
// Jump into the loop after the code that copies the separator, so the first
// element is not preceded by a separator
// result_pos: the position to which we are currently copying characters.
// element: Current array element.
// elements_end: Array end.
- // separator: Single separator ASCII char (in lower byte).
+ // separator: Single separator one-byte char (in lower byte).
// Copy the separator character to the result.
__ Strb(separator, MemOperand(result_pos, 1, PostIndex));
}
-void MacroAssembler::JumpIfEitherIsNotSequentialAsciiStrings(
- Register first,
- Register second,
- Register scratch1,
- Register scratch2,
- Label* failure,
- SmiCheckType smi_check) {
-
+void MacroAssembler::JumpIfEitherIsNotSequentialOneByteStrings(
+ Register first, Register second, Register scratch1, Register scratch2,
+ Label* failure, SmiCheckType smi_check) {
if (smi_check == DO_SMI_CHECK) {
JumpIfEitherSmi(first, second, failure);
} else if (emit_debug_code()) {
Bind(¬_smi);
}
- // Test that both first and second are sequential ASCII strings.
+ // Test that both first and second are sequential one-byte strings.
Ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset));
Ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset));
Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
Ldrb(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset));
- JumpIfEitherInstanceTypeIsNotSequentialAscii(scratch1,
- scratch2,
- scratch1,
- scratch2,
- failure);
+ JumpIfEitherInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, scratch1,
+ scratch2, failure);
}
-void MacroAssembler::JumpIfEitherInstanceTypeIsNotSequentialAscii(
- Register first,
- Register second,
- Register scratch1,
- Register scratch2,
+void MacroAssembler::JumpIfEitherInstanceTypeIsNotSequentialOneByte(
+ Register first, Register second, Register scratch1, Register scratch2,
Label* failure) {
DCHECK(!AreAliased(scratch1, second));
DCHECK(!AreAliased(scratch1, scratch2));
- static const int kFlatAsciiStringMask =
+ static const int kFlatOneByteStringMask =
kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
- static const int kFlatAsciiStringTag = ASCII_STRING_TYPE;
- And(scratch1, first, kFlatAsciiStringMask);
- And(scratch2, second, kFlatAsciiStringMask);
- Cmp(scratch1, kFlatAsciiStringTag);
- Ccmp(scratch2, kFlatAsciiStringTag, NoFlag, eq);
+ static const int kFlatOneByteStringTag = ONE_BYTE_STRING_TYPE;
+ And(scratch1, first, kFlatOneByteStringMask);
+ And(scratch2, second, kFlatOneByteStringMask);
+ Cmp(scratch1, kFlatOneByteStringTag);
+ Ccmp(scratch2, kFlatOneByteStringTag, NoFlag, eq);
B(ne, failure);
}
-void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(Register type,
- Register scratch,
- Label* failure) {
- const int kFlatAsciiStringMask =
+void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(Register type,
+ Register scratch,
+ Label* failure) {
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
- And(scratch, type, kFlatAsciiStringMask);
- Cmp(scratch, kFlatAsciiStringTag);
+ And(scratch, type, kFlatOneByteStringMask);
+ Cmp(scratch, kFlatOneByteStringTag);
B(ne, failure);
}
-void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialAscii(
- Register first,
- Register second,
- Register scratch1,
- Register scratch2,
+void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte(
+ Register first, Register second, Register scratch1, Register scratch2,
Label* failure) {
DCHECK(!AreAliased(first, second, scratch1, scratch2));
- const int kFlatAsciiStringMask =
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
- And(scratch1, first, kFlatAsciiStringMask);
- And(scratch2, second, kFlatAsciiStringMask);
- Cmp(scratch1, kFlatAsciiStringTag);
- Ccmp(scratch2, kFlatAsciiStringTag, NoFlag, eq);
+ And(scratch1, first, kFlatOneByteStringMask);
+ And(scratch2, second, kFlatOneByteStringMask);
+ Cmp(scratch1, kFlatOneByteStringTag);
+ Ccmp(scratch2, kFlatOneByteStringTag, NoFlag, eq);
B(ne, failure);
}
}
-void MacroAssembler::AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3,
+ Label* gc_required) {
DCHECK(!AreAliased(result, length, scratch1, scratch2, scratch3));
// Calculate the number of bytes needed for the characters in the string while
// observing object alignment.
Add(scratch1, length, kObjectAlignmentMask + SeqOneByteString::kHeaderSize);
Bic(scratch1, scratch1, kObjectAlignmentMask);
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(scratch1,
result,
scratch2,
TAG_OBJECT);
// Set the map, length and hash field.
- InitializeNewString(result,
- length,
- Heap::kAsciiStringMapRootIndex,
- scratch1,
- scratch2);
+ InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex,
+ scratch1, scratch2);
}
}
-void MacroAssembler::AllocateAsciiConsString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteConsString(Register result, Register length,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
Allocate(ConsString::kSize,
result,
scratch1,
gc_required,
TAG_OBJECT);
- InitializeNewString(result,
- length,
- Heap::kConsAsciiStringMapRootIndex,
- scratch1,
- scratch2);
+ InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex,
+ scratch1, scratch2);
}
}
-void MacroAssembler::AllocateAsciiSlicedString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteSlicedString(Register result,
+ Register length,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
DCHECK(!AreAliased(result, length, scratch1, scratch2));
Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
TAG_OBJECT);
- InitializeNewString(result,
- length,
- Heap::kSlicedAsciiStringMapRootIndex,
- scratch1,
- scratch2);
+ InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex,
+ scratch1, scratch2);
}
Mov(length_scratch, ExternalString::kSize);
TestAndBranchIfAnySet(instance_type, kExternalStringTag, &is_data_object);
- // Sequential string, either ASCII or UC16.
- // For ASCII (char-size of 1) we shift the smi tag away to get the length.
+ // Sequential string, either Latin1 or UC16.
+ // For Latin1 (char-size of 1) we shift the smi tag away to get the length.
// For UC16 (char-size of 2) we just leave the smi tag in place, thereby
// getting the length multiplied by 2.
DCHECK(kOneByteStringTag == 4 && kStringEncodingMask == 4);
// ---- String Utilities ----
- // Jump to label if either object is not a sequential ASCII string.
+ // Jump to label if either object is not a sequential one-byte string.
// Optionally perform a smi check on the objects first.
- void JumpIfEitherIsNotSequentialAsciiStrings(
- Register first,
- Register second,
- Register scratch1,
- Register scratch2,
- Label* failure,
- SmiCheckType smi_check = DO_SMI_CHECK);
+ void JumpIfEitherIsNotSequentialOneByteStrings(
+ Register first, Register second, Register scratch1, Register scratch2,
+ Label* failure, SmiCheckType smi_check = DO_SMI_CHECK);
- // Check if instance type is sequential ASCII string and jump to label if
+ // Check if instance type is sequential one-byte string and jump to label if
// it is not.
- void JumpIfInstanceTypeIsNotSequentialAscii(Register type,
- Register scratch,
- Label* failure);
+ void JumpIfInstanceTypeIsNotSequentialOneByte(Register type, Register scratch,
+ Label* failure);
- // Checks if both instance types are sequential ASCII strings and jumps to
+ // Checks if both instance types are sequential one-byte strings and jumps to
// label if either is not.
- void JumpIfEitherInstanceTypeIsNotSequentialAscii(
- Register first_object_instance_type,
- Register second_object_instance_type,
- Register scratch1,
- Register scratch2,
- Label* failure);
+ void JumpIfEitherInstanceTypeIsNotSequentialOneByte(
+ Register first_object_instance_type, Register second_object_instance_type,
+ Register scratch1, Register scratch2, Label* failure);
- // Checks if both instance types are sequential ASCII strings and jumps to
+ // Checks if both instance types are sequential one-byte strings and jumps to
// label if either is not.
- void JumpIfBothInstanceTypesAreNotSequentialAscii(
- Register first_object_instance_type,
- Register second_object_instance_type,
- Register scratch1,
- Register scratch2,
- Label* failure);
+ void JumpIfBothInstanceTypesAreNotSequentialOneByte(
+ Register first_object_instance_type, Register second_object_instance_type,
+ Register scratch1, Register scratch2, Label* failure);
void JumpIfNotUniqueName(Register type, Label* not_unique_name);
Register scratch2,
Register scratch3,
Label* gc_required);
- void AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required);
+ void AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3, Label* gc_required);
void AllocateTwoByteConsString(Register result,
Register length,
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiConsString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteConsString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Label* gc_required);
void AllocateTwoByteSlicedString(Register result,
Register length,
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiSlicedString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteSlicedString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Label* gc_required);
// Allocates a heap number or jumps to the gc_required label if the young
// space is full and a scavenge is needed.
}
for (int i = 0; i < str.length(); i++) {
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
__ Ldrb(w10, MemOperand(characters_address, 1, PostIndex));
DCHECK(str[i] <= String::kMaxOneByteCharCode);
} else {
__ Cmn(capture_length, current_input_offset());
BranchOrBacktrack(gt, on_no_match);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
Label success;
Label fail;
Label loop_check;
Label loop;
__ Bind(&loop);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
__ Ldrb(w10, MemOperand(capture_start_address, 1, PostIndex));
__ Ldrb(w11, MemOperand(current_position_address, 1, PostIndex));
} else {
Handle<ByteArray> table,
Label* on_bit_set) {
__ Mov(x11, Operand(table));
- if ((mode_ != ASCII) || (kTableMask != String::kMaxOneByteCharCode)) {
+ if ((mode_ != LATIN1) || (kTableMask != String::kMaxOneByteCharCode)) {
__ And(w10, current_character(), kTableMask);
__ Add(w10, w10, ByteArray::kHeaderSize - kHeapObjectTag);
} else {
switch (type) {
case 's':
// Match space-characters
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
Label success;
// Check for ' ' or 0x00a0.
return true;
}
case 'w': {
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
CompareAndBranchOrBacktrack(current_character(), 'z', hi, on_no_match);
}
ExternalReference map = ExternalReference::re_word_character_map();
}
case 'W': {
Label done;
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ Cmp(current_character(), 'z');
__ B(hi, &done);
}
Handle<String> subject(frame_entry<String*>(re_frame, kInput));
// Current string.
- bool is_ascii = subject->IsOneByteRepresentationUnderneath();
+ bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
DCHECK(re_code->instruction_start() <= *return_address);
DCHECK(*return_address <=
}
// String might have changed.
- if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
- // If we changed between an ASCII and an UC16 string, the specialized
+ if (subject_tmp->IsOneByteRepresentation() != is_one_byte) {
+ // If we changed between an Latin1 and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).
return RETRY;
offset = w10;
}
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
if (characters == 4) {
__ Ldr(current_character(), MemOperand(input_end(), offset, SXTW));
} else if (characters == 2) {
MacroAssembler* masm_;
- // Which mode to generate code for (ASCII or UC16).
+ // Which mode to generate code for (LATIN1 or UC16).
Mode mode_;
// One greater than maximal register index actually used.
elements[elements_length++] = e;
}
elements.length = elements_length;
- var result = %_FastAsciiArrayJoin(elements, '');
+ var result = %_FastOneByteArrayJoin(elements, '');
if (!IS_UNDEFINED(result)) return result;
return %StringBuilderConcat(elements, elements_length, '');
}
elements[i] = e;
}
}
- var result = %_FastAsciiArrayJoin(elements, separator);
+ var result = %_FastOneByteArrayJoin(elements, separator);
if (!IS_UNDEFINED(result)) return result;
return %StringBuilderJoin(elements, length, separator);
separator = NonStringToString(separator);
}
- var result = %_FastAsciiArrayJoin(array, separator);
+ var result = %_FastOneByteArrayJoin(array, separator);
if (!IS_UNDEFINED(result)) return result;
return Join(array, length, separator, ConvertToString);
const AstRawString* AstValueFactory::GetString(Handle<String> literal) {
DisallowHeapAllocation no_gc;
String::FlatContent content = literal->GetFlatContent();
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
return GetOneByteString(content.ToOneByteVector());
}
DCHECK(content.IsTwoByte());
source.start(),
source.length());
// We do not expect this to throw an exception. Change this if it does.
- Handle<String> source_code =
- isolate_->factory()->NewExternalStringFromAscii(
- resource).ToHandleChecked();
+ Handle<String> source_code = isolate_->factory()
+ ->NewExternalStringFromOneByte(resource)
+ .ToHandleChecked();
heap->natives_source_cache()->set(index, *source_code);
}
Handle<Object> cached_source(heap->natives_source_cache()->get(index),
// Allocate the empty function as the prototype for function ECMAScript
// 262 15.3.4.
Handle<String> empty_string =
- factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
+ factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
Handle<JSFunction> empty_function = factory->NewFunctionWithoutPrototype(
empty_string, code);
empty_function->set_map(*empty_function_map);
// --- E m p t y ---
- Handle<String> source = factory->NewStringFromStaticAscii("() {}");
+ Handle<String> source = factory->NewStringFromStaticChars("() {}");
Handle<Script> script = factory->NewScript(source);
script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
empty_function->shared()->set_script(*script);
Handle<JSFunction> Genesis::GetStrictPoisonFunction() {
if (strict_poison_function.is_null()) {
Handle<String> name = factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("ThrowTypeError"));
+ STATIC_CHAR_VECTOR("ThrowTypeError"));
Handle<Code> code(isolate()->builtins()->builtin(
Builtins::kStrictModePoisonPill));
strict_poison_function = factory()->NewFunctionWithoutPrototype(name, code);
Handle<JSFunction> Genesis::GetGeneratorPoisonFunction() {
if (generator_poison_function.is_null()) {
Handle<String> name = factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("ThrowTypeError"));
+ STATIC_CHAR_VECTOR("ThrowTypeError"));
Handle<Code> code(isolate()->builtins()->builtin(
Builtins::kGeneratorPoisonPill));
generator_poison_function = factory()->NewFunctionWithoutPrototype(
JSObject::kHeaderSize);
Handle<String> name = factory->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("context_extension"));
+ STATIC_CHAR_VECTOR("context_extension"));
context_extension_fun->shared()->set_instance_class_name(*name);
native_context()->set_context_extension_function(*context_extension_fun);
}
Factory* factory = isolate->factory();
Handle<String> source_code;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
- isolate, source_code,
- factory->NewStringFromAscii(
- ExperimentalNatives::GetRawScriptSource(index)),
+ isolate, source_code, factory->NewStringFromAscii(
+ ExperimentalNatives::GetRawScriptSource(index)),
false);
return CompileNative(isolate, name, source_code);
}
}
-#define INSTALL_NATIVE(Type, name, var) \
- Handle<String> var##_name = \
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
- Handle<Object> var##_native = Object::GetProperty( \
- handle(native_context()->builtins()), var##_name).ToHandleChecked(); \
+#define INSTALL_NATIVE(Type, name, var) \
+ Handle<String> var##_name = \
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR(name)); \
+ Handle<Object> var##_native = \
+ Object::GetProperty(handle(native_context()->builtins()), var##_name) \
+ .ToHandleChecked(); \
native_context()->set_##var(Type::cast(*var##_native));
#define INSTALL_NATIVE_MATH(name) \
JSBuiltinsObject::kSize);
Handle<String> name =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
builtins_fun->shared()->set_instance_class_name(*name);
builtins_fun->initial_map()->set_dictionary_map(true);
builtins_fun->initial_map()->set_prototype(heap()->null_value());
static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
Handle<String> global_string =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("global"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("global"));
Handle<Object> global_obj(native_context()->global_object(), isolate());
JSObject::AddProperty(builtins, global_string, global_obj, attributes);
Handle<String> builtins_string =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
// Set up the reference from the global object to the builtins object.
Handle<JSObject> Error = Handle<JSObject>::cast(
Object::GetProperty(isolate, global, "Error").ToHandleChecked());
Handle<String> name =
- factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("stackTraceLimit"));
+ factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("stackTraceLimit"));
Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
JSObject::AddProperty(Error, name, stack_trace_limit, NONE);
}
// Expose the stack trace symbol to native JS.
- RETURN_ON_EXCEPTION_VALUE(
- isolate,
- JSObject::SetOwnPropertyIgnoreAttributes(
- handle(native_context->builtins(), isolate),
- factory->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("stack_trace_symbol")),
- factory->stack_trace_symbol(),
- NONE),
- false);
+ RETURN_ON_EXCEPTION_VALUE(isolate,
+ JSObject::SetOwnPropertyIgnoreAttributes(
+ handle(native_context->builtins(), isolate),
+ factory->InternalizeOneByteString(
+ STATIC_CHAR_VECTOR("stack_trace_symbol")),
+ factory->stack_trace_symbol(), NONE),
+ false);
// Expose the debug global object in global if a name for it is specified.
if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
}
// We do not expect this to throw an exception. Change this if it does.
Handle<String> source_code =
- isolate->factory()->NewExternalStringFromAscii(
- extension->source()).ToHandleChecked();
+ isolate->factory()
+ ->NewExternalStringFromOneByte(extension->source())
+ .ToHandleChecked();
bool result = CompileScriptCached(isolate,
CStrVector(extension->name()),
source_code,
Utils::OpenHandle(*buffer)->set_should_be_freed(true);
v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems);
Handle<JSBuiltinsObject> builtins(native_context()->builtins());
- Runtime::DefineObjectProperty(builtins,
- factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("rngstate")),
- Utils::OpenHandle(*ta),
- NONE).Assert();
+ Runtime::DefineObjectProperty(builtins, factory()->InternalizeOneByteString(
+ STATIC_CHAR_VECTOR("rngstate")),
+ Utils::OpenHandle(*ta), NONE).Assert();
// Initialize trigonometric lookup tables and constants.
const int constants_size = arraysize(fdlibm::MathConstants::constants);
Runtime::DefineObjectProperty(
builtins,
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("kMath")),
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("kMath")),
Utils::OpenHandle(*trig_table), NONE).Assert();
}
namespace internal {
// A SourceCodeCache uses a FixedArray to store pairs of
-// (AsciiString*, JSFunction*), mapping names of native code files
+// (OneByteString*, JSFunction*), mapping names of native code files
// (runtime.js, etc.) to precompiled functions. Instead of mapping
// names to functions it might make sense to let the JS2C tool
// generate an index for each native JS file.
class NativesExternalStringResource FINAL
- : public v8::String::ExternalAsciiStringResource {
+ : public v8::String::ExternalOneByteStringResource {
public:
NativesExternalStringResource(Bootstrapper* bootstrapper,
const char* source,
Isolate* isolate = GetIsolate();
Handle<Object> result(error_message_for_code_gen_from_strings(), isolate);
if (!result->IsUndefined()) return result;
- return isolate->factory()->NewStringFromStaticAscii(
+ return isolate->factory()->NewStringFromStaticChars(
"Code generation from strings disallowed for this context");
}
DisallowHeapAllocation no_gc;
String::FlatContent flat = string->GetFlatContent();
// ECMA-262 section 15.1.2.3, empty string is NaN
- if (flat.IsAscii()) {
+ if (flat.IsOneByte()) {
return StringToDouble(
unicode_cache, flat.ToOneByteVector(), flags, empty_string_val);
} else {
SC(store_buffer_overflows, V8.StoreBufferOverflows)
-#define STATS_COUNTER_LIST_2(SC) \
- /* Number of code stubs. */ \
- SC(code_stubs, V8.CodeStubs) \
- /* Amount of stub code. */ \
- SC(total_stubs_code_size, V8.TotalStubsCodeSize) \
- /* Amount of (JS) compiled code. */ \
- SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
- SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
- SC(gc_compactor_caused_by_promoted_data, \
- V8.GCCompactorCausedByPromotedData) \
- SC(gc_compactor_caused_by_oldspace_exhaustion, \
- V8.GCCompactorCausedByOldspaceExhaustion) \
- SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
- SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
- /* How is the generic keyed-load stub used? */ \
- SC(keyed_load_generic_smi, V8.KeyedLoadGenericSmi) \
- SC(keyed_load_generic_symbol, V8.KeyedLoadGenericSymbol) \
- SC(keyed_load_generic_lookup_cache, V8.KeyedLoadGenericLookupCache) \
- SC(keyed_load_generic_slow, V8.KeyedLoadGenericSlow) \
- SC(keyed_load_polymorphic_stubs, V8.KeyedLoadPolymorphicStubs) \
- SC(keyed_load_external_array_slow, V8.KeyedLoadExternalArraySlow) \
- /* How is the generic keyed-call stub used? */ \
- SC(keyed_call_generic_smi_fast, V8.KeyedCallGenericSmiFast) \
- SC(keyed_call_generic_smi_dict, V8.KeyedCallGenericSmiDict) \
- SC(keyed_call_generic_lookup_cache, V8.KeyedCallGenericLookupCache) \
- SC(keyed_call_generic_lookup_dict, V8.KeyedCallGenericLookupDict) \
- SC(keyed_call_generic_slow, V8.KeyedCallGenericSlow) \
- SC(keyed_call_generic_slow_load, V8.KeyedCallGenericSlowLoad) \
- SC(named_load_global_stub, V8.NamedLoadGlobalStub) \
- SC(named_store_global_inline, V8.NamedStoreGlobalInline) \
- SC(named_store_global_inline_miss, V8.NamedStoreGlobalInlineMiss) \
- SC(keyed_store_polymorphic_stubs, V8.KeyedStorePolymorphicStubs) \
- SC(keyed_store_external_array_slow, V8.KeyedStoreExternalArraySlow) \
- SC(store_normal_miss, V8.StoreNormalMiss) \
- SC(store_normal_hit, V8.StoreNormalHit) \
- SC(cow_arrays_created_stub, V8.COWArraysCreatedStub) \
- SC(cow_arrays_created_runtime, V8.COWArraysCreatedRuntime) \
- SC(cow_arrays_converted, V8.COWArraysConverted) \
- SC(call_miss, V8.CallMiss) \
- SC(keyed_call_miss, V8.KeyedCallMiss) \
- SC(load_miss, V8.LoadMiss) \
- SC(keyed_load_miss, V8.KeyedLoadMiss) \
- SC(call_const, V8.CallConst) \
- SC(call_const_fast_api, V8.CallConstFastApi) \
- SC(call_const_interceptor, V8.CallConstInterceptor) \
- SC(call_const_interceptor_fast_api, V8.CallConstInterceptorFastApi) \
- SC(call_global_inline, V8.CallGlobalInline) \
- SC(call_global_inline_miss, V8.CallGlobalInlineMiss) \
- SC(constructed_objects, V8.ConstructedObjects) \
- SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
- SC(negative_lookups, V8.NegativeLookups) \
- SC(negative_lookups_miss, V8.NegativeLookupsMiss) \
- SC(megamorphic_stub_cache_probes, V8.MegamorphicStubCacheProbes) \
- SC(megamorphic_stub_cache_misses, V8.MegamorphicStubCacheMisses) \
- SC(megamorphic_stub_cache_updates, V8.MegamorphicStubCacheUpdates) \
- SC(array_function_runtime, V8.ArrayFunctionRuntime) \
- SC(array_function_native, V8.ArrayFunctionNative) \
- SC(for_in, V8.ForIn) \
- SC(enum_cache_hits, V8.EnumCacheHits) \
- SC(enum_cache_misses, V8.EnumCacheMisses) \
- SC(zone_segment_bytes, V8.ZoneSegmentBytes) \
- SC(fast_new_closure_total, V8.FastNewClosureTotal) \
- SC(fast_new_closure_try_optimized, V8.FastNewClosureTryOptimized) \
- SC(fast_new_closure_install_optimized, V8.FastNewClosureInstallOptimized) \
- SC(string_add_runtime, V8.StringAddRuntime) \
- SC(string_add_native, V8.StringAddNative) \
- SC(string_add_runtime_ext_to_ascii, V8.StringAddRuntimeExtToAscii) \
- SC(sub_string_runtime, V8.SubStringRuntime) \
- SC(sub_string_native, V8.SubStringNative) \
- SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
- SC(string_compare_native, V8.StringCompareNative) \
- SC(string_compare_runtime, V8.StringCompareRuntime) \
- SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
- SC(regexp_entry_native, V8.RegExpEntryNative) \
- SC(number_to_string_native, V8.NumberToStringNative) \
- SC(number_to_string_runtime, V8.NumberToStringRuntime) \
- SC(math_acos, V8.MathAcos) \
- SC(math_asin, V8.MathAsin) \
- SC(math_atan, V8.MathAtan) \
- SC(math_atan2, V8.MathAtan2) \
- SC(math_exp, V8.MathExp) \
- SC(math_floor, V8.MathFloor) \
- SC(math_log, V8.MathLog) \
- SC(math_pow, V8.MathPow) \
- SC(math_round, V8.MathRound) \
- SC(math_sqrt, V8.MathSqrt) \
- SC(stack_interrupts, V8.StackInterrupts) \
- SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
- SC(bounds_checks_eliminated, V8.BoundsChecksEliminated) \
- SC(bounds_checks_hoisted, V8.BoundsChecksHoisted) \
- SC(soft_deopts_requested, V8.SoftDeoptsRequested) \
- SC(soft_deopts_inserted, V8.SoftDeoptsInserted) \
- SC(soft_deopts_executed, V8.SoftDeoptsExecuted) \
- /* Number of write barriers in generated code. */ \
- SC(write_barriers_dynamic, V8.WriteBarriersDynamic) \
- SC(write_barriers_static, V8.WriteBarriersStatic) \
- SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable) \
- SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted) \
- SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed) \
- SC(old_pointer_space_bytes_available, \
- V8.MemoryOldPointerSpaceBytesAvailable) \
- SC(old_pointer_space_bytes_committed, \
- V8.MemoryOldPointerSpaceBytesCommitted) \
- SC(old_pointer_space_bytes_used, V8.MemoryOldPointerSpaceBytesUsed) \
- SC(old_data_space_bytes_available, V8.MemoryOldDataSpaceBytesAvailable) \
- SC(old_data_space_bytes_committed, V8.MemoryOldDataSpaceBytesCommitted) \
- SC(old_data_space_bytes_used, V8.MemoryOldDataSpaceBytesUsed) \
- SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable) \
- SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted) \
- SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed) \
- SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable) \
- SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted) \
- SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed) \
- SC(cell_space_bytes_available, V8.MemoryCellSpaceBytesAvailable) \
- SC(cell_space_bytes_committed, V8.MemoryCellSpaceBytesCommitted) \
- SC(cell_space_bytes_used, V8.MemoryCellSpaceBytesUsed) \
- SC(property_cell_space_bytes_available, \
- V8.MemoryPropertyCellSpaceBytesAvailable) \
- SC(property_cell_space_bytes_committed, \
- V8.MemoryPropertyCellSpaceBytesCommitted) \
- SC(property_cell_space_bytes_used, \
- V8.MemoryPropertyCellSpaceBytesUsed) \
- SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable) \
- SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted) \
+#define STATS_COUNTER_LIST_2(SC) \
+ /* Number of code stubs. */ \
+ SC(code_stubs, V8.CodeStubs) \
+ /* Amount of stub code. */ \
+ SC(total_stubs_code_size, V8.TotalStubsCodeSize) \
+ /* Amount of (JS) compiled code. */ \
+ SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
+ SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
+ SC(gc_compactor_caused_by_promoted_data, V8.GCCompactorCausedByPromotedData) \
+ SC(gc_compactor_caused_by_oldspace_exhaustion, \
+ V8.GCCompactorCausedByOldspaceExhaustion) \
+ SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
+ SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
+ /* How is the generic keyed-load stub used? */ \
+ SC(keyed_load_generic_smi, V8.KeyedLoadGenericSmi) \
+ SC(keyed_load_generic_symbol, V8.KeyedLoadGenericSymbol) \
+ SC(keyed_load_generic_lookup_cache, V8.KeyedLoadGenericLookupCache) \
+ SC(keyed_load_generic_slow, V8.KeyedLoadGenericSlow) \
+ SC(keyed_load_polymorphic_stubs, V8.KeyedLoadPolymorphicStubs) \
+ SC(keyed_load_external_array_slow, V8.KeyedLoadExternalArraySlow) \
+ /* How is the generic keyed-call stub used? */ \
+ SC(keyed_call_generic_smi_fast, V8.KeyedCallGenericSmiFast) \
+ SC(keyed_call_generic_smi_dict, V8.KeyedCallGenericSmiDict) \
+ SC(keyed_call_generic_lookup_cache, V8.KeyedCallGenericLookupCache) \
+ SC(keyed_call_generic_lookup_dict, V8.KeyedCallGenericLookupDict) \
+ SC(keyed_call_generic_slow, V8.KeyedCallGenericSlow) \
+ SC(keyed_call_generic_slow_load, V8.KeyedCallGenericSlowLoad) \
+ SC(named_load_global_stub, V8.NamedLoadGlobalStub) \
+ SC(named_store_global_inline, V8.NamedStoreGlobalInline) \
+ SC(named_store_global_inline_miss, V8.NamedStoreGlobalInlineMiss) \
+ SC(keyed_store_polymorphic_stubs, V8.KeyedStorePolymorphicStubs) \
+ SC(keyed_store_external_array_slow, V8.KeyedStoreExternalArraySlow) \
+ SC(store_normal_miss, V8.StoreNormalMiss) \
+ SC(store_normal_hit, V8.StoreNormalHit) \
+ SC(cow_arrays_created_stub, V8.COWArraysCreatedStub) \
+ SC(cow_arrays_created_runtime, V8.COWArraysCreatedRuntime) \
+ SC(cow_arrays_converted, V8.COWArraysConverted) \
+ SC(call_miss, V8.CallMiss) \
+ SC(keyed_call_miss, V8.KeyedCallMiss) \
+ SC(load_miss, V8.LoadMiss) \
+ SC(keyed_load_miss, V8.KeyedLoadMiss) \
+ SC(call_const, V8.CallConst) \
+ SC(call_const_fast_api, V8.CallConstFastApi) \
+ SC(call_const_interceptor, V8.CallConstInterceptor) \
+ SC(call_const_interceptor_fast_api, V8.CallConstInterceptorFastApi) \
+ SC(call_global_inline, V8.CallGlobalInline) \
+ SC(call_global_inline_miss, V8.CallGlobalInlineMiss) \
+ SC(constructed_objects, V8.ConstructedObjects) \
+ SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
+ SC(negative_lookups, V8.NegativeLookups) \
+ SC(negative_lookups_miss, V8.NegativeLookupsMiss) \
+ SC(megamorphic_stub_cache_probes, V8.MegamorphicStubCacheProbes) \
+ SC(megamorphic_stub_cache_misses, V8.MegamorphicStubCacheMisses) \
+ SC(megamorphic_stub_cache_updates, V8.MegamorphicStubCacheUpdates) \
+ SC(array_function_runtime, V8.ArrayFunctionRuntime) \
+ SC(array_function_native, V8.ArrayFunctionNative) \
+ SC(for_in, V8.ForIn) \
+ SC(enum_cache_hits, V8.EnumCacheHits) \
+ SC(enum_cache_misses, V8.EnumCacheMisses) \
+ SC(zone_segment_bytes, V8.ZoneSegmentBytes) \
+ SC(fast_new_closure_total, V8.FastNewClosureTotal) \
+ SC(fast_new_closure_try_optimized, V8.FastNewClosureTryOptimized) \
+ SC(fast_new_closure_install_optimized, V8.FastNewClosureInstallOptimized) \
+ SC(string_add_runtime, V8.StringAddRuntime) \
+ SC(string_add_native, V8.StringAddNative) \
+ SC(string_add_runtime_ext_to_one_byte, V8.StringAddRuntimeExtToOneByte) \
+ SC(sub_string_runtime, V8.SubStringRuntime) \
+ SC(sub_string_native, V8.SubStringNative) \
+ SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
+ SC(string_compare_native, V8.StringCompareNative) \
+ SC(string_compare_runtime, V8.StringCompareRuntime) \
+ SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
+ SC(regexp_entry_native, V8.RegExpEntryNative) \
+ SC(number_to_string_native, V8.NumberToStringNative) \
+ SC(number_to_string_runtime, V8.NumberToStringRuntime) \
+ SC(math_acos, V8.MathAcos) \
+ SC(math_asin, V8.MathAsin) \
+ SC(math_atan, V8.MathAtan) \
+ SC(math_atan2, V8.MathAtan2) \
+ SC(math_exp, V8.MathExp) \
+ SC(math_floor, V8.MathFloor) \
+ SC(math_log, V8.MathLog) \
+ SC(math_pow, V8.MathPow) \
+ SC(math_round, V8.MathRound) \
+ SC(math_sqrt, V8.MathSqrt) \
+ SC(stack_interrupts, V8.StackInterrupts) \
+ SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
+ SC(bounds_checks_eliminated, V8.BoundsChecksEliminated) \
+ SC(bounds_checks_hoisted, V8.BoundsChecksHoisted) \
+ SC(soft_deopts_requested, V8.SoftDeoptsRequested) \
+ SC(soft_deopts_inserted, V8.SoftDeoptsInserted) \
+ SC(soft_deopts_executed, V8.SoftDeoptsExecuted) \
+ /* Number of write barriers in generated code. */ \
+ SC(write_barriers_dynamic, V8.WriteBarriersDynamic) \
+ SC(write_barriers_static, V8.WriteBarriersStatic) \
+ SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable) \
+ SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted) \
+ SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed) \
+ SC(old_pointer_space_bytes_available, \
+ V8.MemoryOldPointerSpaceBytesAvailable) \
+ SC(old_pointer_space_bytes_committed, \
+ V8.MemoryOldPointerSpaceBytesCommitted) \
+ SC(old_pointer_space_bytes_used, V8.MemoryOldPointerSpaceBytesUsed) \
+ SC(old_data_space_bytes_available, V8.MemoryOldDataSpaceBytesAvailable) \
+ SC(old_data_space_bytes_committed, V8.MemoryOldDataSpaceBytesCommitted) \
+ SC(old_data_space_bytes_used, V8.MemoryOldDataSpaceBytesUsed) \
+ SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable) \
+ SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted) \
+ SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed) \
+ SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable) \
+ SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted) \
+ SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed) \
+ SC(cell_space_bytes_available, V8.MemoryCellSpaceBytesAvailable) \
+ SC(cell_space_bytes_committed, V8.MemoryCellSpaceBytesCommitted) \
+ SC(cell_space_bytes_used, V8.MemoryCellSpaceBytesUsed) \
+ SC(property_cell_space_bytes_available, \
+ V8.MemoryPropertyCellSpaceBytesAvailable) \
+ SC(property_cell_space_bytes_committed, \
+ V8.MemoryPropertyCellSpaceBytesCommitted) \
+ SC(property_cell_space_bytes_used, V8.MemoryPropertyCellSpaceBytesUsed) \
+ SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable) \
+ SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted) \
SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed)
};
-class BinaryResource : public v8::String::ExternalAsciiStringResource {
+class BinaryResource : public v8::String::ExternalOneByteStringResource {
public:
BinaryResource(const char* string, int length)
: data_(string),
// Expose the builtins object in the debugger context.
Handle<String> key = isolate_->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("builtins"));
+ STATIC_CHAR_VECTOR("builtins"));
Handle<GlobalObject> global =
Handle<GlobalObject>(context->global_object(), isolate_);
Handle<JSBuiltinsObject> builtin =
// Get the function IsBreakPointTriggered (defined in debug-debugger.js).
Handle<String> is_break_point_triggered_string =
factory->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("IsBreakPointTriggered"));
+ STATIC_CHAR_VECTOR("IsBreakPointTriggered"));
Handle<GlobalObject> debug_global(debug_context()->global_object());
Handle<JSFunction> check_break_point =
Handle<JSFunction>::cast(Object::GetProperty(
bool Debug::PromiseHasRejectHandler(Handle<JSObject> promise) {
Handle<JSFunction> fun = Handle<JSFunction>::cast(
JSObject::GetDataProperty(isolate_->js_builtins_object(),
- isolate_->factory()->NewStringFromStaticAscii(
+ isolate_->factory()->NewStringFromStaticChars(
"PromiseHasRejectHandler")));
Handle<Object> result =
Execution::Call(isolate_, fun, promise, 0, NULL).ToHandleChecked();
Factory* factory = isolate_->factory();
Handle<GlobalObject> global(isolate_->global_object());
JSObject::SetProperty(global,
- factory->NewStringFromAsciiChecked("next_handle_"),
- handle(Smi::FromInt(0), isolate_),
- SLOPPY).Check();
+ factory->NewStringFromAsciiChecked("next_handle_"),
+ handle(Smi::FromInt(0), isolate_), SLOPPY).Check();
JSObject::SetProperty(global,
- factory->NewStringFromAsciiChecked("mirror_cache_"),
- factory->NewJSArray(0, FAST_ELEMENTS),
- SLOPPY).Check();
+ factory->NewStringFromAsciiChecked("mirror_cache_"),
+ factory->NewJSArray(0, FAST_ELEMENTS), SLOPPY).Check();
}
// Get the function UpdateScriptBreakPoints (defined in debug-debugger.js).
Handle<String> update_script_break_points_string =
isolate_->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
+ STATIC_CHAR_VECTOR("UpdateScriptBreakPoints"));
Handle<GlobalObject> debug_global(debug_context()->global_object());
Handle<Object> update_script_break_points =
Object::GetProperty(
};
-typedef SimpleStringResource<char, v8::String::ExternalAsciiStringResource>
- SimpleAsciiStringResource;
+typedef SimpleStringResource<char, v8::String::ExternalOneByteStringResource>
+ SimpleOneByteStringResource;
typedef SimpleStringResource<uc16, v8::String::ExternalStringResource>
SimpleTwoByteStringResource;
const char* const ExternalizeStringExtension::kSource =
"native function externalizeString();"
- "native function isAsciiString();";
+ "native function isOneByteString();";
v8::Handle<v8::FunctionTemplate>
ExternalizeStringExtension::GetNativeFunctionTemplate(
return v8::FunctionTemplate::New(isolate,
ExternalizeStringExtension::Externalize);
} else {
- DCHECK(strcmp(*v8::String::Utf8Value(str), "isAsciiString") == 0);
+ DCHECK(strcmp(*v8::String::Utf8Value(str), "isOneByteString") == 0);
return v8::FunctionTemplate::New(isolate,
- ExternalizeStringExtension::IsAscii);
+ ExternalizeStringExtension::IsOneByte);
}
}
if (string->IsOneByteRepresentation() && !force_two_byte) {
uint8_t* data = new uint8_t[string->length()];
String::WriteToFlat(*string, data, 0, string->length());
- SimpleAsciiStringResource* resource = new SimpleAsciiStringResource(
+ SimpleOneByteStringResource* resource = new SimpleOneByteStringResource(
reinterpret_cast<char*>(data), string->length());
result = string->MakeExternal(resource);
if (result) {
}
-void ExternalizeStringExtension::IsAscii(
+void ExternalizeStringExtension::IsOneByte(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 1 || !args[0]->IsString()) {
args.GetIsolate()->ThrowException(v8::String::NewFromUtf8(
args.GetIsolate(),
- "isAsciiString() requires a single string argument."));
+ "isOneByteString() requires a single string argument."));
return;
}
bool is_one_byte =
v8::Isolate* isolate,
v8::Handle<v8::String> name);
static void Externalize(const v8::FunctionCallbackInfo<v8::Value>& args);
- static void IsAscii(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void IsOneByte(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
static const char* const kSource;
isolate(), result,
NewRawTwoByteString(non_ascii_start + utf16_length, pretenure),
String);
- // Copy ascii portion.
+ // Copy ASCII portion.
uint16_t* data = result->GetChars();
const char* ascii_data = string.start();
for (int i = 0; i < non_ascii_start; i++) {
// Find the corresponding internalized string map for strings.
switch (string->map()->instance_type()) {
case STRING_TYPE: return internalized_string_map();
- case ASCII_STRING_TYPE: return ascii_internalized_string_map();
+ case ONE_BYTE_STRING_TYPE:
+ return one_byte_internalized_string_map();
case EXTERNAL_STRING_TYPE: return external_internalized_string_map();
- case EXTERNAL_ASCII_STRING_TYPE:
- return external_ascii_internalized_string_map();
+ case EXTERNAL_ONE_BYTE_STRING_TYPE:
+ return external_one_byte_internalized_string_map();
case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
return external_internalized_string_with_one_byte_data_map();
case SHORT_EXTERNAL_STRING_TYPE:
return short_external_internalized_string_map();
- case SHORT_EXTERNAL_ASCII_STRING_TYPE:
- return short_external_ascii_internalized_string_map();
+ case SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE:
+ return short_external_one_byte_internalized_string_map();
case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
return short_external_internalized_string_with_one_byte_data_map();
default: return MaybeHandle<Map>(); // No match found.
bool is_one_byte_data_in_two_byte_string = false;
if (!is_one_byte) {
// At least one of the strings uses two-byte representation so we
- // can't use the fast case code for short ASCII strings below, but
- // we can try to save memory if all chars actually fit in ASCII.
+ // can't use the fast case code for short one-byte strings below, but
+ // we can try to save memory if all chars actually fit in one-byte.
is_one_byte_data_in_two_byte_string =
left->HasOnlyOneByteChars() && right->HasOnlyOneByteChars();
if (is_one_byte_data_in_two_byte_string) {
- isolate()->counters()->string_add_runtime_ext_to_ascii()->Increment();
+ isolate()->counters()->string_add_runtime_ext_to_one_byte()->Increment();
}
}
DisallowHeapAllocation no_gc;
uint8_t* dest = result->GetChars();
// Copy left part.
- const uint8_t* src = left->IsExternalString()
- ? Handle<ExternalAsciiString>::cast(left)->GetChars()
- : Handle<SeqOneByteString>::cast(left)->GetChars();
+ const uint8_t* src =
+ left->IsExternalString()
+ ? Handle<ExternalOneByteString>::cast(left)->GetChars()
+ : Handle<SeqOneByteString>::cast(left)->GetChars();
for (int i = 0; i < left_length; i++) *dest++ = src[i];
// Copy right part.
src = right->IsExternalString()
- ? Handle<ExternalAsciiString>::cast(right)->GetChars()
- : Handle<SeqOneByteString>::cast(right)->GetChars();
+ ? Handle<ExternalOneByteString>::cast(right)->GetChars()
+ : Handle<SeqOneByteString>::cast(right)->GetChars();
for (int i = 0; i < right_length; i++) *dest++ = src[i];
return result;
}
}
Handle<Map> map = (is_one_byte || is_one_byte_data_in_two_byte_string)
- ? cons_ascii_string_map() : cons_string_map();
+ ? cons_one_byte_string_map()
+ : cons_string_map();
Handle<ConsString> result = New<ConsString>(map, NEW_SPACE);
DisallowHeapAllocation no_gc;
}
DCHECK(str->IsSeqString() || str->IsExternalString());
- Handle<Map> map = str->IsOneByteRepresentation() ? sliced_ascii_string_map()
- : sliced_string_map();
+ Handle<Map> map = str->IsOneByteRepresentation()
+ ? sliced_one_byte_string_map()
+ : sliced_string_map();
Handle<SlicedString> slice = New<SlicedString>(map, NEW_SPACE);
slice->set_hash_field(String::kEmptyHashField);
}
-MaybeHandle<String> Factory::NewExternalStringFromAscii(
- const ExternalAsciiString::Resource* resource) {
+MaybeHandle<String> Factory::NewExternalStringFromOneByte(
+ const ExternalOneByteString::Resource* resource) {
size_t length = resource->length();
if (length > static_cast<size_t>(String::kMaxLength)) {
THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), String);
}
- Handle<Map> map = external_ascii_string_map();
- Handle<ExternalAsciiString> external_string =
- New<ExternalAsciiString>(map, NEW_SPACE);
+ Handle<Map> map = external_one_byte_string_map();
+ Handle<ExternalOneByteString> external_string =
+ New<ExternalOneByteString>(map, NEW_SPACE);
external_string->set_length(static_cast<int>(length));
external_string->set_hash_field(String::kEmptyHashField);
external_string->set_resource(resource);
Heap* heap = isolate()->heap();
MaybeHandle<SharedFunctionInfo> shared;
if (type == JS_FUNCTION_TYPE) {
- OneByteStringKey key(STATIC_ASCII_VECTOR("<freezing call trap>"),
+ OneByteStringKey key(STATIC_CHAR_VECTOR("<freezing call trap>"),
heap->HashSeed());
Handle<String> name = InternalizeStringWithKey(&key);
shared = NewSharedFunctionInfo(name, MaybeHandle<Code>());
store->set(JSRegExp::kTagIndex, Smi::FromInt(type));
store->set(JSRegExp::kSourceIndex, *source);
store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value()));
- store->set(JSRegExp::kIrregexpASCIICodeIndex, uninitialized);
+ store->set(JSRegExp::kIrregexpLatin1CodeIndex, uninitialized);
store->set(JSRegExp::kIrregexpUC16CodeIndex, uninitialized);
- store->set(JSRegExp::kIrregexpASCIICodeSavedIndex, uninitialized);
+ store->set(JSRegExp::kIrregexpLatin1CodeSavedIndex, uninitialized);
store->set(JSRegExp::kIrregexpUC16CodeSavedIndex, uninitialized);
store->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(0));
store->set(JSRegExp::kIrregexpCaptureCountIndex,
// allocated in the old generation. The pretenure flag defaults to
// DONT_TENURE.
//
- // Creates a new String object. There are two String encodings: ASCII and
- // two byte. One should choose between the three string factory functions
+ // Creates a new String object. There are two String encodings: one-byte and
+ // two-byte. One should choose between the three string factory functions
// based on the encoding of the string buffer that the string is
// initialized from.
- // - ...FromAscii initializes the string from a buffer that is ASCII
- // encoded (it does not check that the buffer is ASCII encoded) and
- // the result will be ASCII encoded.
+ // - ...FromOneByte initializes the string from a buffer that is Latin1
+ // encoded (it does not check that the buffer is Latin1 encoded) and
+ // the result will be Latin1 encoded.
// - ...FromUtf8 initializes the string from a buffer that is UTF-8
- // encoded. If the characters are all single-byte characters, the
- // result will be ASCII encoded, otherwise it will converted to two
- // byte.
- // - ...FromTwoByte initializes the string from a buffer that is two
- // byte encoded. If the characters are all single-byte characters,
- // the result will be converted to ASCII, otherwise it will be left as
- // two byte.
+ // encoded. If the characters are all ASCII characters, the result
+ // will be Latin1 encoded, otherwise it will converted to two-byte.
+ // - ...FromTwoByte initializes the string from a buffer that is two-byte
+ // encoded. If the characters are all Latin1 characters, the result
+ // will be converted to Latin1, otherwise it will be left as two-byte.
//
- // ASCII strings are pretenured when used as keys in the SourceCodeCache.
+ // One-byte strings are pretenured when used as keys in the SourceCodeCache.
MUST_USE_RESULT MaybeHandle<String> NewStringFromOneByte(
Vector<const uint8_t> str,
PretenureFlag pretenure = NOT_TENURED);
- template<size_t N>
- inline Handle<String> NewStringFromStaticAscii(
- const char (&str)[N],
- PretenureFlag pretenure = NOT_TENURED) {
+ template <size_t N>
+ inline Handle<String> NewStringFromStaticChars(
+ const char (&str)[N], PretenureFlag pretenure = NOT_TENURED) {
DCHECK(N == StrLength(str) + 1);
- return NewStringFromOneByte(
- STATIC_ASCII_VECTOR(str), pretenure).ToHandleChecked();
+ return NewStringFromOneByte(STATIC_CHAR_VECTOR(str), pretenure)
+ .ToHandleChecked();
}
inline Handle<String> NewStringFromAsciiChecked(
}
- // Allocates and fully initializes a String. There are two String
- // encodings: ASCII and two byte. One should choose between the three string
+ // Allocates and fully initializes a String. There are two String encodings:
+ // one-byte and two-byte. One should choose between the threestring
// allocation functions based on the encoding of the string buffer used to
// initialized the string.
- // - ...FromAscii initializes the string from a buffer that is ASCII
- // encoded (it does not check that the buffer is ASCII encoded) and the
- // result will be ASCII encoded.
+ // - ...FromOneByte initializes the string from a buffer that is Latin1
+ // encoded (it does not check that the buffer is Latin1 encoded) and the
+ // result will be Latin1 encoded.
// - ...FromUTF8 initializes the string from a buffer that is UTF-8
- // encoded. If the characters are all single-byte characters, the
- // result will be ASCII encoded, otherwise it will converted to two
- // byte.
+ // encoded. If the characters are all ASCII characters, the result
+ // will be Latin1 encoded, otherwise it will converted to two-byte.
// - ...FromTwoByte initializes the string from a buffer that is two-byte
- // encoded. If the characters are all single-byte characters, the
- // result will be converted to ASCII, otherwise it will be left as
+ // encoded. If the characters are all Latin1 characters, the
+ // result will be converted to Latin1, otherwise it will be left as
// two-byte.
// TODO(dcarney): remove this function.
MUST_USE_RESULT MaybeHandle<Map> InternalizedStringMapForString(
Handle<String> string);
- // Allocates and partially initializes an ASCII or TwoByte String. The
+ // Allocates and partially initializes an one-byte or two-byte String. The
// characters of the string are uninitialized. Currently used in regexp code
// only, where they are pretenured.
MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString(
PretenureFlag pretenure = NOT_TENURED);
// Creates a single character string where the character has given code.
- // A cache is used for ASCII codes.
+ // A cache is used for Latin1 codes.
Handle<String> LookupSingleCharacterStringFromCode(uint32_t code);
// Create a new cons string object which consists of a pair of strings.
}
// Creates a new external String object. There are two String encodings
- // in the system: ASCII and two byte. Unlike other String types, it does
+ // in the system: one-byte and two-byte. Unlike other String types, it does
// not make sense to have a UTF-8 factory function for external strings,
// because we cannot change the underlying buffer. Note that these strings
// are backed by a string resource that resides outside the V8 heap.
- MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromAscii(
- const ExternalAsciiString::Resource* resource);
+ MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromOneByte(
+ const ExternalOneByteString::Resource* resource);
MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromTwoByte(
const ExternalTwoByteString::Resource* resource);
{
// Check that we are not passing a finalized external string to
// the callback.
- DCHECK(!object_->IsExternalAsciiString() ||
- ExternalAsciiString::cast(object_)->resource() != NULL);
+ DCHECK(!object_->IsExternalOneByteString() ||
+ ExternalOneByteString::cast(object_)->resource() != NULL);
DCHECK(!object_->IsExternalTwoByteString() ||
ExternalTwoByteString::cast(object_)->resource() != NULL);
// Leaving V8.
template <>
bool inline Heap::IsOneByte(Vector<const char> str, int chars) {
// TODO(dcarney): incorporate Latin-1 check when Latin-1 is supported?
- // ASCII only check.
return chars == str.length();
}
Vector<const uint8_t> str, uint32_t hash_field) {
CHECK_GE(String::kMaxLength, str.length());
// Compute map and object size.
- Map* map = ascii_internalized_string_map();
+ Map* map = one_byte_internalized_string_map();
int size = SeqOneByteString::SizeFor(str.length());
AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED);
ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string)
undetectable_string_map()->set_is_undetectable();
- ALLOCATE_VARSIZE_MAP(ASCII_STRING_TYPE, undetectable_ascii_string);
- undetectable_ascii_string_map()->set_is_undetectable();
+ ALLOCATE_VARSIZE_MAP(ONE_BYTE_STRING_TYPE, undetectable_one_byte_string);
+ undetectable_one_byte_string_map()->set_is_undetectable();
ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array)
ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array)
static inline void WriteOneByteData(Vector<const char> vector, uint8_t* chars,
int len) {
- // Only works for ascii.
+ // Only works for one byte strings.
DCHECK(vector.length() == len);
MemCopy(chars, vector.start(), len);
}
DCHECK_LE(0, chars);
DCHECK_GE(String::kMaxLength, chars);
if (is_one_byte) {
- map = ascii_internalized_string_map();
+ map = one_byte_internalized_string_map();
size = SeqOneByteString::SizeFor(chars);
} else {
map = internalized_string_map();
}
// Partially initialize the object.
- result->set_map_no_write_barrier(ascii_string_map());
+ result->set_map_no_write_barrier(one_byte_string_map());
String::cast(result)->set_length(length);
String::cast(result)->set_hash_field(String::kEmptyHashField);
DCHECK_EQ(size, HeapObject::cast(result)->Size());
V(Smi, hash_seed, HashSeed) \
V(Map, symbol_map, SymbolMap) \
V(Map, string_map, StringMap) \
- V(Map, ascii_string_map, AsciiStringMap) \
+ V(Map, one_byte_string_map, OneByteStringMap) \
V(Map, cons_string_map, ConsStringMap) \
- V(Map, cons_ascii_string_map, ConsAsciiStringMap) \
+ V(Map, cons_one_byte_string_map, ConsOneByteStringMap) \
V(Map, sliced_string_map, SlicedStringMap) \
- V(Map, sliced_ascii_string_map, SlicedAsciiStringMap) \
+ V(Map, sliced_one_byte_string_map, SlicedOneByteStringMap) \
V(Map, external_string_map, ExternalStringMap) \
V(Map, external_string_with_one_byte_data_map, \
ExternalStringWithOneByteDataMap) \
- V(Map, external_ascii_string_map, ExternalAsciiStringMap) \
+ V(Map, external_one_byte_string_map, ExternalOneByteStringMap) \
V(Map, short_external_string_map, ShortExternalStringMap) \
V(Map, short_external_string_with_one_byte_data_map, \
ShortExternalStringWithOneByteDataMap) \
V(Map, internalized_string_map, InternalizedStringMap) \
- V(Map, ascii_internalized_string_map, AsciiInternalizedStringMap) \
+ V(Map, one_byte_internalized_string_map, OneByteInternalizedStringMap) \
V(Map, external_internalized_string_map, ExternalInternalizedStringMap) \
V(Map, external_internalized_string_with_one_byte_data_map, \
ExternalInternalizedStringWithOneByteDataMap) \
- V(Map, external_ascii_internalized_string_map, \
- ExternalAsciiInternalizedStringMap) \
+ V(Map, external_one_byte_internalized_string_map, \
+ ExternalOneByteInternalizedStringMap) \
V(Map, short_external_internalized_string_map, \
ShortExternalInternalizedStringMap) \
V(Map, short_external_internalized_string_with_one_byte_data_map, \
ShortExternalInternalizedStringWithOneByteDataMap) \
- V(Map, short_external_ascii_internalized_string_map, \
- ShortExternalAsciiInternalizedStringMap) \
- V(Map, short_external_ascii_string_map, ShortExternalAsciiStringMap) \
+ V(Map, short_external_one_byte_internalized_string_map, \
+ ShortExternalOneByteInternalizedStringMap) \
+ V(Map, short_external_one_byte_string_map, ShortExternalOneByteStringMap) \
V(Map, undetectable_string_map, UndetectableStringMap) \
- V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \
+ V(Map, undetectable_one_byte_string_map, UndetectableOneByteStringMap) \
V(Map, external_int8_array_map, ExternalInt8ArrayMap) \
V(Map, external_uint8_array_map, ExternalUint8ArrayMap) \
V(Map, external_int16_array_map, ExternalInt16ArrayMap) \
Object* filler);
// Allocate and partially initializes a String. There are two String
- // encodings: ASCII and two byte. These functions allocate a string of the
- // given length and set its map and length fields. The characters of the
- // string are uninitialized.
+ // encodings: one-byte and two-byte. These functions allocate a string of
+ // the given length and set its map and length fields. The characters of
+ // the string are uninitialized.
MUST_USE_RESULT AllocationResult
AllocateRawOneByteString(int length, PretenureFlag pretenure);
MUST_USE_RESULT AllocationResult
// Computes a single character string where the character has code.
- // A cache is used for ASCII codes.
+ // A cache is used for one-byte (Latin1) codes.
MUST_USE_RESULT AllocationResult
LookupSingleCharacterStringFromCode(uint16_t code);
static const int kRegExpCodeThreshold = 5;
static void UpdateRegExpCodeAgeAndFlush(Heap* heap, JSRegExp* re,
- bool is_ascii) {
+ bool is_one_byte) {
// Make sure that the fixed array is in fact initialized on the RegExp.
// We could potentially trigger a GC when initializing the RegExp.
if (HeapObject::cast(re->data())->map()->instance_type() !=
// Make sure this is a RegExp that actually contains code.
if (re->TypeTag() != JSRegExp::IRREGEXP) return;
- Object* code = re->DataAt(JSRegExp::code_index(is_ascii));
+ Object* code = re->DataAt(JSRegExp::code_index(is_one_byte));
if (!code->IsSmi() &&
HeapObject::cast(code)->map()->instance_type() == CODE_TYPE) {
// Save a copy that can be reinstated if we need the code again.
- re->SetDataAt(JSRegExp::saved_code_index(is_ascii), code);
+ re->SetDataAt(JSRegExp::saved_code_index(is_one_byte), code);
// Saving a copy might create a pointer into compaction candidate
// that was not observed by marker. This might happen if JSRegExp data
// was marked through the compilation cache before marker reached JSRegExp
// object.
FixedArray* data = FixedArray::cast(re->data());
- Object** slot = data->data_start() + JSRegExp::saved_code_index(is_ascii);
+ Object** slot =
+ data->data_start() + JSRegExp::saved_code_index(is_one_byte);
heap->mark_compact_collector()->RecordSlot(slot, slot, code);
// Set a number in the 0-255 range to guarantee no smi overflow.
- re->SetDataAt(JSRegExp::code_index(is_ascii),
+ re->SetDataAt(JSRegExp::code_index(is_one_byte),
Smi::FromInt(heap->sweep_generation() & 0xff));
} else if (code->IsSmi()) {
int value = Smi::cast(code)->value();
// Check if we should flush now.
if (value == ((heap->sweep_generation() - kRegExpCodeThreshold) & 0xff)) {
- re->SetDataAt(JSRegExp::code_index(is_ascii),
+ re->SetDataAt(JSRegExp::code_index(is_one_byte),
Smi::FromInt(JSRegExp::kUninitializedValue));
- re->SetDataAt(JSRegExp::saved_code_index(is_ascii),
+ re->SetDataAt(JSRegExp::saved_code_index(is_one_byte),
Smi::FromInt(JSRegExp::kUninitializedValue));
}
}
return;
}
JSRegExp* re = reinterpret_cast<JSRegExp*>(object);
- // Flush code or set age on both ASCII and two byte code.
+ // Flush code or set age on both one byte and two byte code.
UpdateRegExpCodeAgeAndFlush(heap, re, true);
UpdateRegExpCodeAgeAndFlush(heap, re, false);
// Visit the fields of the RegExp, including the updated FixedArray.
HInstruction* right_instance_type = AddLoadStringInstanceType(right);
// Allocate the cons string object. HAllocate does not care whether we
- // pass CONS_STRING_TYPE or CONS_ASCII_STRING_TYPE here, so we just use
+ // pass CONS_STRING_TYPE or CONS_ONE_BYTE_STRING_TYPE here, so we just use
// CONS_STRING_TYPE here. Below we decide whether the cons string is
// one-byte or two-byte and set the appropriate map.
DCHECK(HAllocate::CompatibleInstanceTypes(CONS_STRING_TYPE,
- CONS_ASCII_STRING_TYPE));
+ CONS_ONE_BYTE_STRING_TYPE));
HAllocate* result = BuildAllocate(Add<HConstant>(ConsString::kSize),
HType::String(), CONS_STRING_TYPE,
allocation_mode);
// We can safely skip the write barrier for storing the map here.
Add<HStoreNamedField>(
result, HObjectAccess::ForMap(),
- Add<HConstant>(isolate()->factory()->cons_ascii_string_map()));
+ Add<HConstant>(isolate()->factory()->cons_one_byte_string_map()));
}
if_onebyte.Else();
{
{
HConstant* string_map =
Add<HConstant>(isolate()->factory()->string_map());
- HConstant* ascii_string_map =
- Add<HConstant>(isolate()->factory()->ascii_string_map());
+ HConstant* one_byte_string_map =
+ Add<HConstant>(isolate()->factory()->one_byte_string_map());
// Determine map and size depending on whether result is one-byte string.
IfBuilder if_onebyte(this);
{
// Allocate sequential one-byte string object.
Push(length);
- Push(ascii_string_map);
+ Push(one_byte_string_map);
}
if_onebyte.Else();
{
HValue* size = BuildObjectSizeAlignment(Pop(), SeqString::kHeaderSize);
// Allocate the string object. HAllocate does not care whether we pass
- // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here.
+ // STRING_TYPE or ONE_BYTE_STRING_TYPE here, so we just use STRING_TYPE.
HAllocate* result = BuildAllocate(
size, HType::String(), STRING_TYPE, allocation_mode);
Add<HStoreNamedField>(result, HObjectAccess::ForMap(), map);
Literal* literal = expr->right()->AsLiteral();
if (literal == NULL) return false;
if (!literal->value()->IsString()) return false;
- if (!call->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_ClassOf"))) {
+ if (!call->name()->IsOneByteEqualTo(STATIC_CHAR_VECTOR("_ClassOf"))) {
return false;
}
DCHECK(call->arguments()->length() == 1);
}
-void HOptimizedGraphBuilder::GenerateFastAsciiArrayJoin(CallRuntime* call) {
- return Bailout(kInlinedRuntimeFunctionFastAsciiArrayJoin);
+void HOptimizedGraphBuilder::GenerateFastOneByteArrayJoin(CallRuntime* call) {
+ return Bailout(kInlinedRuntimeFunctionFastOneByteArrayJoin);
}
icu::UnicodeString pattern;
date_format->toPattern(pattern);
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("pattern"),
+ resolved, factory->NewStringFromStaticChars("pattern"),
factory->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
- pattern.length())).ToHandleChecked(),
+ Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
+ pattern.length())).ToHandleChecked(),
SLOPPY).Assert();
// Set time zone and calendar.
const icu::Calendar* calendar = date_format->getCalendar();
const char* calendar_name = calendar->getType();
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("calendar"),
- factory->NewStringFromAsciiChecked(calendar_name),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("calendar"),
+ factory->NewStringFromAsciiChecked(calendar_name),
+ SLOPPY).Assert();
const icu::TimeZone& tz = calendar->getTimeZone();
icu::UnicodeString time_zone;
if (U_SUCCESS(status)) {
if (canonical_time_zone == UNICODE_STRING_SIMPLE("Etc/GMT")) {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("timeZone"),
- factory->NewStringFromStaticAscii("UTC"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("timeZone"),
+ factory->NewStringFromStaticChars("UTC"), SLOPPY).Assert();
} else {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("timeZone"),
+ resolved, factory->NewStringFromStaticChars("timeZone"),
factory->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(
- canonical_time_zone.getBuffer()),
- canonical_time_zone.length())).ToHandleChecked(),
+ Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(
+ canonical_time_zone.getBuffer()),
+ canonical_time_zone.length())).ToHandleChecked(),
SLOPPY).Assert();
}
}
if (U_SUCCESS(status)) {
const char* ns = numbering_system->getName();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("numberingSystem"),
- factory->NewStringFromAsciiChecked(ns),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("numberingSystem"),
+ factory->NewStringFromAsciiChecked(ns), SLOPPY).Assert();
} else {
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("numberingSystem"),
- factory->undefined_value(),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved,
+ factory->NewStringFromStaticChars("numberingSystem"),
+ factory->undefined_value(), SLOPPY).Assert();
}
delete numbering_system;
uloc_toLanguageTag(
icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
if (U_SUCCESS(status)) {
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromAsciiChecked(result),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromAsciiChecked(result),
+ SLOPPY).Assert();
} else {
// This would never happen, since we got the locale from ICU.
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromStaticAscii("und"),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromStaticChars("und"),
+ SLOPPY).Assert();
}
}
icu::UnicodeString pattern;
number_format->toPattern(pattern);
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("pattern"),
+ resolved, factory->NewStringFromStaticChars("pattern"),
factory->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
- pattern.length())).ToHandleChecked(),
+ Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(pattern.getBuffer()),
+ pattern.length())).ToHandleChecked(),
SLOPPY).Assert();
// Set resolved currency code in options.currency if not empty.
icu::UnicodeString currency(number_format->getCurrency());
if (!currency.isEmpty()) {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("currency"),
- factory->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(currency.getBuffer()),
- currency.length())).ToHandleChecked(),
+ resolved, factory->NewStringFromStaticChars("currency"),
+ factory->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(
+ currency.getBuffer()),
+ currency.length())).ToHandleChecked(),
SLOPPY).Assert();
}
if (U_SUCCESS(status)) {
const char* ns = numbering_system->getName();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("numberingSystem"),
- factory->NewStringFromAsciiChecked(ns),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("numberingSystem"),
+ factory->NewStringFromAsciiChecked(ns), SLOPPY).Assert();
} else {
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("numberingSystem"),
- factory->undefined_value(),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved,
+ factory->NewStringFromStaticChars("numberingSystem"),
+ factory->undefined_value(), SLOPPY).Assert();
}
delete numbering_system;
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("useGrouping"),
- factory->ToBoolean(number_format->isGroupingUsed()),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("useGrouping"),
+ factory->ToBoolean(number_format->isGroupingUsed()), SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("minimumIntegerDigits"),
+ resolved, factory->NewStringFromStaticChars("minimumIntegerDigits"),
factory->NewNumberFromInt(number_format->getMinimumIntegerDigits()),
SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("minimumFractionDigits"),
+ resolved, factory->NewStringFromStaticChars("minimumFractionDigits"),
factory->NewNumberFromInt(number_format->getMinimumFractionDigits()),
SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("maximumFractionDigits"),
+ resolved, factory->NewStringFromStaticChars("maximumFractionDigits"),
factory->NewNumberFromInt(number_format->getMaximumFractionDigits()),
SLOPPY).Assert();
Handle<String> key =
- factory->NewStringFromStaticAscii("minimumSignificantDigits");
+ factory->NewStringFromStaticChars("minimumSignificantDigits");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(resolved, key);
CHECK(maybe.has_value);
if (maybe.value) {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("minimumSignificantDigits"),
+ resolved, factory->NewStringFromStaticChars("minimumSignificantDigits"),
factory->NewNumberFromInt(number_format->getMinimumSignificantDigits()),
SLOPPY).Assert();
}
- key = factory->NewStringFromStaticAscii("maximumSignificantDigits");
+ key = factory->NewStringFromStaticChars("maximumSignificantDigits");
maybe = JSReceiver::HasOwnProperty(resolved, key);
CHECK(maybe.has_value);
if (maybe.value) {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("maximumSignificantDigits"),
+ resolved, factory->NewStringFromStaticChars("maximumSignificantDigits"),
factory->NewNumberFromInt(number_format->getMaximumSignificantDigits()),
SLOPPY).Assert();
}
uloc_toLanguageTag(
icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
if (U_SUCCESS(status)) {
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromAsciiChecked(result),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromAsciiChecked(result),
+ SLOPPY).Assert();
} else {
// This would never happen, since we got the locale from ICU.
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromStaticAscii("und"),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromStaticChars("und"),
+ SLOPPY).Assert();
}
}
UErrorCode status = U_ZERO_ERROR;
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("numeric"),
+ resolved, factory->NewStringFromStaticChars("numeric"),
factory->ToBoolean(
collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON),
SLOPPY).Assert();
switch (collator->getAttribute(UCOL_CASE_FIRST, status)) {
case UCOL_LOWER_FIRST:
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("caseFirst"),
- factory->NewStringFromStaticAscii("lower"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("caseFirst"),
+ factory->NewStringFromStaticChars("lower"), SLOPPY).Assert();
break;
case UCOL_UPPER_FIRST:
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("caseFirst"),
- factory->NewStringFromStaticAscii("upper"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("caseFirst"),
+ factory->NewStringFromStaticChars("upper"), SLOPPY).Assert();
break;
default:
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("caseFirst"),
- factory->NewStringFromStaticAscii("false"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("caseFirst"),
+ factory->NewStringFromStaticChars("false"), SLOPPY).Assert();
}
switch (collator->getAttribute(UCOL_STRENGTH, status)) {
case UCOL_PRIMARY: {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("strength"),
- factory->NewStringFromStaticAscii("primary"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("strength"),
+ factory->NewStringFromStaticChars("primary"), SLOPPY).Assert();
// case level: true + s1 -> case, s1 -> base.
if (UCOL_ON == collator->getAttribute(UCOL_CASE_LEVEL, status)) {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("sensitivity"),
- factory->NewStringFromStaticAscii("case"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("sensitivity"),
+ factory->NewStringFromStaticChars("case"), SLOPPY).Assert();
} else {
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("sensitivity"),
- factory->NewStringFromStaticAscii("base"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("sensitivity"),
+ factory->NewStringFromStaticChars("base"), SLOPPY).Assert();
}
break;
}
case UCOL_SECONDARY:
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("strength"),
- factory->NewStringFromStaticAscii("secondary"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("strength"),
+ factory->NewStringFromStaticChars("secondary"), SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("sensitivity"),
- factory->NewStringFromStaticAscii("accent"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("sensitivity"),
+ factory->NewStringFromStaticChars("accent"), SLOPPY).Assert();
break;
case UCOL_TERTIARY:
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("strength"),
- factory->NewStringFromStaticAscii("tertiary"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("strength"),
+ factory->NewStringFromStaticChars("tertiary"), SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("sensitivity"),
- factory->NewStringFromStaticAscii("variant"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("sensitivity"),
+ factory->NewStringFromStaticChars("variant"), SLOPPY).Assert();
break;
case UCOL_QUATERNARY:
// We shouldn't get quaternary and identical from ICU, but if we do
// put them into variant.
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("strength"),
- factory->NewStringFromStaticAscii("quaternary"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("strength"),
+ factory->NewStringFromStaticChars("quaternary"), SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("sensitivity"),
- factory->NewStringFromStaticAscii("variant"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("sensitivity"),
+ factory->NewStringFromStaticChars("variant"), SLOPPY).Assert();
break;
default:
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("strength"),
- factory->NewStringFromStaticAscii("identical"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("strength"),
+ factory->NewStringFromStaticChars("identical"), SLOPPY).Assert();
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("sensitivity"),
- factory->NewStringFromStaticAscii("variant"),
- SLOPPY).Assert();
+ resolved, factory->NewStringFromStaticChars("sensitivity"),
+ factory->NewStringFromStaticChars("variant"), SLOPPY).Assert();
}
JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("ignorePunctuation"),
- factory->ToBoolean(collator->getAttribute(
- UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED),
+ resolved, factory->NewStringFromStaticChars("ignorePunctuation"),
+ factory->ToBoolean(collator->getAttribute(UCOL_ALTERNATE_HANDLING,
+ status) == UCOL_SHIFTED),
SLOPPY).Assert();
// Set the locale
uloc_toLanguageTag(
icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
if (U_SUCCESS(status)) {
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromAsciiChecked(result),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromAsciiChecked(result),
+ SLOPPY).Assert();
} else {
// This would never happen, since we got the locale from ICU.
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromStaticAscii("und"),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromStaticChars("und"),
+ SLOPPY).Assert();
}
}
uloc_toLanguageTag(
icu_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
if (U_SUCCESS(status)) {
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromAsciiChecked(result),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromAsciiChecked(result),
+ SLOPPY).Assert();
} else {
// This would never happen, since we got the locale from ICU.
- JSObject::SetProperty(
- resolved,
- factory->NewStringFromStaticAscii("locale"),
- factory->NewStringFromStaticAscii("und"),
- SLOPPY).Assert();
+ JSObject::SetProperty(resolved, factory->NewStringFromStaticChars("locale"),
+ factory->NewStringFromStaticChars("und"),
+ SLOPPY).Assert();
}
}
Isolate* isolate,
Handle<JSObject> obj) {
Handle<String> key =
- isolate->factory()->NewStringFromStaticAscii("dateFormat");
+ isolate->factory()->NewStringFromStaticChars("dateFormat");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
Isolate* isolate,
Handle<JSObject> obj) {
Handle<String> key =
- isolate->factory()->NewStringFromStaticAscii("numberFormat");
+ isolate->factory()->NewStringFromStaticChars("numberFormat");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
icu::Collator* Collator::UnpackCollator(Isolate* isolate,
Handle<JSObject> obj) {
- Handle<String> key = isolate->factory()->NewStringFromStaticAscii("collator");
+ Handle<String> key = isolate->factory()->NewStringFromStaticChars("collator");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate,
Handle<JSObject> obj) {
Handle<String> key =
- isolate->factory()->NewStringFromStaticAscii("breakIterator");
+ isolate->factory()->NewStringFromStaticChars("breakIterator");
Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
CHECK(maybe.has_value);
if (maybe.value) {
__ JumpIfNotSmi(ebx, &runtime);
__ cmp(ebx, FieldOperand(edx, String::kLengthOffset));
__ j(above_equal, &runtime);
- __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset));
+ __ mov(edx, FieldOperand(ecx, JSRegExp::kDataOneByteCodeOffset));
__ Move(ecx, Immediate(1)); // Type is one byte.
// (E) Carry on. String handling is done.
// eax: subject string
// ebx: previous index (smi)
// edx: code
- // ecx: encoding of subject string (1 if ASCII, 0 if two_byte);
+ // ecx: encoding of subject string (1 if one_byte, 0 if two_byte);
// All checks done. Now push arguments for native regexp code.
Counters* counters = isolate()->counters();
__ IncrementCounter(counters->regexp_entry_native(), 1);
// esi: original subject string
// eax: underlying subject string
// ebx: previous index
- // ecx: encoding of subject string (1 if ASCII 0 if two_byte);
+ // ecx: encoding of subject string (1 if one_byte 0 if two_byte);
// edx: code
// Argument 4: End of string data
// Argument 3: Start of string data
__ bind(&check_for_strings);
- __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx,
- &check_unequal_objects);
+ __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx,
+ &check_unequal_objects);
- // Inline comparison of ASCII strings.
+ // Inline comparison of one-byte strings.
if (cc == equal) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, edx, eax, ecx, ebx);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, edx, eax, ecx, ebx);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx,
- edi);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
+ edi);
}
#ifdef DEBUG
__ Abort(kUnexpectedFallThroughFromStringComparison);
STATIC_ASSERT(kSmiTag == 0);
STATIC_ASSERT(kSmiTagSize == 1);
STATIC_ASSERT(kSmiShiftSize == 0);
- // At this point code register contains smi tagged ASCII char code.
+ // At this point code register contains smi tagged one byte char code.
__ mov(result_, FieldOperand(result_,
code_, times_half_pointer_size,
FixedArray::kHeaderSize));
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ test(ebx, Immediate(kStringEncodingMask));
__ j(zero, &two_byte_slice, Label::kNear);
- __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime);
+ __ AllocateOneByteSlicedString(eax, ebx, no_reg, &runtime);
__ jmp(&set_slice_header, Label::kNear);
__ bind(&two_byte_slice);
__ AllocateTwoByteSlicedString(eax, ebx, no_reg, &runtime);
__ test_b(ebx, kStringEncodingMask);
__ j(zero, &two_byte_sequential);
- // Sequential ASCII string. Allocate the result.
- __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime_drop_two);
+ // Sequential one byte string. Allocate the result.
+ __ AllocateOneByteString(eax, ecx, ebx, edx, edi, &runtime_drop_two);
// eax: result string
// ecx: result string length
}
-void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left, Register right,
- Register scratch1,
- Register scratch2) {
+void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
+ Register left,
+ Register right,
+ Register scratch1,
+ Register scratch2) {
Register length = scratch1;
// Compare lengths.
// Compare characters.
__ bind(&compare_chars);
- GenerateAsciiCharsCompareLoop(masm, left, right, length, scratch2,
- &strings_not_equal, Label::kNear);
+ GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2,
+ &strings_not_equal, Label::kNear);
// Characters are equal.
__ Move(eax, Immediate(Smi::FromInt(EQUAL)));
}
-void StringHelper::GenerateCompareFlatAsciiStrings(
+void StringHelper::GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3) {
Counters* counters = masm->isolate()->counters();
// Compare characters.
Label result_not_equal;
- GenerateAsciiCharsCompareLoop(masm, left, right, min_length, scratch2,
- &result_not_equal, Label::kNear);
+ GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2,
+ &result_not_equal, Label::kNear);
// Compare lengths - strings up to min-length are equal.
__ bind(&compare_lengths);
}
-void StringHelper::GenerateAsciiCharsCompareLoop(
+void StringHelper::GenerateOneByteCharsCompareLoop(
MacroAssembler* masm, Register left, Register right, Register length,
Register scratch, Label* chars_not_equal,
Label::Distance chars_not_equal_near) {
__ bind(¬_same);
- // Check that both objects are sequential ASCII strings.
- __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx, &runtime);
+ // Check that both objects are sequential one-byte strings.
+ __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime);
- // Compare flat ASCII strings.
+ // Compare flat one-byte strings.
// Drop arguments from the stack.
__ pop(ecx);
__ add(esp, Immediate(2 * kPointerSize));
__ push(ecx);
- StringHelper::GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
+ edi);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ bind(&do_compare);
}
- // Check that both strings are sequential ASCII.
+ // Check that both strings are sequential one-byte.
Label runtime;
- __ JumpIfNotBothSequentialAsciiStrings(left, right, tmp1, tmp2, &runtime);
+ __ JumpIfNotBothSequentialOneByteStrings(left, right, tmp1, tmp2, &runtime);
- // Compare flat ASCII strings. Returns when done.
+ // Compare flat one byte strings. Returns when done.
if (equality) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1,
+ tmp2);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
- tmp3);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1,
+ tmp2, tmp3);
}
// Handle more complex cases in runtime.
Register scratch,
String::Encoding encoding);
- // Compares two flat ASCII strings and returns result in eax.
- static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
+ // Compares two flat one byte strings and returns result in eax.
+ static void GenerateCompareFlatOneByteStrings(MacroAssembler* masm,
+ Register left, Register right,
+ Register scratch1,
+ Register scratch2,
+ Register scratch3);
+
+ // Compares two flat one byte strings for equality and returns result in eax.
+ static void GenerateFlatOneByteStringEquals(MacroAssembler* masm,
Register left, Register right,
Register scratch1,
- Register scratch2,
- Register scratch3);
-
- // Compares two flat ASCII strings for equality and returns result in eax.
- static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left,
- Register right,
- Register scratch1,
- Register scratch2);
+ Register scratch2);
private:
- static void GenerateAsciiCharsCompareLoop(
- MacroAssembler* masm,
- Register left,
- Register right,
- Register length,
- Register scratch,
- Label* chars_not_equal,
+ static void GenerateOneByteCharsCompareLoop(
+ MacroAssembler* masm, Register left, Register right, Register length,
+ Register scratch, Label* chars_not_equal,
Label::Distance chars_not_equal_near = Label::kFar);
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
__ j(zero, &seq_string, Label::kNear);
// Handle external strings.
- Label ascii_external, done;
+ Label one_byte_external, done;
if (FLAG_debug_code) {
// Assert that we do not have a cons or slice (indirect strings) here.
// Sequential strings have already been ruled out.
STATIC_ASSERT(kTwoByteStringTag == 0);
__ test_b(result, kStringEncodingMask);
__ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset));
- __ j(not_equal, &ascii_external, Label::kNear);
+ __ j(not_equal, &one_byte_external, Label::kNear);
// Two-byte string.
__ movzx_w(result, Operand(result, index, times_2, 0));
__ jmp(&done, Label::kNear);
- __ bind(&ascii_external);
- // Ascii string.
+ __ bind(&one_byte_external);
+ // One-byte string.
__ movzx_b(result, Operand(result, index, times_1, 0));
__ jmp(&done, Label::kNear);
- // Dispatch on the encoding: ASCII or two-byte.
- Label ascii;
+ // Dispatch on the encoding: one-byte or two-byte.
+ Label one_byte;
__ bind(&seq_string);
STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0);
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ test(result, Immediate(kStringEncodingMask));
- __ j(not_zero, &ascii, Label::kNear);
+ __ j(not_zero, &one_byte, Label::kNear);
// Two-byte string.
// Load the two-byte character code into the result register.
SeqTwoByteString::kHeaderSize));
__ jmp(&done, Label::kNear);
- // Ascii string.
+ // One-byte string.
// Load the byte into the result register.
- __ bind(&ascii);
+ __ bind(&one_byte);
__ movzx_b(result, FieldOperand(string,
index,
times_1,
}
-void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
+void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
Label bailout, done, one_char_separator, long_separator,
non_trivial_array, not_size_one_array, loop,
loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
array = no_reg;
- // Check that all array elements are sequential ASCII strings, and
+ // Check that all array elements are sequential one-byte strings, and
// accumulate the sum of their lengths, as a smi-encoded value.
__ Move(index, Immediate(0));
__ Move(string_length, Immediate(0));
// scratch, string_length, elements.
if (generate_debug_code_) {
__ cmp(index, array_length);
- __ Assert(less, kNoEmptyArraysHereInEmitFastAsciiArrayJoin);
+ __ Assert(less, kNoEmptyArraysHereInEmitFastOneByteArrayJoin);
}
__ bind(&loop);
__ mov(string, FieldOperand(elements,
// string_length: Sum of string lengths, as a smi.
// elements: FixedArray of strings.
- // Check that the separator is a flat ASCII string.
+ // Check that the separator is a flat one-byte string.
__ mov(string, separator_operand);
__ JumpIfSmi(string, &bailout);
__ mov(scratch, FieldOperand(string, HeapObject::kMapOffset));
// Live registers and stack values:
// string_length
// elements
- __ AllocateAsciiString(result_pos, string_length, scratch,
- index, string, &bailout);
+ __ AllocateOneByteString(result_pos, string_length, scratch, index, string,
+ &bailout);
__ mov(result_operand, result_pos);
__ lea(result_pos, FieldOperand(result_pos, SeqOneByteString::kHeaderSize));
// One-character separator case
__ bind(&one_char_separator);
- // Replace separator with its ASCII character value.
+ // Replace separator with its one-byte character value.
__ mov_b(scratch, FieldOperand(string, SeqOneByteString::kHeaderSize));
__ mov_b(separator_operand, scratch);
}
-void MacroAssembler::AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3,
+ Label* gc_required) {
// Calculate the number of bytes needed for the characters in the string while
// observing object alignment.
DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0);
add(scratch1, Immediate(kObjectAlignmentMask));
and_(scratch1, Immediate(~kObjectAlignmentMask));
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(SeqOneByteString::kHeaderSize,
times_1,
scratch1,
// Set the map, length and hash field.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->ascii_string_map()));
+ Immediate(isolate()->factory()->one_byte_string_map()));
mov(scratch1, length);
SmiTag(scratch1);
mov(FieldOperand(result, String::kLengthOffset), scratch1);
}
-void MacroAssembler::AllocateAsciiString(Register result,
- int length,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteString(Register result, int length,
+ Register scratch1, Register scratch2,
+ Label* gc_required) {
DCHECK(length > 0);
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(SeqOneByteString::SizeFor(length), result, scratch1, scratch2,
gc_required, TAG_OBJECT);
// Set the map, length and hash field.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->ascii_string_map()));
+ Immediate(isolate()->factory()->one_byte_string_map()));
mov(FieldOperand(result, String::kLengthOffset),
Immediate(Smi::FromInt(length)));
mov(FieldOperand(result, String::kHashFieldOffset),
}
-void MacroAssembler::AllocateAsciiConsString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteConsString(Register result,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
Allocate(ConsString::kSize,
result,
scratch1,
// Set the map. The other fields are left uninitialized.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->cons_ascii_string_map()));
+ Immediate(isolate()->factory()->cons_one_byte_string_map()));
}
}
-void MacroAssembler::AllocateAsciiSlicedString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteSlicedString(Register result,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
// Allocate heap number in new space.
Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
TAG_OBJECT);
// Set the map. The other fields are left uninitialized.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->sliced_ascii_string_map()));
+ Immediate(isolate()->factory()->sliced_one_byte_string_map()));
}
}
-void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(
- Register instance_type,
- Register scratch,
- Label* failure) {
+void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(
+ Register instance_type, Register scratch, Label* failure) {
if (!scratch.is(instance_type)) {
mov(scratch, instance_type);
}
}
-void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register object1,
- Register object2,
- Register scratch1,
- Register scratch2,
- Label* failure) {
+void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register object1,
+ Register object2,
+ Register scratch1,
+ Register scratch2,
+ Label* failure) {
// Check that both objects are not smis.
STATIC_ASSERT(kSmiTag == 0);
mov(scratch1, object1);
movzx_b(scratch1, FieldOperand(scratch1, Map::kInstanceTypeOffset));
movzx_b(scratch2, FieldOperand(scratch2, Map::kInstanceTypeOffset));
- // Check that both are flat ASCII strings.
- const int kFlatAsciiStringMask =
+ // Check that both are flat one-byte strings.
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
// Interleave bits from both instance types and compare them in one check.
- DCHECK_EQ(0, kFlatAsciiStringMask & (kFlatAsciiStringMask << 3));
- and_(scratch1, kFlatAsciiStringMask);
- and_(scratch2, kFlatAsciiStringMask);
+ DCHECK_EQ(0, kFlatOneByteStringMask & (kFlatOneByteStringMask << 3));
+ and_(scratch1, kFlatOneByteStringMask);
+ and_(scratch2, kFlatOneByteStringMask);
lea(scratch1, Operand(scratch1, scratch2, times_8, 0));
- cmp(scratch1, kFlatAsciiStringTag | (kFlatAsciiStringTag << 3));
+ cmp(scratch1, kFlatOneByteStringTag | (kFlatOneByteStringTag << 3));
j(not_equal, failure);
}
jmp(&is_data_object, Label::kNear);
bind(¬_external);
- // Sequential string, either ASCII or UC16.
+ // Sequential string, either Latin1 or UC16.
DCHECK(kOneByteStringTag == 0x04);
and_(length, Immediate(kStringEncodingMask));
xor_(length, Immediate(kStringEncodingMask));
add(length, Immediate(0x04));
- // Value now either 4 (if ASCII) or 8 (if UC16), i.e., char-size shifted
+ // Value now either 4 (if Latin1) or 8 (if UC16), i.e., char-size shifted
// by 2. If we multiply the string length as smi by this, it still
// won't overflow a 32-bit value.
DCHECK_EQ(SeqOneByteString::kMaxSize, SeqTwoByteString::kMaxSize);
Register scratch2,
Register scratch3,
Label* gc_required);
- void AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required);
- void AllocateAsciiString(Register result,
- int length,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3, Label* gc_required);
+ void AllocateOneByteString(Register result, int length, Register scratch1,
+ Register scratch2, Label* gc_required);
// Allocate a raw cons string object. Only the map field of the result is
// initialized.
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiConsString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteConsString(Register result, Register scratch1,
+ Register scratch2, Label* gc_required);
// Allocate a raw sliced string object. Only the map field of the result is
// initialized.
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiSlicedString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteSlicedString(Register result, Register scratch1,
+ Register scratch2, Label* gc_required);
// Copy memory, byte-by-byte, from source to destination. Not optimized for
// long or aligned copies.
Register scratch2,
Label* not_found);
- // Check whether the instance type represents a flat ASCII string. Jump to the
- // label if not. If the instance type can be scratched specify same register
- // for both instance type and scratch.
- void JumpIfInstanceTypeIsNotSequentialAscii(Register instance_type,
- Register scratch,
- Label* on_not_flat_ascii_string);
+ // Check whether the instance type represents a flat one-byte string. Jump to
+ // the label if not. If the instance type can be scratched specify same
+ // register for both instance type and scratch.
+ void JumpIfInstanceTypeIsNotSequentialOneByte(
+ Register instance_type, Register scratch,
+ Label* on_not_flat_one_byte_string);
- // Checks if both objects are sequential ASCII strings, and jumps to label
+ // Checks if both objects are sequential one-byte strings, and jumps to label
// if either is not.
- void JumpIfNotBothSequentialAsciiStrings(Register object1,
- Register object2,
- Register scratch1,
- Register scratch2,
- Label* on_not_flat_ascii_strings);
+ void JumpIfNotBothSequentialOneByteStrings(
+ Register object1, Register object2, Register scratch1, Register scratch2,
+ Label* on_not_flat_one_byte_strings);
// Checks if the given register or operand is a unique name
void JumpIfNotUniqueName(Register reg, Label* not_unique_name,
__ add(eax, ebx);
BranchOrBacktrack(greater, on_no_match);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
Label success;
Label fail;
Label loop_increment;
Label loop;
__ bind(&loop);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
__ movzx_b(eax, Operand(edx, 0));
__ cmpb_al(Operand(ebx, 0));
} else {
Label* on_bit_set) {
__ mov(eax, Immediate(table));
Register index = current_character();
- if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) {
+ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) {
__ mov(ebx, kTableSize - 1);
__ and_(ebx, current_character());
index = ebx;
switch (type) {
case 's':
// Match space-characters
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
Label success;
__ cmp(current_character(), ' ');
return true;
}
case 'w': {
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ cmp(current_character(), Immediate('z'));
BranchOrBacktrack(above, on_no_match);
}
}
case 'W': {
Label done;
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ cmp(current_character(), Immediate('z'));
__ j(above, &done);
}
__ test_b(current_character(),
Operand::StaticArray(current_character(), times_1, word_map));
BranchOrBacktrack(not_zero, on_no_match);
- if (mode_ != ASCII) {
+ if (mode_ != LATIN1) {
__ bind(&done);
}
return true;
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c
__ sub(eax, Immediate(0x0b));
__ cmp(eax, 0x0c - 0x0b);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
BranchOrBacktrack(above, on_no_match);
} else {
Label done;
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
- bool is_ascii = subject->IsOneByteRepresentationUnderneath();
+ bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
DCHECK(re_code->instruction_start() <= *return_address);
DCHECK(*return_address <=
}
// String might have changed.
- if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
- // If we changed between an ASCII and an UC16 string, the specialized
+ if (subject_tmp->IsOneByteRepresentation() != is_one_byte) {
+ // If we changed between an LATIN1 and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).
return RETRY;
void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset,
int characters) {
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
if (characters == 4) {
__ mov(current_character(), Operand(esi, edi, times_1, cp_offset));
} else if (characters == 2) {
MacroAssembler* masm_;
- // Which mode to generate code for (ASCII or UC16).
+ // Which mode to generate code for (LATIN1 or UC16).
Mode mode_;
// One greater than maximal register index actually used.
const byte* code_base = code_array->GetDataStartAddress();
uc16 previous_char = '\n';
String::FlatContent subject_content = subject->GetFlatContent();
- if (subject_content.IsAscii()) {
+ if (subject_content.IsOneByte()) {
Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector();
if (start_position != 0) previous_char = subject_vector[start_position - 1];
return RawMatch(isolate,
Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit);
Handle<String> column_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("column"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("column"));
Handle<String> line_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("lineNumber"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("lineNumber"));
Handle<String> script_id_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("scriptId"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptId"));
Handle<String> script_name_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("scriptName"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptName"));
Handle<String> script_name_or_source_url_key =
factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("scriptNameOrSourceURL"));
+ STATIC_CHAR_VECTOR("scriptNameOrSourceURL"));
Handle<String> function_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("functionName"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("functionName"));
Handle<String> eval_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("isEval"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval"));
Handle<String> constructor_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("isConstructor"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isConstructor"));
StackTraceFrameIterator it(this);
int frames_seen = 0;
if (!obj->IsJSObject()) return false;
Handle<String> error_key =
- factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error"));
+ factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("$Error"));
Handle<Object> error_constructor = Object::GetProperty(
js_builtins_object(), error_key).ToHandleChecked();
Execution::ToDetailString(this, exception_arg);
if (!maybe_exception.ToHandle(&exception_arg)) {
exception_arg = factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("exception"));
+ STATIC_CHAR_VECTOR("exception"));
}
}
Handle<Object> message_obj = MessageHandler::MakeMessageObject(
namespace internal {
// A simple json parser.
-template <bool seq_ascii>
+template <bool seq_one_byte>
class JsonParser BASE_EMBEDDED {
public:
MUST_USE_RESULT static MaybeHandle<Object> Parse(Handle<String> source) {
source_ = String::Flatten(source_);
pretenure_ = (source_length_ >= kPretenureTreshold) ? TENURED : NOT_TENURED;
- // Optimized fast case where we only have ASCII characters.
- if (seq_ascii) {
+ // Optimized fast case where we only have Latin1 characters.
+ if (seq_one_byte) {
seq_source_ = Handle<SeqOneByteString>::cast(source_);
}
}
position_++;
if (position_ >= source_length_) {
c0_ = kEndOfString;
- } else if (seq_ascii) {
+ } else if (seq_one_byte) {
c0_ = seq_source_->SeqOneByteStringGet(position_);
} else {
c0_ = source_->Get(position_);
if (source_->length() - position_ - 1 > length) {
DisallowHeapAllocation no_gc;
String::FlatContent content = expected->GetFlatContent();
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
DCHECK_EQ('"', c0_);
const uint8_t* input_chars = seq_source_->GetChars() + position_ + 1;
const uint8_t* expected_chars = content.ToOneByteVector().start();
Handle<String> ScanJsonString();
// Creates a new string and copies prefix[start..end] into the beginning
// of it. Then scans the rest of the string, adding characters after the
- // prefix. Called by ScanJsonString when reaching a '\' or non-ASCII char.
+ // prefix. Called by ScanJsonString when reaching a '\' or non-Latin1 char.
template <typename StringType, typename SinkChar>
Handle<String> SlowScanJsonString(Handle<String> prefix, int start, int end);
int position_;
};
-template <bool seq_ascii>
-MaybeHandle<Object> JsonParser<seq_ascii>::ParseJson() {
+template <bool seq_one_byte>
+MaybeHandle<Object> JsonParser<seq_one_byte>::ParseJson() {
// Advance to the first character (possibly EOS)
AdvanceSkipWhitespace();
Handle<Object> result = ParseJsonValue();
// Parse any JSON value.
-template <bool seq_ascii>
-Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() {
+template <bool seq_one_byte>
+Handle<Object> JsonParser<seq_one_byte>::ParseJsonValue() {
StackLimitCheck stack_check(isolate_);
if (stack_check.HasOverflowed()) {
isolate_->StackOverflow();
// Parse a JSON object. Position must be right at '{'.
-template <bool seq_ascii>
-Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
+template <bool seq_one_byte>
+Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
HandleScope scope(isolate());
Handle<JSObject> json_object =
factory()->NewJSObject(object_constructor(), pretenure_);
// to parse it first.
bool follow_expected = false;
Handle<Map> target;
- if (seq_ascii) {
+ if (seq_one_byte) {
key = Map::ExpectedTransitionKey(map);
follow_expected = !key.is_null() && ParseJsonString(key);
}
}
// Parse a JSON array. Position must be right at '['.
-template <bool seq_ascii>
-Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
+template <bool seq_one_byte>
+Handle<Object> JsonParser<seq_one_byte>::ParseJsonArray() {
HandleScope scope(isolate());
ZoneList<Handle<Object> > elements(4, zone());
DCHECK_EQ(c0_, '[');
}
-template <bool seq_ascii>
-Handle<Object> JsonParser<seq_ascii>::ParseJsonNumber() {
+template <bool seq_one_byte>
+Handle<Object> JsonParser<seq_one_byte>::ParseJsonNumber() {
bool negative = false;
int beg_pos = position_;
if (c0_ == '-') {
}
int length = position_ - beg_pos;
double number;
- if (seq_ascii) {
+ if (seq_one_byte) {
Vector<const uint8_t> chars(seq_source_->GetChars() + beg_pos, length);
number = StringToDouble(isolate()->unicode_cache(),
chars,
// Scans the rest of a JSON string starting from position_ and writes
// prefix[start..end] along with the scanned characters into a
// sequential string of type StringType.
-template <bool seq_ascii>
+template <bool seq_one_byte>
template <typename StringType, typename SinkChar>
-Handle<String> JsonParser<seq_ascii>::SlowScanJsonString(
+Handle<String> JsonParser<seq_one_byte>::SlowScanJsonString(
Handle<String> prefix, int start, int end) {
int count = end - start;
int max_length = count + source_length_ - position_;
}
if (c0_ != '\\') {
// If the sink can contain UC16 characters, or source_ contains only
- // ASCII characters, there's no need to test whether we can store the
+ // Latin1 characters, there's no need to test whether we can store the
// character. Otherwise check whether the UC16 source character can fit
- // in the ASCII sink.
- if (sizeof(SinkChar) == kUC16Size ||
- seq_ascii ||
+ // in the Latin1 sink.
+ if (sizeof(SinkChar) == kUC16Size || seq_one_byte ||
c0_ <= String::kMaxOneByteCharCode) {
SeqStringSet(seq_string, count++, c0_);
Advance();
} else {
- // StringType is SeqOneByteString and we just read a non-ASCII char.
+ // StringType is SeqOneByteString and we just read a non-Latin1 char.
return SlowScanJsonString<SeqTwoByteString, uc16>(seq_string, 0, count);
}
} else {
SeqStringSet(seq_string, count++, value);
break;
} else {
- // StringType is SeqOneByteString and we just read a non-ASCII char.
+ // StringType is SeqOneByteString and we just read a non-Latin1
+ // char.
position_ -= 6; // Rewind position_ to \ in \uxxxx.
Advance();
return SlowScanJsonString<SeqTwoByteString, uc16>(seq_string,
}
-template <bool seq_ascii>
+template <bool seq_one_byte>
template <bool is_internalized>
-Handle<String> JsonParser<seq_ascii>::ScanJsonString() {
+Handle<String> JsonParser<seq_one_byte>::ScanJsonString() {
DCHECK_EQ('"', c0_);
Advance();
if (c0_ == '"') {
return factory()->empty_string();
}
- if (seq_ascii && is_internalized) {
+ if (seq_one_byte && is_internalized) {
// Fast path for existing internalized strings. If the the string being
// parsed is not a known internalized string, contains backslashes or
// unexpectedly reaches the end of string, return with an empty handle.
}
int beg_pos = position_;
- // Fast case for ASCII only without escape characters.
+ // Fast case for Latin1 only without escape characters.
do {
// Check for control character (0x00-0x1f) or unterminated string (<0).
if (c0_ < 0x20) return Handle<String>::null();
if (c0_ != '\\') {
- if (seq_ascii || c0_ <= String::kMaxOneByteCharCode) {
+ if (seq_one_byte || c0_ <= String::kMaxOneByteCharCode) {
Advance();
} else {
return SlowScanJsonString<SeqTwoByteString, uc16>(source_,
INLINE(void ShrinkCurrentPart());
- template <bool is_ascii, typename Char>
+ template <bool is_one_byte, typename Char>
INLINE(void Append_(Char c));
- template <bool is_ascii, typename Char>
+ template <bool is_one_byte, typename Char>
INLINE(void Append_(const Char* chars));
INLINE(void Append(uint8_t c)) {
- if (is_ascii_) {
+ if (is_one_byte_) {
Append_<true>(c);
} else {
Append_<false>(c);
}
}
- INLINE(void AppendAscii(const char* chars)) {
- if (is_ascii_) {
+ INLINE(void AppendOneByte(const char* chars)) {
+ if (is_one_byte_) {
Append_<true>(reinterpret_cast<const uint8_t*>(chars));
} else {
Append_<false>(reinterpret_cast<const uint8_t*>(chars));
DestChar* dest,
int length));
- template <bool is_ascii, typename Char>
+ template <bool is_one_byte, typename Char>
INLINE(void SerializeString_(Handle<String> string));
template <typename Char>
Handle<JSArray> stack_;
int current_index_;
int part_length_;
- bool is_ascii_;
+ bool is_one_byte_;
bool overflowed_;
static const int kJsonEscapeTableEntrySize = 8;
};
-// Translation table to escape ASCII characters.
+// Translation table to escape Latin1 characters.
// Table entries start at a multiple of 8 and are null-terminated.
const char* const BasicJsonStringifier::JsonEscapeTable =
"\\u0000\0 \\u0001\0 \\u0002\0 \\u0003\0 "
BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate)
: isolate_(isolate),
current_index_(0),
- is_ascii_(true),
+ is_one_byte_(true),
overflowed_(false) {
factory_ = isolate_->factory();
accumulator_store_ = Handle<JSValue>::cast(
}
-template <bool is_ascii, typename Char>
+template <bool is_one_byte, typename Char>
void BasicJsonStringifier::Append_(Char c) {
- if (is_ascii) {
+ if (is_one_byte) {
SeqOneByteString::cast(*current_part_)->SeqOneByteStringSet(
current_index_++, c);
} else {
}
-template <bool is_ascii, typename Char>
+template <bool is_one_byte, typename Char>
void BasicJsonStringifier::Append_(const Char* chars) {
- for ( ; *chars != '\0'; chars++) Append_<is_ascii, Char>(*chars);
+ for (; *chars != '\0'; chars++) Append_<is_one_byte, Char>(*chars);
}
switch (Oddball::cast(*object)->kind()) {
case Oddball::kFalse:
if (deferred_string_key) SerializeDeferredKey(comma, key);
- AppendAscii("false");
+ AppendOneByte("false");
return SUCCESS;
case Oddball::kTrue:
if (deferred_string_key) SerializeDeferredKey(comma, key);
- AppendAscii("true");
+ AppendOneByte("true");
return SUCCESS;
case Oddball::kNull:
if (deferred_string_key) SerializeDeferredKey(comma, key);
- AppendAscii("null");
+ AppendOneByte("null");
return SUCCESS;
default:
return UNCHANGED;
DCHECK(class_name == isolate_->heap()->Boolean_string());
Object* value = JSValue::cast(*object)->value();
DCHECK(value->IsBoolean());
- AppendAscii(value->IsTrue() ? "true" : "false");
+ AppendOneByte(value->IsTrue() ? "true" : "false");
}
return SUCCESS;
}
static const int kBufferSize = 100;
char chars[kBufferSize];
Vector<char> buffer(chars, kBufferSize);
- AppendAscii(IntToCString(object->value(), buffer));
+ AppendOneByte(IntToCString(object->value(), buffer));
return SUCCESS;
}
BasicJsonStringifier::Result BasicJsonStringifier::SerializeDouble(
double number) {
if (std::isinf(number) || std::isnan(number)) {
- AppendAscii("null");
+ AppendOneByte("null");
return SUCCESS;
}
static const int kBufferSize = 100;
char chars[kBufferSize];
Vector<char> buffer(chars, kBufferSize);
- AppendAscii(DoubleToCString(number, buffer));
+ AppendOneByte(DoubleToCString(number, buffer));
return SUCCESS;
}
i);
if (result == SUCCESS) continue;
if (result == UNCHANGED) {
- AppendAscii("null");
+ AppendOneByte("null");
} else {
return result;
}
Object::GetElement(isolate_, object, i),
EXCEPTION);
if (element->IsUndefined()) {
- AppendAscii("null");
+ AppendOneByte("null");
} else {
Result result = SerializeElement(isolate_, element, i);
if (result == SUCCESS) continue;
if (result == UNCHANGED) {
- AppendAscii("null");
+ AppendOneByte("null");
} else {
return result;
}
if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) {
part_length_ *= kPartLengthGrowthFactor;
}
- if (is_ascii_) {
+ if (is_one_byte_) {
current_part_ =
factory_->NewRawOneByteString(part_length_).ToHandleChecked();
} else {
factory_->NewRawTwoByteString(part_length_).ToHandleChecked();
DCHECK(!current_part_.is_null());
current_index_ = 0;
- is_ascii_ = false;
+ is_one_byte_ = false;
}
}
-template <bool is_ascii, typename Char>
+template <bool is_one_byte, typename Char>
void BasicJsonStringifier::SerializeString_(Handle<String> string) {
int length = string->length();
- Append_<is_ascii, char>('"');
+ Append_<is_one_byte, char>('"');
// We make a rough estimate to find out if the current string can be
// serialized without allocating a new string part. The worst case length of
// an escaped character is 6. Shifting the remainin string length right by 3
if (((part_length_ - current_index_) >> 3) > length) {
DisallowHeapAllocation no_gc;
Vector<const Char> vector = GetCharVector<Char>(string);
- if (is_ascii) {
+ if (is_one_byte) {
current_index_ += SerializeStringUnchecked_(
vector.start(),
SeqOneByteString::cast(*current_part_)->GetChars() + current_index_,
}
Char c = vector[i];
if (DoNotEscape(c)) {
- Append_<is_ascii, Char>(c);
+ Append_<is_one_byte, Char>(c);
} else {
- Append_<is_ascii, uint8_t>(reinterpret_cast<const uint8_t*>(
+ Append_<is_one_byte, uint8_t>(reinterpret_cast<const uint8_t*>(
&JsonEscapeTable[c * kJsonEscapeTableEntrySize]));
}
}
}
- Append_<is_ascii, uint8_t>('"');
+ Append_<is_one_byte, uint8_t>('"');
}
Vector<const uint8_t> BasicJsonStringifier::GetCharVector(
Handle<String> string) {
String::FlatContent flat = string->GetFlatContent();
- DCHECK(flat.IsAscii());
+ DCHECK(flat.IsOneByte());
return flat.ToOneByteVector();
}
void BasicJsonStringifier::SerializeString(Handle<String> object) {
object = String::Flatten(object);
- if (is_ascii_) {
+ if (is_one_byte_) {
if (object->IsOneByteRepresentationUnderneath()) {
SerializeString_<true, uint8_t>(object);
} else {
DCHECK(needle_content.IsFlat());
DCHECK(subject_content.IsFlat());
// dispatch on type of strings
- index = (needle_content.IsAscii()
- ? (subject_content.IsAscii()
- ? SearchString(isolate,
- subject_content.ToOneByteVector(),
- needle_content.ToOneByteVector(),
- index)
- : SearchString(isolate,
- subject_content.ToUC16Vector(),
- needle_content.ToOneByteVector(),
- index))
- : (subject_content.IsAscii()
- ? SearchString(isolate,
- subject_content.ToOneByteVector(),
- needle_content.ToUC16Vector(),
- index)
- : SearchString(isolate,
- subject_content.ToUC16Vector(),
- needle_content.ToUC16Vector(),
- index)));
+ index =
+ (needle_content.IsOneByte()
+ ? (subject_content.IsOneByte()
+ ? SearchString(isolate, subject_content.ToOneByteVector(),
+ needle_content.ToOneByteVector(), index)
+ : SearchString(isolate, subject_content.ToUC16Vector(),
+ needle_content.ToOneByteVector(), index))
+ : (subject_content.IsOneByte()
+ ? SearchString(isolate, subject_content.ToOneByteVector(),
+ needle_content.ToUC16Vector(), index)
+ : SearchString(isolate, subject_content.ToUC16Vector(),
+ needle_content.ToUC16Vector(), index)));
if (index == -1) {
return i / 2; // Return number of matches.
} else {
// Irregexp implementation.
// Ensures that the regexp object contains a compiled version of the
-// source for either ASCII or non-ASCII strings.
+// source for either one-byte or two-byte subject strings.
// If the compiled version doesn't already exist, it is compiled
// from the source pattern.
// If compilation fails, an exception is thrown and this function
// returns false.
-bool RegExpImpl::EnsureCompiledIrregexp(
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii) {
- Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii));
+bool RegExpImpl::EnsureCompiledIrregexp(Handle<JSRegExp> re,
+ Handle<String> sample_subject,
+ bool is_one_byte) {
+ Object* compiled_code = re->DataAt(JSRegExp::code_index(is_one_byte));
#ifdef V8_INTERPRETED_REGEXP
if (compiled_code->IsByteArray()) return true;
#else // V8_INTERPRETED_REGEXP (RegExp native code)
#endif
// We could potentially have marked this as flushable, but have kept
// a saved version if we did not flush it yet.
- Object* saved_code = re->DataAt(JSRegExp::saved_code_index(is_ascii));
+ Object* saved_code = re->DataAt(JSRegExp::saved_code_index(is_one_byte));
if (saved_code->IsCode()) {
// Reinstate the code in the original place.
- re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code);
+ re->SetDataAt(JSRegExp::code_index(is_one_byte), saved_code);
DCHECK(compiled_code->IsSmi());
return true;
}
- return CompileIrregexp(re, sample_subject, is_ascii);
+ return CompileIrregexp(re, sample_subject, is_one_byte);
}
-static void CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re, bool is_ascii,
+static void CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re,
Handle<String> error_message,
Isolate* isolate) {
Factory* factory = isolate->factory();
bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
Handle<String> sample_subject,
- bool is_ascii) {
+ bool is_one_byte) {
// Compile the RegExp.
Isolate* isolate = re->GetIsolate();
Zone zone(isolate);
PostponeInterruptsScope postpone(isolate);
// If we had a compilation error the last time this is saved at the
// saved code index.
- Object* entry = re->DataAt(JSRegExp::code_index(is_ascii));
+ Object* entry = re->DataAt(JSRegExp::code_index(is_one_byte));
// When arriving here entry can only be a smi, either representing an
// uncompiled regexp, a previous compilation error, or code that has
// been flushed.
// A previous compilation failed and threw an error which we store in
// the saved code index (we store the error message, not the actual
// error). Recreate the error object and throw it.
- Object* error_string = re->DataAt(JSRegExp::saved_code_index(is_ascii));
+ Object* error_string = re->DataAt(JSRegExp::saved_code_index(is_one_byte));
DCHECK(error_string->IsString());
Handle<String> error_message(String::cast(error_string));
- CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate);
+ CreateRegExpErrorObjectAndThrow(re, error_message, isolate);
return false;
}
"malformed_regexp"));
return false;
}
- RegExpEngine::CompilationResult result =
- RegExpEngine::Compile(&compile_data,
- flags.is_ignore_case(),
- flags.is_global(),
- flags.is_multiline(),
- pattern,
- sample_subject,
- is_ascii,
- &zone);
+ RegExpEngine::CompilationResult result = RegExpEngine::Compile(
+ &compile_data, flags.is_ignore_case(), flags.is_global(),
+ flags.is_multiline(), pattern, sample_subject, is_one_byte, &zone);
if (result.error_message != NULL) {
// Unable to compile regexp.
Handle<String> error_message = isolate->factory()->NewStringFromUtf8(
CStrVector(result.error_message)).ToHandleChecked();
- CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate);
+ CreateRegExpErrorObjectAndThrow(re, error_message, isolate);
return false;
}
Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data()));
- data->set(JSRegExp::code_index(is_ascii), result.code);
+ data->set(JSRegExp::code_index(is_one_byte), result.code);
int register_max = IrregexpMaxRegisterCount(*data);
if (result.num_registers > register_max) {
SetIrregexpMaxRegisterCount(*data, result.num_registers);
}
-ByteArray* RegExpImpl::IrregexpByteCode(FixedArray* re, bool is_ascii) {
- return ByteArray::cast(re->get(JSRegExp::code_index(is_ascii)));
+ByteArray* RegExpImpl::IrregexpByteCode(FixedArray* re, bool is_one_byte) {
+ return ByteArray::cast(re->get(JSRegExp::code_index(is_one_byte)));
}
-Code* RegExpImpl::IrregexpNativeCode(FixedArray* re, bool is_ascii) {
- return Code::cast(re->get(JSRegExp::code_index(is_ascii)));
+Code* RegExpImpl::IrregexpNativeCode(FixedArray* re, bool is_one_byte) {
+ return Code::cast(re->get(JSRegExp::code_index(is_one_byte)));
}
Handle<String> subject) {
subject = String::Flatten(subject);
- // Check the asciiness of the underlying storage.
- bool is_ascii = subject->IsOneByteRepresentationUnderneath();
- if (!EnsureCompiledIrregexp(regexp, subject, is_ascii)) return -1;
+ // Check representation of the underlying storage.
+ bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
+ if (!EnsureCompiledIrregexp(regexp, subject, is_one_byte)) return -1;
#ifdef V8_INTERPRETED_REGEXP
// Byte-code regexp needs space allocated for all its registers.
DCHECK(index <= subject->length());
DCHECK(subject->IsFlat());
- bool is_ascii = subject->IsOneByteRepresentationUnderneath();
+ bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
#ifndef V8_INTERPRETED_REGEXP
DCHECK(output_size >= (IrregexpNumberOfCaptures(*irregexp) + 1) * 2);
do {
- EnsureCompiledIrregexp(regexp, subject, is_ascii);
- Handle<Code> code(IrregexpNativeCode(*irregexp, is_ascii), isolate);
+ EnsureCompiledIrregexp(regexp, subject, is_one_byte);
+ Handle<Code> code(IrregexpNativeCode(*irregexp, is_one_byte), isolate);
// The stack is used to allocate registers for the compiled regexp code.
// This means that in case of failure, the output registers array is left
// untouched and contains the capture results from the previous successful
// must restart from scratch.
// In this case, it means we must make sure we are prepared to handle
// the, potentially, different subject (the string can switch between
- // being internal and external, and even between being ASCII and UC16,
+ // being internal and external, and even between being Latin1 and UC16,
// but the characters are always the same).
IrregexpPrepare(regexp, subject);
- is_ascii = subject->IsOneByteRepresentationUnderneath();
+ is_one_byte = subject->IsOneByteRepresentationUnderneath();
} while (true);
UNREACHABLE();
return RE_EXCEPTION;
for (int i = number_of_capture_registers - 1; i >= 0; i--) {
raw_output[i] = -1;
}
- Handle<ByteArray> byte_codes(IrregexpByteCode(*irregexp, is_ascii), isolate);
+ Handle<ByteArray> byte_codes(IrregexpByteCode(*irregexp, is_one_byte),
+ isolate);
IrregexpResult result = IrregexpInterpreter::Match(isolate,
byte_codes,
class RegExpCompiler {
public:
- RegExpCompiler(int capture_count, bool ignore_case, bool is_ascii,
+ RegExpCompiler(int capture_count, bool ignore_case, bool is_one_byte,
Zone* zone);
int AllocateRegister() {
void SetRegExpTooBig() { reg_exp_too_big_ = true; }
inline bool ignore_case() { return ignore_case_; }
- inline bool ascii() { return ascii_; }
+ inline bool one_byte() { return one_byte_; }
FrequencyCollator* frequency_collator() { return &frequency_collator_; }
int current_expansion_factor() { return current_expansion_factor_; }
int recursion_depth_;
RegExpMacroAssembler* macro_assembler_;
bool ignore_case_;
- bool ascii_;
+ bool one_byte_;
bool reg_exp_too_big_;
int current_expansion_factor_;
FrequencyCollator frequency_collator_;
// Attempts to compile the regexp using an Irregexp code generator. Returns
// a fixed array or a null handle depending on whether it succeeded.
-RegExpCompiler::RegExpCompiler(int capture_count, bool ignore_case, bool ascii,
- Zone* zone)
+RegExpCompiler::RegExpCompiler(int capture_count, bool ignore_case,
+ bool one_byte, Zone* zone)
: next_register_(2 * (capture_count + 1)),
work_list_(NULL),
recursion_depth_(0),
ignore_case_(ignore_case),
- ascii_(ascii),
+ one_byte_(one_byte),
reg_exp_too_big_(false),
current_expansion_factor_(1),
frequency_collator_(),
// Returns the number of characters in the equivalence class, omitting those
// that cannot occur in the source string because it is ASCII.
-static int GetCaseIndependentLetters(Isolate* isolate,
- uc16 character,
- bool ascii_subject,
+static int GetCaseIndependentLetters(Isolate* isolate, uc16 character,
+ bool one_byte_subject,
unibrow::uchar* letters) {
int length =
isolate->jsregexp_uncanonicalize()->get(character, '\0', letters);
letters[0] = character;
length = 1;
}
- if (!ascii_subject || character <= String::kMaxOneByteCharCode) {
+ if (!one_byte_subject || character <= String::kMaxOneByteCharCode) {
return length;
}
+
// The standard requires that non-ASCII characters cannot have ASCII
// character codes in their equivalence class.
+ // TODO(dcarney): issue 3550 this is not actually true for Latin1 anymore,
+ // is it? For example, \u00C5 is equivalent to \u212B.
return 0;
}
bool check,
bool preloaded) {
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
- bool ascii = compiler->ascii();
+ bool one_byte = compiler->one_byte();
unibrow::uchar chars[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- int length = GetCaseIndependentLetters(isolate, c, ascii, chars);
+ int length = GetCaseIndependentLetters(isolate, c, one_byte, chars);
if (length < 1) {
- // This can't match. Must be an ASCII subject and a non-ASCII character.
- // We do not need to do anything since the ASCII pass already handled this.
+ // This can't match. Must be an one-byte subject and a non-one-byte
+ // character. We do not need to do anything since the one-byte pass
+ // already handled this.
return false; // Bounds not checked.
}
bool checked = false;
// We handle the length > 1 case in a later pass.
if (length == 1) {
- if (ascii && c > String::kMaxOneByteCharCodeU) {
+ if (one_byte && c > String::kMaxOneByteCharCodeU) {
// Can't match - see above.
return false; // Bounds not checked.
}
static bool ShortCutEmitCharacterPair(RegExpMacroAssembler* macro_assembler,
- bool ascii,
- uc16 c1,
- uc16 c2,
+ bool one_byte, uc16 c1, uc16 c2,
Label* on_failure) {
uc16 char_mask;
- if (ascii) {
+ if (one_byte) {
char_mask = String::kMaxOneByteCharCode;
} else {
char_mask = String::kMaxUtf16CodeUnit;
bool check,
bool preloaded) {
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
- bool ascii = compiler->ascii();
+ bool one_byte = compiler->one_byte();
unibrow::uchar chars[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- int length = GetCaseIndependentLetters(isolate, c, ascii, chars);
+ int length = GetCaseIndependentLetters(isolate, c, one_byte, chars);
if (length <= 1) return false;
// We may not need to check against the end of the input string
// if this character lies before a character that matched.
DCHECK(unibrow::Ecma262UnCanonicalize::kMaxWidth == 4);
switch (length) {
case 2: {
- if (ShortCutEmitCharacterPair(macro_assembler,
- ascii,
- chars[0],
- chars[1],
- on_failure)) {
+ if (ShortCutEmitCharacterPair(macro_assembler, one_byte, chars[0],
+ chars[1], on_failure)) {
} else {
macro_assembler->CheckCharacter(chars[0], &ok);
macro_assembler->CheckNotCharacter(chars[1], on_failure);
// new_start_index is the index of the first edge that is beyond the
// current kSize space.
- // For very large search spaces we do a binary chop search of the non-ASCII
+ // For very large search spaces we do a binary chop search of the non-Latin1
// space instead of just going to the end of the current kSize space. The
// heuristics are complicated a little by the fact that any 128-character
// encoding space can be quickly tested with a table lookup, so we don't
// for example, we only want to match every second character (eg. the lower
// case characters on some Unicode pages).
int binary_chop_index = (end_index + start_index) / 2;
- // The first test ensures that we get to the code that handles the ASCII
+ // The first test ensures that we get to the code that handles the Latin1
// range with a single not-taken branch, speeding up this important
- // character range (even non-ASCII charset-based text has spaces and
+ // character range (even non-Latin1 charset-based text has spaces and
// punctuation).
- if (*border - 1 > String::kMaxOneByteCharCode && // ASCII case.
+ if (*border - 1 > String::kMaxOneByteCharCode && // Latin1 case.
end_index - start_index > (*new_start_index - start_index) * 2 &&
- last - first > kSize * 2 &&
- binary_chop_index > *new_start_index &&
+ last - first > kSize * 2 && binary_chop_index > *new_start_index &&
ranges->at(binary_chop_index) >= first + 2 * kSize) {
int scan_forward_for_section_border = binary_chop_index;;
int new_border = (ranges->at(binary_chop_index) | kMask) + 1;
static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
- RegExpCharacterClass* cc,
- bool ascii,
- Label* on_failure,
- int cp_offset,
- bool check_offset,
- bool preloaded,
- Zone* zone) {
+ RegExpCharacterClass* cc, bool one_byte,
+ Label* on_failure, int cp_offset, bool check_offset,
+ bool preloaded, Zone* zone) {
ZoneList<CharacterRange>* ranges = cc->ranges(zone);
if (!CharacterRange::IsCanonical(ranges)) {
CharacterRange::Canonicalize(ranges);
}
int max_char;
- if (ascii) {
+ if (one_byte) {
max_char = String::kMaxOneByteCharCode;
} else {
max_char = String::kMaxUtf16CodeUnit;
GetQuickCheckDetails(
details, compiler, 0, trace->at_start() == Trace::FALSE_VALUE);
if (details->cannot_match()) return false;
- if (!details->Rationalize(compiler->ascii())) return false;
+ if (!details->Rationalize(compiler->one_byte())) return false;
DCHECK(details->characters() == 1 ||
compiler->macro_assembler()->CanReadUnaligned());
uint32_t mask = details->mask();
// If number of characters preloaded is 1 then we used a byte or 16 bit
// load so the value is already masked down.
uint32_t char_mask;
- if (compiler->ascii()) {
+ if (compiler->one_byte()) {
char_mask = String::kMaxOneByteCharCode;
} else {
char_mask = String::kMaxUtf16CodeUnit;
if ((mask & char_mask) == char_mask) need_mask = false;
mask &= char_mask;
} else {
- // For 2-character preloads in ASCII mode or 1-character preloads in
- // TWO_BYTE mode we also use a 16 bit load with zero extend.
- if (details->characters() == 2 && compiler->ascii()) {
+ // For 2-character preloads in one-byte mode or 1-character preloads in
+ // two-byte mode we also use a 16 bit load with zero extend.
+ if (details->characters() == 2 && compiler->one_byte()) {
if ((mask & 0xffff) == 0xffff) need_mask = false;
- } else if (details->characters() == 1 && !compiler->ascii()) {
+ } else if (details->characters() == 1 && !compiler->one_byte()) {
if ((mask & 0xffff) == 0xffff) need_mask = false;
} else {
if (mask == 0xffffffff) need_mask = false;
DCHECK(characters_filled_in < details->characters());
int characters = details->characters();
int char_mask;
- if (compiler->ascii()) {
+ if (compiler->one_byte()) {
char_mask = String::kMaxOneByteCharCode;
} else {
char_mask = String::kMaxUtf16CodeUnit;
details->positions(characters_filled_in);
uc16 c = quarks[i];
if (c > char_mask) {
- // If we expect a non-ASCII character from an ASCII string,
- // there is no way we can match. Not even case independent
- // matching can turn an ASCII character into non-ASCII or
+ // If we expect a non-Latin1 character from an one-byte string,
+ // there is no way we can match. Not even case-independent
+ // matching can turn an Latin1 character into non-Latin1 or
// vice versa.
+ // TODO(dcarney): issue 3550. Verify that this works as expected.
+ // For example, \u0178 is uppercase of \u00ff (y-umlaut).
details->set_cannot_match();
pos->determines_perfectly = false;
return;
}
if (compiler->ignore_case()) {
unibrow::uchar chars[unibrow::Ecma262UnCanonicalize::kMaxWidth];
- int length = GetCaseIndependentLetters(isolate, c, compiler->ascii(),
- chars);
+ int length = GetCaseIndependentLetters(isolate, c,
+ compiler->one_byte(), chars);
DCHECK(length != 0); // Can only happen if c > char_mask (see above).
if (length == 1) {
// This letter has no case equivalents, so it's nice and simple
}
-void QuickCheckDetails::Advance(int by, bool ascii) {
+void QuickCheckDetails::Advance(int by, bool one_byte) {
DCHECK(by >= 0);
if (by >= characters_) {
Clear();
};
-RegExpNode* SeqRegExpNode::FilterASCII(int depth, bool ignore_case) {
+RegExpNode* SeqRegExpNode::FilterOneByte(int depth, bool ignore_case) {
if (info()->replacement_calculated) return replacement();
if (depth < 0) return this;
DCHECK(!info()->visited);
RegExpNode* SeqRegExpNode::FilterSuccessor(int depth, bool ignore_case) {
- RegExpNode* next = on_success_->FilterASCII(depth - 1, ignore_case);
+ RegExpNode* next = on_success_->FilterOneByte(depth - 1, ignore_case);
if (next == NULL) return set_replacement(NULL);
on_success_ = next;
return set_replacement(this);
}
-RegExpNode* TextNode::FilterASCII(int depth, bool ignore_case) {
+RegExpNode* TextNode::FilterOneByte(int depth, bool ignore_case) {
if (info()->replacement_calculated) return replacement();
if (depth < 0) return this;
DCHECK(!info()->visited);
}
-RegExpNode* LoopChoiceNode::FilterASCII(int depth, bool ignore_case) {
+RegExpNode* LoopChoiceNode::FilterOneByte(int depth, bool ignore_case) {
if (info()->replacement_calculated) return replacement();
if (depth < 0) return this;
if (info()->visited) return this;
VisitMarker marker(info());
RegExpNode* continue_replacement =
- continue_node_->FilterASCII(depth - 1, ignore_case);
+ continue_node_->FilterOneByte(depth - 1, ignore_case);
// If we can't continue after the loop then there is no sense in doing the
// loop.
if (continue_replacement == NULL) return set_replacement(NULL);
}
- return ChoiceNode::FilterASCII(depth - 1, ignore_case);
+ return ChoiceNode::FilterOneByte(depth - 1, ignore_case);
}
-RegExpNode* ChoiceNode::FilterASCII(int depth, bool ignore_case) {
+RegExpNode* ChoiceNode::FilterOneByte(int depth, bool ignore_case) {
if (info()->replacement_calculated) return replacement();
if (depth < 0) return this;
if (info()->visited) return this;
for (int i = 0; i < choice_count; i++) {
GuardedAlternative alternative = alternatives_->at(i);
RegExpNode* replacement =
- alternative.node()->FilterASCII(depth - 1, ignore_case);
+ alternative.node()->FilterOneByte(depth - 1, ignore_case);
DCHECK(replacement != this); // No missing EMPTY_MATCH_CHECK.
if (replacement != NULL) {
alternatives_->at(i).set_node(replacement);
new(zone()) ZoneList<GuardedAlternative>(surviving, zone());
for (int i = 0; i < choice_count; i++) {
RegExpNode* replacement =
- alternatives_->at(i).node()->FilterASCII(depth - 1, ignore_case);
+ alternatives_->at(i).node()->FilterOneByte(depth - 1, ignore_case);
if (replacement != NULL) {
alternatives_->at(i).set_node(replacement);
new_alternatives->Add(alternatives_->at(i), zone());
}
-RegExpNode* NegativeLookaheadChoiceNode::FilterASCII(int depth,
- bool ignore_case) {
+RegExpNode* NegativeLookaheadChoiceNode::FilterOneByte(int depth,
+ bool ignore_case) {
if (info()->replacement_calculated) return replacement();
if (depth < 0) return this;
if (info()->visited) return this;
// Alternative 0 is the negative lookahead, alternative 1 is what comes
// afterwards.
RegExpNode* node = alternatives_->at(1).node();
- RegExpNode* replacement = node->FilterASCII(depth - 1, ignore_case);
+ RegExpNode* replacement = node->FilterOneByte(depth - 1, ignore_case);
if (replacement == NULL) return set_replacement(NULL);
alternatives_->at(1).set_node(replacement);
RegExpNode* neg_node = alternatives_->at(0).node();
- RegExpNode* neg_replacement = neg_node->FilterASCII(depth - 1, ignore_case);
+ RegExpNode* neg_replacement = neg_node->FilterOneByte(depth - 1, ignore_case);
// If the negative lookahead is always going to fail then
// we don't need to check it.
if (neg_replacement == NULL) return set_replacement(replacement);
if (!assembler->CheckSpecialCharacterClass('n',
new_trace.backtrack())) {
// Newline means \n, \r, 0x2028 or 0x2029.
- if (!compiler->ascii()) {
+ if (!compiler->one_byte()) {
assembler->CheckCharacterAfterAnd(0x2028, 0xfffe, &ok);
}
assembler->CheckCharacter('\n', &ok);
int* checked_up_to) {
RegExpMacroAssembler* assembler = compiler->macro_assembler();
Isolate* isolate = assembler->zone()->isolate();
- bool ascii = compiler->ascii();
+ bool one_byte = compiler->one_byte();
Label* backtrack = trace->backtrack();
QuickCheckDetails* quick_check = trace->quick_check_performed();
int element_count = elms_->length();
if (DeterminedAlready(quick_check, elm.cp_offset() + j)) continue;
EmitCharacterFunction* emit_function = NULL;
switch (pass) {
- case NON_ASCII_MATCH:
- DCHECK(ascii);
+ case NON_LATIN1_MATCH:
+ DCHECK(one_byte);
if (quarks[j] > String::kMaxOneByteCharCode) {
assembler->GoTo(backtrack);
return;
if (first_element_checked && i == 0) continue;
if (DeterminedAlready(quick_check, elm.cp_offset())) continue;
RegExpCharacterClass* cc = elm.char_class();
- EmitCharClass(assembler,
- cc,
- ascii,
- backtrack,
- cp_offset,
- *checked_up_to < cp_offset,
- preloaded,
- zone());
+ EmitCharClass(assembler, cc, one_byte, backtrack, cp_offset,
+ *checked_up_to < cp_offset, preloaded, zone());
UpdateBoundsCheck(cp_offset, checked_up_to);
}
}
return;
}
- if (compiler->ascii()) {
+ if (compiler->one_byte()) {
int dummy = 0;
- TextEmitPass(compiler, NON_ASCII_MATCH, false, trace, false, &dummy);
+ TextEmitPass(compiler, NON_LATIN1_MATCH, false, trace, false, &dummy);
}
bool first_elt_done = false;
// Adjust the offsets of the quick check performed information. This
// information is used to find out what we already determined about the
// characters by means of mask and compare.
- quick_check_performed_.Advance(by, compiler->ascii());
+ quick_check_performed_.Advance(by, compiler->one_byte());
cp_offset_ += by;
if (cp_offset_ > RegExpMacroAssembler::kMaxCPOffset) {
compiler->SetRegExpTooBig();
}
-void TextNode::MakeCaseIndependent(bool is_ascii) {
+void TextNode::MakeCaseIndependent(bool is_one_byte) {
int element_count = elms_->length();
for (int i = 0; i < element_count; i++) {
TextElement elm = elms_->at(i);
ZoneList<CharacterRange>* ranges = cc->ranges(zone());
int range_count = ranges->length();
for (int j = 0; j < range_count; j++) {
- ranges->at(j).AddCaseEquivalents(ranges, is_ascii, zone());
+ ranges->at(j).AddCaseEquivalents(ranges, is_one_byte, zone());
}
}
}
}
if (ranges->length() != 1) return NULL;
uint32_t max_char;
- if (compiler->ascii()) {
+ if (compiler->one_byte()) {
max_char = String::kMaxOneByteCharCode;
} else {
max_char = String::kMaxUtf16CodeUnit;
int eats_at_least) {
int preload_characters = Min(4, eats_at_least);
if (compiler->macro_assembler()->CanReadUnaligned()) {
- bool ascii = compiler->ascii();
- if (ascii) {
+ bool one_byte = compiler->one_byte();
+ if (one_byte) {
if (preload_characters > 4) preload_characters = 4;
// We can't preload 3 characters because there is no machine instruction
// to do that. We can't just load 4 because we could be reading
int length, RegExpCompiler* compiler, Zone* zone)
: length_(length),
compiler_(compiler) {
- if (compiler->ascii()) {
+ if (compiler->one_byte()) {
max_char_ = String::kMaxOneByteCharCode;
} else {
max_char_ = String::kMaxUtf16CodeUnit;
// dividing by 2 we switch off the skipping if the probability of skipping
// is less than 50%. This is because the multibyte mask-and-compare
// skipping in quickcheck is more likely to do well on this case.
- bool in_quickcheck_range = ((i - remembered_from < 4) ||
- (compiler_->ascii() ? remembered_from <= 4 : remembered_from <= 2));
+ bool in_quickcheck_range =
+ ((i - remembered_from < 4) ||
+ (compiler_->one_byte() ? remembered_from <= 4 : remembered_from <= 2));
// Called 'probability' but it is only a rough estimate and can actually
// be outside the 0-kSize range.
int probability = (in_quickcheck_range ? kSize / 2 : kSize) - frequency;
if (state->eats_at_least_ == PreloadState::kEatsAtLeastNotYetInitialized) {
// Save some time by looking at most one machine word ahead.
state->eats_at_least_ =
- EatsAtLeast(compiler->ascii() ? 4 : 2,
- kRecursionBudget,
+ EatsAtLeast(compiler->one_byte() ? 4 : 2, kRecursionBudget,
current_trace->at_start() == Trace::FALSE_VALUE);
}
state->preload_characters_ =
void CharacterRange::AddCaseEquivalents(ZoneList<CharacterRange>* ranges,
- bool is_ascii,
- Zone* zone) {
+ bool is_one_byte, Zone* zone) {
Isolate* isolate = zone->isolate();
uc16 bottom = from();
uc16 top = to();
- if (is_ascii && !RangeContainsLatin1Equivalents(*this)) {
+ if (is_one_byte && !RangeContainsLatin1Equivalents(*this)) {
if (bottom > String::kMaxOneByteCharCode) return;
if (top > String::kMaxOneByteCharCode) top = String::kMaxOneByteCharCode;
}
void Analysis::VisitText(TextNode* that) {
if (ignore_case_) {
- that->MakeCaseIndependent(is_ascii_);
+ that->MakeCaseIndependent(is_one_byte_);
}
EnsureAnalyzed(that->on_success());
if (!has_failed()) {
RegExpEngine::CompilationResult RegExpEngine::Compile(
- RegExpCompileData* data,
- bool ignore_case,
- bool is_global,
- bool is_multiline,
- Handle<String> pattern,
- Handle<String> sample_subject,
- bool is_ascii,
- Zone* zone) {
+ RegExpCompileData* data, bool ignore_case, bool is_global,
+ bool is_multiline, Handle<String> pattern, Handle<String> sample_subject,
+ bool is_one_byte, Zone* zone) {
if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) {
return IrregexpRegExpTooBig(zone->isolate());
}
- RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii, zone);
+ RegExpCompiler compiler(data->capture_count, ignore_case, is_one_byte, zone);
// Sample some characters from the middle of the string.
static const int kSampleSize = 128;
node = loop_node;
}
}
- if (is_ascii) {
- node = node->FilterASCII(RegExpCompiler::kMaxRecursion, ignore_case);
+ if (is_one_byte) {
+ node = node->FilterOneByte(RegExpCompiler::kMaxRecursion, ignore_case);
// Do it again to propagate the new nodes to places where they were not
// put because they had not been calculated yet.
if (node != NULL) {
- node = node->FilterASCII(RegExpCompiler::kMaxRecursion, ignore_case);
+ node = node->FilterOneByte(RegExpCompiler::kMaxRecursion, ignore_case);
}
}
if (node == NULL) node = new(zone) EndNode(EndNode::BACKTRACK, zone);
data->node = node;
- Analysis analysis(ignore_case, is_ascii);
+ Analysis analysis(ignore_case, is_one_byte);
analysis.EnsureAnalyzed(node);
if (analysis.has_failed()) {
const char* error_message = analysis.error_message();
// Native regexp implementation.
NativeRegExpMacroAssembler::Mode mode =
- is_ascii ? NativeRegExpMacroAssembler::ASCII
- : NativeRegExpMacroAssembler::UC16;
+ is_one_byte ? NativeRegExpMacroAssembler::LATIN1
+ : NativeRegExpMacroAssembler::UC16;
#if V8_TARGET_ARCH_IA32
RegExpMacroAssemblerIA32 macro_assembler(mode, (data->capture_count + 1) * 2,
static void SetIrregexpMaxRegisterCount(FixedArray* re, int value);
static int IrregexpNumberOfCaptures(FixedArray* re);
static int IrregexpNumberOfRegisters(FixedArray* re);
- static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii);
- static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii);
+ static ByteArray* IrregexpByteCode(FixedArray* re, bool is_one_byte);
+ static Code* IrregexpNativeCode(FixedArray* re, bool is_one_byte);
// Limit the space regexps take up on the heap. In order to limit this we
// would like to keep track of the amount of regexp code on the heap. This
static const int kRegWxpCompiledLimit = 1 * MB;
private:
- static bool CompileIrregexp(
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii);
- static inline bool EnsureCompiledIrregexp(
- Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii);
+ static bool CompileIrregexp(Handle<JSRegExp> re,
+ Handle<String> sample_subject, bool is_one_byte);
+ static inline bool EnsureCompiledIrregexp(Handle<JSRegExp> re,
+ Handle<String> sample_subject,
+ bool is_one_byte);
};
bool is_valid() { return from_ <= to_; }
bool IsEverything(uc16 max) { return from_ == 0 && to_ >= max; }
bool IsSingleton() { return (from_ == to_); }
- void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_ascii,
+ void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_one_byte,
Zone* zone);
static void Split(ZoneList<CharacterRange>* base,
Vector<const int> overlay,
mask_(0),
value_(0),
cannot_match_(false) { }
- bool Rationalize(bool ascii);
+ bool Rationalize(bool one_byte);
// Merge in the information from another branch of an alternation.
void Merge(QuickCheckDetails* other, int from_index);
// Advance the current position by some amount.
- void Advance(int by, bool ascii);
+ void Advance(int by, bool one_byte);
void Clear();
bool cannot_match() { return cannot_match_; }
void set_cannot_match() { cannot_match_ = true; }
UNREACHABLE();
}
- // If we know that the input is ASCII then there are some nodes that can
+ // If we know that the input is one-byte then there are some nodes that can
// never match. This method returns a node that can be substituted for
// itself, or NULL if the node can never match.
- virtual RegExpNode* FilterASCII(int depth, bool ignore_case) { return this; }
- // Helper for FilterASCII.
+ virtual RegExpNode* FilterOneByte(int depth, bool ignore_case) {
+ return this;
+ }
+ // Helper for FilterOneByte.
RegExpNode* replacement() {
DCHECK(info()->replacement_calculated);
return replacement_;
: RegExpNode(on_success->zone()), on_success_(on_success) { }
RegExpNode* on_success() { return on_success_; }
void set_on_success(RegExpNode* node) { on_success_ = node; }
- virtual RegExpNode* FilterASCII(int depth, bool ignore_case);
+ virtual RegExpNode* FilterOneByte(int depth, bool ignore_case);
virtual void FillInBMInfo(int offset,
int budget,
BoyerMooreLookahead* bm,
int characters_filled_in,
bool not_at_start);
ZoneList<TextElement>* elements() { return elms_; }
- void MakeCaseIndependent(bool is_ascii);
+ void MakeCaseIndependent(bool is_one_byte);
virtual int GreedyLoopTextLength();
virtual RegExpNode* GetSuccessorOfOmnivorousTextNode(
RegExpCompiler* compiler);
BoyerMooreLookahead* bm,
bool not_at_start);
void CalculateOffsets();
- virtual RegExpNode* FilterASCII(int depth, bool ignore_case);
+ virtual RegExpNode* FilterOneByte(int depth, bool ignore_case);
private:
enum TextEmitPassType {
- NON_ASCII_MATCH, // Check for characters that can't match.
+ NON_LATIN1_MATCH, // Check for characters that can't match.
SIMPLE_CHARACTER_MATCH, // Case-dependent single character check.
NON_LETTER_CHARACTER_MATCH, // Check characters that have no case equivs.
CASE_CHARACTER_MATCH, // Case-independent single character check.
virtual bool try_to_emit_quick_check_for_alternative(bool is_first) {
return true;
}
- virtual RegExpNode* FilterASCII(int depth, bool ignore_case);
+ virtual RegExpNode* FilterOneByte(int depth, bool ignore_case);
protected:
int GreedyLoopTextLengthForAlternative(GuardedAlternative* alternative);
virtual bool try_to_emit_quick_check_for_alternative(bool is_first) {
return !is_first;
}
- virtual RegExpNode* FilterASCII(int depth, bool ignore_case);
+ virtual RegExpNode* FilterOneByte(int depth, bool ignore_case);
};
RegExpNode* continue_node() { return continue_node_; }
bool body_can_be_zero_length() { return body_can_be_zero_length_; }
virtual void Accept(NodeVisitor* visitor);
- virtual RegExpNode* FilterASCII(int depth, bool ignore_case);
+ virtual RegExpNode* FilterOneByte(int depth, bool ignore_case);
private:
// AddAlternative is made private for loop nodes because alternatives
// point.
int length_;
RegExpCompiler* compiler_;
- // 0x7f for ASCII, 0xffff for UTF-16.
+ // 0xff for Latin1, 0xffff for UTF-16.
int max_char_;
ZoneList<BoyerMoorePositionInfo*>* bitmaps_;
// +-------+ +------------+
class Analysis: public NodeVisitor {
public:
- Analysis(bool ignore_case, bool is_ascii)
+ Analysis(bool ignore_case, bool is_one_byte)
: ignore_case_(ignore_case),
- is_ascii_(is_ascii),
- error_message_(NULL) { }
+ is_one_byte_(is_one_byte),
+ error_message_(NULL) {}
void EnsureAnalyzed(RegExpNode* node);
#define DECLARE_VISIT(Type) \
private:
bool ignore_case_;
- bool is_ascii_;
+ bool is_one_byte_;
const char* error_message_;
DISALLOW_IMPLICIT_CONSTRUCTORS(Analysis);
int num_registers;
};
- static CompilationResult Compile(RegExpCompileData* input,
- bool ignore_case,
- bool global,
- bool multiline,
+ static CompilationResult Compile(RegExpCompileData* input, bool ignore_case,
+ bool global, bool multiline,
Handle<String> pattern,
Handle<String> sample_subject,
- bool is_ascii, Zone* zone);
+ bool is_one_byte, Zone* zone);
static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
};
Factory* factory = isolate->factory();
Handle<String> start_pos_key = factory->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("startPosition"));
- Handle<String> end_pos_key = factory->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("endPosition"));
- Handle<String> script_obj_key = factory->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("scriptObject"));
+ STATIC_CHAR_VECTOR("startPosition"));
+ Handle<String> end_pos_key =
+ factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("endPosition"));
+ Handle<String> script_obj_key =
+ factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptObject"));
Handle<Smi> start_pos(
Smi::FromInt(message_location.start_pos()), isolate);
Handle<Smi> end_pos(Smi::FromInt(message_location.end_pos()), isolate);
Handle<Object> data) {
Factory* factory = isolate->factory();
Handle<String> fmt_str =
- factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage"));
+ factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("FormatMessage"));
Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty(
isolate->js_builtins_object(), fmt_str).ToHandleChecked());
Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
fun, isolate->js_builtins_object(), arraysize(argv), argv);
Handle<Object> result;
if (!maybe_result.ToHandle(&result) || !result->IsString()) {
- return factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("<error>"));
+ return factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("<error>"));
}
Handle<String> result_string = Handle<String>::cast(result);
// A string that has been obtained from JS code in this way is
bool is_native = RegExpImpl::UsesNativeRegExp();
FixedArray* arr = FixedArray::cast(data());
- Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex);
+ Object* one_byte_data = arr->get(JSRegExp::kIrregexpLatin1CodeIndex);
// Smi : Not compiled yet (-1) or code prepared for flushing.
// JSObject: Compilation error.
// Code/ByteArray: Compiled code.
- CHECK(ascii_data->IsSmi() ||
- (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray()));
+ CHECK(
+ one_byte_data->IsSmi() ||
+ (is_native ? one_byte_data->IsCode() : one_byte_data->IsByteArray()));
Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex);
CHECK(uc16_data->IsSmi() ||
(is_native ? uc16_data->IsCode() : uc16_data->IsByteArray()));
- Object* ascii_saved = arr->get(JSRegExp::kIrregexpASCIICodeSavedIndex);
- CHECK(ascii_saved->IsSmi() || ascii_saved->IsString() ||
- ascii_saved->IsCode());
+ Object* one_byte_saved =
+ arr->get(JSRegExp::kIrregexpLatin1CodeSavedIndex);
+ CHECK(one_byte_saved->IsSmi() || one_byte_saved->IsString() ||
+ one_byte_saved->IsCode());
Object* uc16_saved = arr->get(JSRegExp::kIrregexpUC16CodeSavedIndex);
CHECK(uc16_saved->IsSmi() || uc16_saved->IsString() ||
uc16_saved->IsCode());
}
-bool Object::IsExternalAsciiString() const {
+bool Object::IsExternalOneByteString() const {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal() &&
String::cast(this)->IsOneByteRepresentation();
Internals::kStringEncodingMask);
-bool StringShape::IsSequentialAscii() {
+bool StringShape::IsSequentialOneByte() {
return full_representation_tag() == (kSeqStringTag | kOneByteStringTag);
}
}
-bool StringShape::IsExternalAscii() {
+bool StringShape::IsExternalOneByte() {
return full_representation_tag() == (kExternalStringTag | kOneByteStringTag);
}
STATIC_ASSERT((kExternalStringTag | kOneByteStringTag) ==
- Internals::kExternalAsciiRepresentationTag);
+ Internals::kExternalOneByteRepresentationTag);
-STATIC_ASSERT(v8::String::ASCII_ENCODING == kOneByteStringTag);
+STATIC_ASSERT(v8::String::ONE_BYTE_ENCODING == kOneByteStringTag);
bool StringShape::IsExternalTwoByte() {
uc32 FlatStringReader::Get(int index) {
DCHECK(0 <= index && index <= length_);
- if (is_ascii_) {
+ if (is_one_byte_) {
return static_cast<const byte*>(start_)[index];
} else {
return static_cast<const uc16*>(start_)[index];
CAST_ACCESSOR(DependentCode)
CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(ExternalArray)
-CAST_ACCESSOR(ExternalAsciiString)
+CAST_ACCESSOR(ExternalOneByteString)
CAST_ACCESSOR(ExternalFloat32Array)
CAST_ACCESSOR(ExternalFloat64Array)
CAST_ACCESSOR(ExternalInt16Array)
case kConsStringTag | kTwoByteStringTag:
return ConsString::cast(this)->ConsStringGet(index);
case kExternalStringTag | kOneByteStringTag:
- return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index);
+ return ExternalOneByteString::cast(this)->ExternalOneByteStringGet(index);
case kExternalStringTag | kTwoByteStringTag:
return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
case kSlicedStringTag | kOneByteStringTag:
case kExternalStringTag | kOneByteStringTag:
visitor->VisitOneByteString(
- ExternalAsciiString::cast(string)->GetChars() + slice_offset,
+ ExternalOneByteString::cast(string)->GetChars() + slice_offset,
length - offset);
return NULL;
}
-const ExternalAsciiString::Resource* ExternalAsciiString::resource() {
+const ExternalOneByteString::Resource* ExternalOneByteString::resource() {
return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
}
-void ExternalAsciiString::update_data_cache() {
+void ExternalOneByteString::update_data_cache() {
if (is_short()) return;
const char** data_field =
reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset));
}
-void ExternalAsciiString::set_resource(
- const ExternalAsciiString::Resource* resource) {
+void ExternalOneByteString::set_resource(
+ const ExternalOneByteString::Resource* resource) {
DCHECK(IsAligned(reinterpret_cast<intptr_t>(resource), kPointerSize));
*reinterpret_cast<const Resource**>(
FIELD_ADDR(this, kResourceOffset)) = resource;
}
-const uint8_t* ExternalAsciiString::GetChars() {
+const uint8_t* ExternalOneByteString::GetChars() {
return reinterpret_cast<const uint8_t*>(resource()->data());
}
-uint16_t ExternalAsciiString::ExternalAsciiStringGet(int index) {
+uint16_t ExternalOneByteString::ExternalOneByteStringGet(int index) {
DCHECK(index >= 0 && index < length());
return GetChars()[index];
}
if (instance_type == FIXED_ARRAY_TYPE) {
return FixedArray::BodyDescriptor::SizeOf(map, this);
}
- if (instance_type == ASCII_STRING_TYPE ||
- instance_type == ASCII_INTERNALIZED_STRING_TYPE) {
+ if (instance_type == ONE_BYTE_STRING_TYPE ||
+ instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) {
return SeqOneByteString::SizeFor(
reinterpret_cast<SeqOneByteString*>(this)->length());
}
String* src_str = String::cast(src);
if (!StringShape(src_str).IsExternal()) return true;
if (src_str->IsOneByteRepresentation()) {
- return ExternalAsciiString::cast(src)->resource() != NULL;
+ return ExternalOneByteString::cast(src)->resource() != NULL;
} else if (src_str->IsTwoByteRepresentation()) {
return ExternalTwoByteString::cast(src)->resource() != NULL;
}
}
-void ExternalAsciiString::ExternalAsciiStringIterateBody(ObjectVisitor* v) {
- typedef v8::String::ExternalAsciiStringResource Resource;
- v->VisitExternalAsciiString(
+void ExternalOneByteString::ExternalOneByteStringIterateBody(ObjectVisitor* v) {
+ typedef v8::String::ExternalOneByteStringResource Resource;
+ v->VisitExternalOneByteString(
reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)));
}
-template<typename StaticVisitor>
-void ExternalAsciiString::ExternalAsciiStringIterateBody() {
- typedef v8::String::ExternalAsciiStringResource Resource;
- StaticVisitor::VisitExternalAsciiString(
+template <typename StaticVisitor>
+void ExternalOneByteString::ExternalOneByteStringIterateBody() {
+ typedef v8::String::ExternalOneByteStringResource Resource;
+ StaticVisitor::VisitExternalOneByteString(
reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)));
}
// This method is only meant to be called from gdb for debugging purposes.
-// Since the string can also be in two-byte encoding, non-ASCII characters
+// Since the string can also be in two-byte encoding, non-Latin1 characters
// will be ignored in the output.
char* String::ToAsciiArray() {
// Static so that subsequent calls frees previously allocated space.
// Abort if size does not allow in-place conversion.
if (size < ExternalString::kShortSize) return false;
Heap* heap = GetHeap();
- bool is_ascii = this->IsOneByteRepresentation();
+ bool is_one_byte = this->IsOneByteRepresentation();
bool is_internalized = this->IsInternalizedString();
// Morph the string to an external string by replacing the map and
Map* new_map;
if (size < ExternalString::kSize) {
new_map = is_internalized
- ? (is_ascii
- ? heap->
- short_external_internalized_string_with_one_byte_data_map()
- : heap->short_external_internalized_string_map())
- : (is_ascii
- ? heap->short_external_string_with_one_byte_data_map()
- : heap->short_external_string_map());
+ ? (is_one_byte
+ ? heap->short_external_internalized_string_with_one_byte_data_map()
+ : heap->short_external_internalized_string_map())
+ : (is_one_byte ? heap->short_external_string_with_one_byte_data_map()
+ : heap->short_external_string_map());
} else {
new_map = is_internalized
- ? (is_ascii
- ? heap->external_internalized_string_with_one_byte_data_map()
- : heap->external_internalized_string_map())
- : (is_ascii
- ? heap->external_string_with_one_byte_data_map()
- : heap->external_string_map());
+ ? (is_one_byte
+ ? heap->external_internalized_string_with_one_byte_data_map()
+ : heap->external_internalized_string_map())
+ : (is_one_byte ? heap->external_string_with_one_byte_data_map()
+ : heap->external_string_map());
}
// Byte size of the external String object.
}
-bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
+bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
// Externalizing twice leaks the external resource, so it's
// prohibited by the API.
DCHECK(!this->IsExternalString());
Map* new_map;
if (size < ExternalString::kSize) {
new_map = is_internalized
- ? heap->short_external_ascii_internalized_string_map()
- : heap->short_external_ascii_string_map();
+ ? heap->short_external_one_byte_internalized_string_map()
+ : heap->short_external_one_byte_string_map();
} else {
new_map = is_internalized
- ? heap->external_ascii_internalized_string_map()
- : heap->external_ascii_string_map();
+ ? heap->external_one_byte_internalized_string_map()
+ : heap->external_one_byte_string_map();
}
// Byte size of the external String object.
// the left-over space to avoid races with the sweeper thread.
this->synchronized_set_map(new_map);
- ExternalAsciiString* self = ExternalAsciiString::cast(this);
+ ExternalOneByteString* self = ExternalOneByteString::cast(this);
self->set_resource(resource);
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
len = kMaxShortPrintLength;
truncated = true;
}
- bool ascii = true;
+ bool one_byte = true;
for (int i = 0; i < len; i++) {
uint16_t c = stream.GetNext();
if (c < 32 || c >= 127) {
- ascii = false;
+ one_byte = false;
}
}
stream.Reset(this);
- if (ascii) {
+ if (one_byte) {
accumulator->Add("<String[%u]: ", length());
for (int i = 0; i < len; i++) {
accumulator->Put(static_cast<char>(stream.GetNext()));
break;
case kExternalStringTag:
if ((type & kStringEncodingMask) == kOneByteStringTag) {
- reinterpret_cast<ExternalAsciiString*>(this)->
- ExternalAsciiStringIterateBody(v);
+ reinterpret_cast<ExternalOneByteString*>(this)
+ ->ExternalOneByteStringIterateBody(v);
} else {
reinterpret_cast<ExternalTwoByteString*>(this)->
ExternalTwoByteStringIterateBody(v);
// [[GetProperty]] requires to check that all properties are configurable.
Handle<String> configurable_name =
isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("configurable_"));
+ STATIC_CHAR_VECTOR("configurable_"));
Handle<Object> configurable =
Object::GetProperty(desc, configurable_name).ToHandleChecked();
DCHECK(configurable->IsBoolean());
if (configurable->IsFalse()) {
- Handle<String> trap =
- isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("getPropertyDescriptor"));
+ Handle<String> trap = isolate->factory()->InternalizeOneByteString(
+ STATIC_CHAR_VECTOR("getPropertyDescriptor"));
Handle<Object> args[] = { handler, trap, name };
THROW_NEW_ERROR(isolate, NewTypeError("proxy_prop_not_configurable",
HandleVector(args, arraysize(args))),
// Check for DataDescriptor.
Handle<String> hasWritable_name =
isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("hasWritable_"));
+ STATIC_CHAR_VECTOR("hasWritable_"));
Handle<Object> hasWritable =
Object::GetProperty(desc, hasWritable_name).ToHandleChecked();
DCHECK(hasWritable->IsBoolean());
if (hasWritable->IsTrue()) {
- Handle<String> writable_name =
- isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("writable_"));
+ Handle<String> writable_name = isolate->factory()->InternalizeOneByteString(
+ STATIC_CHAR_VECTOR("writable_"));
Handle<Object> writable =
Object::GetProperty(desc, writable_name).ToHandleChecked();
DCHECK(writable->IsBoolean());
}
// We have an AccessorDescriptor.
- Handle<String> set_name = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("set_"));
+ Handle<String> set_name =
+ isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("set_"));
Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked();
if (!setter->IsUndefined()) {
// TODO(rossberg): nicer would be to cast to some JSCallable here...
if (mode == STRICT_DELETION && !result_bool) {
Handle<Object> handler(proxy->handler(), isolate);
Handle<String> trap_name = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("delete"));
+ STATIC_CHAR_VECTOR("delete"));
Handle<Object> args[] = { handler, trap_name };
THROW_NEW_ERROR(isolate, NewTypeError("handler_failed",
HandleVector(args, arraysize(args))),
// Convert result to PropertyAttributes.
Handle<String> enum_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("enumerable_"));
+ STATIC_CHAR_VECTOR("enumerable_"));
Handle<Object> enumerable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, enumerable,
Object::GetProperty(desc, enum_n),
Maybe<PropertyAttributes>());
Handle<String> conf_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("configurable_"));
+ STATIC_CHAR_VECTOR("configurable_"));
Handle<Object> configurable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, configurable,
Object::GetProperty(desc, conf_n),
Maybe<PropertyAttributes>());
Handle<String> writ_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("writable_"));
+ STATIC_CHAR_VECTOR("writable_"));
Handle<Object> writable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, writable,
Object::GetProperty(desc, writ_n),
Maybe<PropertyAttributes>());
if (!writable->BooleanValue()) {
Handle<String> set_n = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("set_"));
+ STATIC_CHAR_VECTOR("set_"));
Handle<Object> setter;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, setter,
Object::GetProperty(desc, set_n),
if (configurable->IsFalse()) {
Handle<Object> handler(proxy->handler(), isolate);
Handle<String> trap = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("getPropertyDescriptor"));
+ STATIC_CHAR_VECTOR("getPropertyDescriptor"));
Handle<Object> args[] = { handler, trap, name };
Handle<Object> error;
MaybeHandle<Object> maybe_error = isolate->factory()->NewTypeError(
if (shape.representation_tag() == kSeqStringTag) {
start = SeqOneByteString::cast(string)->GetChars();
} else {
- start = ExternalAsciiString::cast(string)->GetChars();
+ start = ExternalOneByteString::cast(string)->GetChars();
}
return FlatContent(start + offset, length);
} else {
FlatStringReader::FlatStringReader(Isolate* isolate, Vector<const char> input)
: Relocatable(isolate),
str_(0),
- is_ascii_(true),
+ is_one_byte_(true),
length_(input.length()),
- start_(input.start()) { }
+ start_(input.start()) {}
void FlatStringReader::PostGarbageCollection() {
// This does not actually prevent the vector from being relocated later.
String::FlatContent content = str->GetFlatContent();
DCHECK(content.IsFlat());
- is_ascii_ = content.IsAscii();
- if (is_ascii_) {
+ is_one_byte_ = content.IsOneByte();
+ if (is_one_byte_) {
start_ = content.ToOneByteVector().start();
} else {
start_ = content.ToUC16Vector().start();
DCHECK(0 <= from && from <= to && to <= source->length());
switch (StringShape(source).full_representation_tag()) {
case kOneByteStringTag | kExternalStringTag: {
- CopyChars(sink,
- ExternalAsciiString::cast(source)->GetChars() + from,
+ CopyChars(sink, ExternalOneByteString::cast(source)->GetChars() + from,
to - from);
return;
}
String* second = cons_string->second();
// When repeatedly appending to a string, we get a cons string that
// is unbalanced to the left, a list, essentially. We inline the
- // common case of sequential ascii right child.
+ // common case of sequential one-byte right child.
if (to - boundary == 1) {
sink[boundary - from] = static_cast<sinkchar>(second->Get(0));
} else if (second->IsSeqOneByteString()) {
Vector<const SourceChar> src,
bool include_ending_line) {
const int src_len = src.length();
- StringSearch<uint8_t, SourceChar> search(isolate, STATIC_ASCII_VECTOR("\n"));
+ StringSearch<uint8_t, SourceChar> search(isolate, STATIC_CHAR_VECTOR("\n"));
// Find and record line ends.
int position = 0;
// Dispatch on type of strings.
String::FlatContent content = src->GetFlatContent();
DCHECK(content.IsFlat());
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
CalculateLineEndsImpl(isolate,
&line_ends,
content.ToOneByteVector(),
String::FlatContent flat1 = one->GetFlatContent();
String::FlatContent flat2 = two->GetFlatContent();
- if (flat1.IsAscii() && flat2.IsAscii()) {
+ if (flat1.IsOneByte() && flat2.IsOneByte()) {
return CompareRawStringContents(flat1.ToOneByteVector().start(),
flat2.ToOneByteVector().start(),
one_length);
if (map == heap->string_map()) {
this->set_map(heap->undetectable_string_map());
return true;
- } else if (map == heap->ascii_string_map()) {
- this->set_map(heap->undetectable_ascii_string_map());
+ } else if (map == heap->one_byte_string_map()) {
+ this->set_map(heap->undetectable_one_byte_string_map());
return true;
}
// Rest cannot be marked as undetectable
if (str.length() != slen) return false;
DisallowHeapAllocation no_gc;
FlatContent content = GetFlatContent();
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
return CompareChars(content.ToOneByteVector().start(),
str.start(), slen) == 0;
}
Isolate* isolate = script->GetIsolate();
Handle<String> name_or_source_url_key =
isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("nameOrSourceURL"));
+ STATIC_CHAR_VECTOR("nameOrSourceURL"));
Handle<JSObject> script_wrapper = Script::GetWrapper(script);
Handle<Object> property = Object::GetProperty(
script_wrapper, name_or_source_url_key).ToHandleChecked();
// - SlicedString
// - ConsString
// - ExternalString
-// - ExternalAsciiString
+// - ExternalOneByteString
// - ExternalTwoByteString
// - InternalizedString
// - SeqInternalizedString
// - SeqTwoByteInternalizedString
// - ConsInternalizedString
// - ExternalInternalizedString
-// - ExternalAsciiInternalizedString
+// - ExternalOneByteInternalizedString
// - ExternalTwoByteInternalizedString
// - Symbol
// - HeapNumber
//
// The names of the string instance types are intended to systematically
// mirror their encoding in the instance_type field of the map. The default
-// encoding is considered TWO_BYTE. It is not mentioned in the name. ASCII
+// encoding is considered TWO_BYTE. It is not mentioned in the name. ONE_BYTE
// encoding is mentioned explicitly in the name. Likewise, the default
// representation is considered sequential. It is not mentioned in the
// name. The other representations (e.g. CONS, EXTERNAL) are explicitly
// NOTE: Everything following JS_VALUE_TYPE is considered a
// JSObject for GC purposes. The first four entries here have typeof
// 'object', whereas JS_FUNCTION_TYPE has typeof 'function'.
-#define INSTANCE_TYPE_LIST(V) \
- V(STRING_TYPE) \
- V(ASCII_STRING_TYPE) \
- V(CONS_STRING_TYPE) \
- V(CONS_ASCII_STRING_TYPE) \
- V(SLICED_STRING_TYPE) \
- V(SLICED_ASCII_STRING_TYPE) \
- V(EXTERNAL_STRING_TYPE) \
- V(EXTERNAL_ASCII_STRING_TYPE) \
- V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
- V(SHORT_EXTERNAL_STRING_TYPE) \
- V(SHORT_EXTERNAL_ASCII_STRING_TYPE) \
- V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
- \
- V(INTERNALIZED_STRING_TYPE) \
- V(ASCII_INTERNALIZED_STRING_TYPE) \
- V(EXTERNAL_INTERNALIZED_STRING_TYPE) \
- V(EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE) \
- V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \
- V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE) \
- V(SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE) \
- V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \
- \
- V(SYMBOL_TYPE) \
- \
- V(MAP_TYPE) \
- V(CODE_TYPE) \
- V(ODDBALL_TYPE) \
- V(CELL_TYPE) \
- V(PROPERTY_CELL_TYPE) \
- \
- V(HEAP_NUMBER_TYPE) \
- V(MUTABLE_HEAP_NUMBER_TYPE) \
- V(FOREIGN_TYPE) \
- V(BYTE_ARRAY_TYPE) \
- V(FREE_SPACE_TYPE) \
- /* Note: the order of these external array */ \
- /* types is relied upon in */ \
- /* Object::IsExternalArray(). */ \
- V(EXTERNAL_INT8_ARRAY_TYPE) \
- V(EXTERNAL_UINT8_ARRAY_TYPE) \
- V(EXTERNAL_INT16_ARRAY_TYPE) \
- V(EXTERNAL_UINT16_ARRAY_TYPE) \
- V(EXTERNAL_INT32_ARRAY_TYPE) \
- V(EXTERNAL_UINT32_ARRAY_TYPE) \
- V(EXTERNAL_FLOAT32_ARRAY_TYPE) \
- V(EXTERNAL_FLOAT64_ARRAY_TYPE) \
- V(EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE) \
- \
- V(FIXED_INT8_ARRAY_TYPE) \
- V(FIXED_UINT8_ARRAY_TYPE) \
- V(FIXED_INT16_ARRAY_TYPE) \
- V(FIXED_UINT16_ARRAY_TYPE) \
- V(FIXED_INT32_ARRAY_TYPE) \
- V(FIXED_UINT32_ARRAY_TYPE) \
- V(FIXED_FLOAT32_ARRAY_TYPE) \
- V(FIXED_FLOAT64_ARRAY_TYPE) \
- V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \
- \
- V(FILLER_TYPE) \
- \
- V(DECLARED_ACCESSOR_DESCRIPTOR_TYPE) \
- V(DECLARED_ACCESSOR_INFO_TYPE) \
- V(EXECUTABLE_ACCESSOR_INFO_TYPE) \
- V(ACCESSOR_PAIR_TYPE) \
- V(ACCESS_CHECK_INFO_TYPE) \
- V(INTERCEPTOR_INFO_TYPE) \
- V(CALL_HANDLER_INFO_TYPE) \
- V(FUNCTION_TEMPLATE_INFO_TYPE) \
- V(OBJECT_TEMPLATE_INFO_TYPE) \
- V(SIGNATURE_INFO_TYPE) \
- V(TYPE_SWITCH_INFO_TYPE) \
- V(ALLOCATION_MEMENTO_TYPE) \
- V(ALLOCATION_SITE_TYPE) \
- V(SCRIPT_TYPE) \
- V(CODE_CACHE_TYPE) \
- V(POLYMORPHIC_CODE_CACHE_TYPE) \
- V(TYPE_FEEDBACK_INFO_TYPE) \
- V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
- V(BOX_TYPE) \
- \
- V(FIXED_ARRAY_TYPE) \
- V(FIXED_DOUBLE_ARRAY_TYPE) \
- V(CONSTANT_POOL_ARRAY_TYPE) \
- V(SHARED_FUNCTION_INFO_TYPE) \
- \
- V(JS_MESSAGE_OBJECT_TYPE) \
- \
- V(JS_VALUE_TYPE) \
- V(JS_DATE_TYPE) \
- V(JS_OBJECT_TYPE) \
- V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
- V(JS_GENERATOR_OBJECT_TYPE) \
- V(JS_MODULE_TYPE) \
- V(JS_GLOBAL_OBJECT_TYPE) \
- V(JS_BUILTINS_OBJECT_TYPE) \
- V(JS_GLOBAL_PROXY_TYPE) \
- V(JS_ARRAY_TYPE) \
- V(JS_ARRAY_BUFFER_TYPE) \
- V(JS_TYPED_ARRAY_TYPE) \
- V(JS_DATA_VIEW_TYPE) \
- V(JS_PROXY_TYPE) \
- V(JS_SET_TYPE) \
- V(JS_MAP_TYPE) \
- V(JS_SET_ITERATOR_TYPE) \
- V(JS_MAP_ITERATOR_TYPE) \
- V(JS_WEAK_MAP_TYPE) \
- V(JS_WEAK_SET_TYPE) \
- V(JS_REGEXP_TYPE) \
- \
- V(JS_FUNCTION_TYPE) \
- V(JS_FUNCTION_PROXY_TYPE) \
- V(DEBUG_INFO_TYPE) \
+#define INSTANCE_TYPE_LIST(V) \
+ V(STRING_TYPE) \
+ V(ONE_BYTE_STRING_TYPE) \
+ V(CONS_STRING_TYPE) \
+ V(CONS_ONE_BYTE_STRING_TYPE) \
+ V(SLICED_STRING_TYPE) \
+ V(SLICED_ONE_BYTE_STRING_TYPE) \
+ V(EXTERNAL_STRING_TYPE) \
+ V(EXTERNAL_ONE_BYTE_STRING_TYPE) \
+ V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
+ V(SHORT_EXTERNAL_STRING_TYPE) \
+ V(SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE) \
+ V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
+ \
+ V(INTERNALIZED_STRING_TYPE) \
+ V(ONE_BYTE_INTERNALIZED_STRING_TYPE) \
+ V(EXTERNAL_INTERNALIZED_STRING_TYPE) \
+ V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \
+ V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \
+ V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE) \
+ V(SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE) \
+ V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \
+ \
+ V(SYMBOL_TYPE) \
+ \
+ V(MAP_TYPE) \
+ V(CODE_TYPE) \
+ V(ODDBALL_TYPE) \
+ V(CELL_TYPE) \
+ V(PROPERTY_CELL_TYPE) \
+ \
+ V(HEAP_NUMBER_TYPE) \
+ V(MUTABLE_HEAP_NUMBER_TYPE) \
+ V(FOREIGN_TYPE) \
+ V(BYTE_ARRAY_TYPE) \
+ V(FREE_SPACE_TYPE) \
+ /* Note: the order of these external array */ \
+ /* types is relied upon in */ \
+ /* Object::IsExternalArray(). */ \
+ V(EXTERNAL_INT8_ARRAY_TYPE) \
+ V(EXTERNAL_UINT8_ARRAY_TYPE) \
+ V(EXTERNAL_INT16_ARRAY_TYPE) \
+ V(EXTERNAL_UINT16_ARRAY_TYPE) \
+ V(EXTERNAL_INT32_ARRAY_TYPE) \
+ V(EXTERNAL_UINT32_ARRAY_TYPE) \
+ V(EXTERNAL_FLOAT32_ARRAY_TYPE) \
+ V(EXTERNAL_FLOAT64_ARRAY_TYPE) \
+ V(EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE) \
+ \
+ V(FIXED_INT8_ARRAY_TYPE) \
+ V(FIXED_UINT8_ARRAY_TYPE) \
+ V(FIXED_INT16_ARRAY_TYPE) \
+ V(FIXED_UINT16_ARRAY_TYPE) \
+ V(FIXED_INT32_ARRAY_TYPE) \
+ V(FIXED_UINT32_ARRAY_TYPE) \
+ V(FIXED_FLOAT32_ARRAY_TYPE) \
+ V(FIXED_FLOAT64_ARRAY_TYPE) \
+ V(FIXED_UINT8_CLAMPED_ARRAY_TYPE) \
+ \
+ V(FILLER_TYPE) \
+ \
+ V(DECLARED_ACCESSOR_DESCRIPTOR_TYPE) \
+ V(DECLARED_ACCESSOR_INFO_TYPE) \
+ V(EXECUTABLE_ACCESSOR_INFO_TYPE) \
+ V(ACCESSOR_PAIR_TYPE) \
+ V(ACCESS_CHECK_INFO_TYPE) \
+ V(INTERCEPTOR_INFO_TYPE) \
+ V(CALL_HANDLER_INFO_TYPE) \
+ V(FUNCTION_TEMPLATE_INFO_TYPE) \
+ V(OBJECT_TEMPLATE_INFO_TYPE) \
+ V(SIGNATURE_INFO_TYPE) \
+ V(TYPE_SWITCH_INFO_TYPE) \
+ V(ALLOCATION_MEMENTO_TYPE) \
+ V(ALLOCATION_SITE_TYPE) \
+ V(SCRIPT_TYPE) \
+ V(CODE_CACHE_TYPE) \
+ V(POLYMORPHIC_CODE_CACHE_TYPE) \
+ V(TYPE_FEEDBACK_INFO_TYPE) \
+ V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
+ V(BOX_TYPE) \
+ \
+ V(FIXED_ARRAY_TYPE) \
+ V(FIXED_DOUBLE_ARRAY_TYPE) \
+ V(CONSTANT_POOL_ARRAY_TYPE) \
+ V(SHARED_FUNCTION_INFO_TYPE) \
+ \
+ V(JS_MESSAGE_OBJECT_TYPE) \
+ \
+ V(JS_VALUE_TYPE) \
+ V(JS_DATE_TYPE) \
+ V(JS_OBJECT_TYPE) \
+ V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
+ V(JS_GENERATOR_OBJECT_TYPE) \
+ V(JS_MODULE_TYPE) \
+ V(JS_GLOBAL_OBJECT_TYPE) \
+ V(JS_BUILTINS_OBJECT_TYPE) \
+ V(JS_GLOBAL_PROXY_TYPE) \
+ V(JS_ARRAY_TYPE) \
+ V(JS_ARRAY_BUFFER_TYPE) \
+ V(JS_TYPED_ARRAY_TYPE) \
+ V(JS_DATA_VIEW_TYPE) \
+ V(JS_PROXY_TYPE) \
+ V(JS_SET_TYPE) \
+ V(JS_MAP_TYPE) \
+ V(JS_SET_ITERATOR_TYPE) \
+ V(JS_MAP_ITERATOR_TYPE) \
+ V(JS_WEAK_MAP_TYPE) \
+ V(JS_WEAK_SET_TYPE) \
+ V(JS_REGEXP_TYPE) \
+ \
+ V(JS_FUNCTION_TYPE) \
+ V(JS_FUNCTION_PROXY_TYPE) \
+ V(DEBUG_INFO_TYPE) \
V(BREAK_POINT_INFO_TYPE)
// Since string types are not consecutive, this macro is used to
// iterate over them.
-#define STRING_TYPE_LIST(V) \
- V(STRING_TYPE, \
- kVariableSizeSentinel, \
- string, \
- String) \
- V(ASCII_STRING_TYPE, \
- kVariableSizeSentinel, \
- ascii_string, \
- AsciiString) \
- V(CONS_STRING_TYPE, \
- ConsString::kSize, \
- cons_string, \
- ConsString) \
- V(CONS_ASCII_STRING_TYPE, \
- ConsString::kSize, \
- cons_ascii_string, \
- ConsAsciiString) \
- V(SLICED_STRING_TYPE, \
- SlicedString::kSize, \
- sliced_string, \
- SlicedString) \
- V(SLICED_ASCII_STRING_TYPE, \
- SlicedString::kSize, \
- sliced_ascii_string, \
- SlicedAsciiString) \
- V(EXTERNAL_STRING_TYPE, \
- ExternalTwoByteString::kSize, \
- external_string, \
- ExternalString) \
- V(EXTERNAL_ASCII_STRING_TYPE, \
- ExternalAsciiString::kSize, \
- external_ascii_string, \
- ExternalAsciiString) \
- V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, \
- ExternalTwoByteString::kSize, \
- external_string_with_one_byte_data, \
- ExternalStringWithOneByteData) \
- V(SHORT_EXTERNAL_STRING_TYPE, \
- ExternalTwoByteString::kShortSize, \
- short_external_string, \
- ShortExternalString) \
- V(SHORT_EXTERNAL_ASCII_STRING_TYPE, \
- ExternalAsciiString::kShortSize, \
- short_external_ascii_string, \
- ShortExternalAsciiString) \
- V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, \
- ExternalTwoByteString::kShortSize, \
- short_external_string_with_one_byte_data, \
- ShortExternalStringWithOneByteData) \
- \
- V(INTERNALIZED_STRING_TYPE, \
- kVariableSizeSentinel, \
- internalized_string, \
- InternalizedString) \
- V(ASCII_INTERNALIZED_STRING_TYPE, \
- kVariableSizeSentinel, \
- ascii_internalized_string, \
- AsciiInternalizedString) \
- V(EXTERNAL_INTERNALIZED_STRING_TYPE, \
- ExternalTwoByteString::kSize, \
- external_internalized_string, \
- ExternalInternalizedString) \
- V(EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE, \
- ExternalAsciiString::kSize, \
- external_ascii_internalized_string, \
- ExternalAsciiInternalizedString) \
- V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
- ExternalTwoByteString::kSize, \
- external_internalized_string_with_one_byte_data, \
- ExternalInternalizedStringWithOneByteData) \
- V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE, \
- ExternalTwoByteString::kShortSize, \
- short_external_internalized_string, \
- ShortExternalInternalizedString) \
- V(SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE, \
- ExternalAsciiString::kShortSize, \
- short_external_ascii_internalized_string, \
- ShortExternalAsciiInternalizedString) \
- V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
- ExternalTwoByteString::kShortSize, \
- short_external_internalized_string_with_one_byte_data, \
- ShortExternalInternalizedStringWithOneByteData) \
+#define STRING_TYPE_LIST(V) \
+ V(STRING_TYPE, kVariableSizeSentinel, string, String) \
+ V(ONE_BYTE_STRING_TYPE, kVariableSizeSentinel, one_byte_string, \
+ OneByteString) \
+ V(CONS_STRING_TYPE, ConsString::kSize, cons_string, ConsString) \
+ V(CONS_ONE_BYTE_STRING_TYPE, ConsString::kSize, cons_one_byte_string, \
+ ConsOneByteString) \
+ V(SLICED_STRING_TYPE, SlicedString::kSize, sliced_string, SlicedString) \
+ V(SLICED_ONE_BYTE_STRING_TYPE, SlicedString::kSize, sliced_one_byte_string, \
+ SlicedOneByteString) \
+ V(EXTERNAL_STRING_TYPE, ExternalTwoByteString::kSize, external_string, \
+ ExternalString) \
+ V(EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kSize, \
+ external_one_byte_string, ExternalOneByteString) \
+ V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, ExternalTwoByteString::kSize, \
+ external_string_with_one_byte_data, ExternalStringWithOneByteData) \
+ V(SHORT_EXTERNAL_STRING_TYPE, ExternalTwoByteString::kShortSize, \
+ short_external_string, ShortExternalString) \
+ V(SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE, ExternalOneByteString::kShortSize, \
+ short_external_one_byte_string, ShortExternalOneByteString) \
+ V(SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, \
+ ExternalTwoByteString::kShortSize, \
+ short_external_string_with_one_byte_data, \
+ ShortExternalStringWithOneByteData) \
+ \
+ V(INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, internalized_string, \
+ InternalizedString) \
+ V(ONE_BYTE_INTERNALIZED_STRING_TYPE, kVariableSizeSentinel, \
+ one_byte_internalized_string, OneByteInternalizedString) \
+ V(EXTERNAL_INTERNALIZED_STRING_TYPE, ExternalTwoByteString::kSize, \
+ external_internalized_string, ExternalInternalizedString) \
+ V(EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, ExternalOneByteString::kSize, \
+ external_one_byte_internalized_string, ExternalOneByteInternalizedString) \
+ V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
+ ExternalTwoByteString::kSize, \
+ external_internalized_string_with_one_byte_data, \
+ ExternalInternalizedStringWithOneByteData) \
+ V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE, \
+ ExternalTwoByteString::kShortSize, short_external_internalized_string, \
+ ShortExternalInternalizedString) \
+ V(SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE, \
+ ExternalOneByteString::kShortSize, \
+ short_external_one_byte_internalized_string, \
+ ShortExternalOneByteInternalizedString) \
+ V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
+ ExternalTwoByteString::kShortSize, \
+ short_external_internalized_string_with_one_byte_data, \
+ ShortExternalInternalizedStringWithOneByteData)
// A struct is a simple object a set of object-valued fields. Including an
// object type in this causes the compiler to generate most of the boilerplate
enum InstanceType {
// String types.
- INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kSeqStringTag
- | kInternalizedTag,
- ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kSeqStringTag
- | kInternalizedTag,
- EXTERNAL_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kExternalStringTag
- | kInternalizedTag,
- EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag
- | kExternalStringTag | kInternalizedTag,
+ INTERNALIZED_STRING_TYPE =
+ kTwoByteStringTag | kSeqStringTag | kInternalizedTag,
+ ONE_BYTE_INTERNALIZED_STRING_TYPE =
+ kOneByteStringTag | kSeqStringTag | kInternalizedTag,
+ EXTERNAL_INTERNALIZED_STRING_TYPE =
+ kTwoByteStringTag | kExternalStringTag | kInternalizedTag,
+ EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE =
+ kOneByteStringTag | kExternalStringTag | kInternalizedTag,
EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE =
- EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag
- | kInternalizedTag,
- SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE =
- EXTERNAL_INTERNALIZED_STRING_TYPE | kShortExternalStringTag
- | kInternalizedTag,
- SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE =
- EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kShortExternalStringTag
- | kInternalizedTag,
+ EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag |
+ kInternalizedTag,
+ SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = EXTERNAL_INTERNALIZED_STRING_TYPE |
+ kShortExternalStringTag |
+ kInternalizedTag,
+ SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE =
+ EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kShortExternalStringTag |
+ kInternalizedTag,
SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE =
- EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE
- | kShortExternalStringTag | kInternalizedTag,
-
+ EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
+ kShortExternalStringTag | kInternalizedTag,
STRING_TYPE = INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
- ASCII_STRING_TYPE = ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
+ ONE_BYTE_STRING_TYPE =
+ ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag | kNotInternalizedTag,
- CONS_ASCII_STRING_TYPE =
+ CONS_ONE_BYTE_STRING_TYPE =
kOneByteStringTag | kConsStringTag | kNotInternalizedTag,
-
SLICED_STRING_TYPE =
kTwoByteStringTag | kSlicedStringTag | kNotInternalizedTag,
- SLICED_ASCII_STRING_TYPE =
+ SLICED_ONE_BYTE_STRING_TYPE =
kOneByteStringTag | kSlicedStringTag | kNotInternalizedTag,
EXTERNAL_STRING_TYPE =
- EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
- EXTERNAL_ASCII_STRING_TYPE =
- EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
+ EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
+ EXTERNAL_ONE_BYTE_STRING_TYPE =
+ EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE =
- EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE
- | kNotInternalizedTag,
+ EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
+ kNotInternalizedTag,
SHORT_EXTERNAL_STRING_TYPE =
SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
- SHORT_EXTERNAL_ASCII_STRING_TYPE =
- SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
+ SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE =
+ SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE =
- SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE
- | kNotInternalizedTag,
+ SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
+ kNotInternalizedTag,
// Non-string names
SYMBOL_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE, LAST_NAME_TYPE
FOREIGN_TYPE,
BYTE_ARRAY_TYPE,
FREE_SPACE_TYPE,
-
EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE
EXTERNAL_UINT8_ARRAY_TYPE,
EXTERNAL_INT16_ARRAY_TYPE,
EXTERNAL_FLOAT32_ARRAY_TYPE,
EXTERNAL_FLOAT64_ARRAY_TYPE,
EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
-
- FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE
+ FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE
FIXED_UINT8_ARRAY_TYPE,
FIXED_INT16_ARRAY_TYPE,
FIXED_UINT16_ARRAY_TYPE,
FIXED_FLOAT32_ARRAY_TYPE,
FIXED_FLOAT64_ARRAY_TYPE,
FIXED_UINT8_CLAMPED_ARRAY_TYPE, // LAST_FIXED_TYPED_ARRAY_TYPE
-
FIXED_DOUBLE_ARRAY_TYPE,
FILLER_TYPE, // LAST_DATA_TYPE
BOX_TYPE,
DEBUG_INFO_TYPE,
BREAK_POINT_INFO_TYPE,
-
FIXED_ARRAY_TYPE,
CONSTANT_POOL_ARRAY_TYPE,
SHARED_FUNCTION_INFO_TYPE,
// compares for checking the JS_RECEIVER/SPEC_OBJECT range and the
// NONCALLABLE_JS_OBJECT range.
JS_FUNCTION_PROXY_TYPE, // FIRST_JS_RECEIVER_TYPE, FIRST_JS_PROXY_TYPE
- JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE
-
- JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
+ JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE
+ JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
JS_MESSAGE_OBJECT_TYPE,
JS_DATE_TYPE,
JS_OBJECT_TYPE,
JS_MAP_ITERATOR_TYPE,
JS_WEAK_MAP_TYPE,
JS_WEAK_SET_TYPE,
-
JS_REGEXP_TYPE,
-
JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE
// Pseudo-types
#endif
-#define OBJECT_TYPE_LIST(V) \
- V(Smi) \
- V(HeapObject) \
- V(Number) \
-
-#define HEAP_OBJECT_TYPE_LIST(V) \
- V(HeapNumber) \
- V(MutableHeapNumber) \
- V(Name) \
- V(UniqueName) \
- V(String) \
- V(SeqString) \
- V(ExternalString) \
- V(ConsString) \
- V(SlicedString) \
- V(ExternalTwoByteString) \
- V(ExternalAsciiString) \
- V(SeqTwoByteString) \
- V(SeqOneByteString) \
- V(InternalizedString) \
- V(Symbol) \
- \
- V(ExternalArray) \
- V(ExternalInt8Array) \
- V(ExternalUint8Array) \
- V(ExternalInt16Array) \
- V(ExternalUint16Array) \
- V(ExternalInt32Array) \
- V(ExternalUint32Array) \
- V(ExternalFloat32Array) \
- V(ExternalFloat64Array) \
- V(ExternalUint8ClampedArray) \
- V(FixedTypedArrayBase) \
- V(FixedUint8Array) \
- V(FixedInt8Array) \
- V(FixedUint16Array) \
- V(FixedInt16Array) \
- V(FixedUint32Array) \
- V(FixedInt32Array) \
- V(FixedFloat32Array) \
- V(FixedFloat64Array) \
- V(FixedUint8ClampedArray) \
- V(ByteArray) \
- V(FreeSpace) \
- V(JSReceiver) \
- V(JSObject) \
- V(JSContextExtensionObject) \
- V(JSGeneratorObject) \
- V(JSModule) \
- V(Map) \
- V(DescriptorArray) \
- V(TransitionArray) \
- V(DeoptimizationInputData) \
- V(DeoptimizationOutputData) \
- V(DependentCode) \
- V(FixedArray) \
- V(FixedDoubleArray) \
- V(ConstantPoolArray) \
- V(Context) \
- V(NativeContext) \
- V(ScopeInfo) \
- V(JSFunction) \
- V(Code) \
- V(Oddball) \
- V(SharedFunctionInfo) \
- V(JSValue) \
- V(JSDate) \
- V(JSMessageObject) \
- V(StringWrapper) \
- V(Foreign) \
- V(Boolean) \
- V(JSArray) \
- V(JSArrayBuffer) \
- V(JSArrayBufferView) \
- V(JSTypedArray) \
- V(JSDataView) \
- V(JSProxy) \
- V(JSFunctionProxy) \
- V(JSSet) \
- V(JSMap) \
- V(JSSetIterator) \
- V(JSMapIterator) \
- V(JSWeakCollection) \
- V(JSWeakMap) \
- V(JSWeakSet) \
- V(JSRegExp) \
- V(HashTable) \
- V(Dictionary) \
- V(StringTable) \
- V(JSFunctionResultCache) \
- V(NormalizedMapCache) \
- V(CompilationCacheTable) \
- V(CodeCacheHashTable) \
- V(PolymorphicCodeCacheHashTable) \
- V(MapCache) \
- V(Primitive) \
- V(GlobalObject) \
- V(JSGlobalObject) \
- V(JSBuiltinsObject) \
- V(JSGlobalProxy) \
- V(UndetectableObject) \
- V(AccessCheckNeeded) \
- V(Cell) \
- V(PropertyCell) \
- V(ObjectHashTable) \
- V(WeakHashTable) \
+#define OBJECT_TYPE_LIST(V) \
+ V(Smi) \
+ V(HeapObject) \
+ V(Number)
+
+#define HEAP_OBJECT_TYPE_LIST(V) \
+ V(HeapNumber) \
+ V(MutableHeapNumber) \
+ V(Name) \
+ V(UniqueName) \
+ V(String) \
+ V(SeqString) \
+ V(ExternalString) \
+ V(ConsString) \
+ V(SlicedString) \
+ V(ExternalTwoByteString) \
+ V(ExternalOneByteString) \
+ V(SeqTwoByteString) \
+ V(SeqOneByteString) \
+ V(InternalizedString) \
+ V(Symbol) \
+ \
+ V(ExternalArray) \
+ V(ExternalInt8Array) \
+ V(ExternalUint8Array) \
+ V(ExternalInt16Array) \
+ V(ExternalUint16Array) \
+ V(ExternalInt32Array) \
+ V(ExternalUint32Array) \
+ V(ExternalFloat32Array) \
+ V(ExternalFloat64Array) \
+ V(ExternalUint8ClampedArray) \
+ V(FixedTypedArrayBase) \
+ V(FixedUint8Array) \
+ V(FixedInt8Array) \
+ V(FixedUint16Array) \
+ V(FixedInt16Array) \
+ V(FixedUint32Array) \
+ V(FixedInt32Array) \
+ V(FixedFloat32Array) \
+ V(FixedFloat64Array) \
+ V(FixedUint8ClampedArray) \
+ V(ByteArray) \
+ V(FreeSpace) \
+ V(JSReceiver) \
+ V(JSObject) \
+ V(JSContextExtensionObject) \
+ V(JSGeneratorObject) \
+ V(JSModule) \
+ V(Map) \
+ V(DescriptorArray) \
+ V(TransitionArray) \
+ V(DeoptimizationInputData) \
+ V(DeoptimizationOutputData) \
+ V(DependentCode) \
+ V(FixedArray) \
+ V(FixedDoubleArray) \
+ V(ConstantPoolArray) \
+ V(Context) \
+ V(NativeContext) \
+ V(ScopeInfo) \
+ V(JSFunction) \
+ V(Code) \
+ V(Oddball) \
+ V(SharedFunctionInfo) \
+ V(JSValue) \
+ V(JSDate) \
+ V(JSMessageObject) \
+ V(StringWrapper) \
+ V(Foreign) \
+ V(Boolean) \
+ V(JSArray) \
+ V(JSArrayBuffer) \
+ V(JSArrayBufferView) \
+ V(JSTypedArray) \
+ V(JSDataView) \
+ V(JSProxy) \
+ V(JSFunctionProxy) \
+ V(JSSet) \
+ V(JSMap) \
+ V(JSSetIterator) \
+ V(JSMapIterator) \
+ V(JSWeakCollection) \
+ V(JSWeakMap) \
+ V(JSWeakSet) \
+ V(JSRegExp) \
+ V(HashTable) \
+ V(Dictionary) \
+ V(StringTable) \
+ V(JSFunctionResultCache) \
+ V(NormalizedMapCache) \
+ V(CompilationCacheTable) \
+ V(CodeCacheHashTable) \
+ V(PolymorphicCodeCacheHashTable) \
+ V(MapCache) \
+ V(Primitive) \
+ V(GlobalObject) \
+ V(JSGlobalObject) \
+ V(JSBuiltinsObject) \
+ V(JSGlobalProxy) \
+ V(UndetectableObject) \
+ V(AccessCheckNeeded) \
+ V(Cell) \
+ V(PropertyCell) \
+ V(ObjectHashTable) \
+ V(WeakHashTable) \
V(OrderedHashTable)
V(kIndexIsNegative, "Index is negative") \
V(kIndexIsTooLarge, "Index is too large") \
V(kInlinedRuntimeFunctionClassOf, "Inlined runtime function: ClassOf") \
- V(kInlinedRuntimeFunctionFastAsciiArrayJoin, \
- "Inlined runtime function: FastAsciiArrayJoin") \
+ V(kInlinedRuntimeFunctionFastOneByteArrayJoin, \
+ "Inlined runtime function: FastOneByteArrayJoin") \
V(kInlinedRuntimeFunctionGeneratorNext, \
"Inlined runtime function: GeneratorNext") \
V(kInlinedRuntimeFunctionGeneratorThrow, \
V(kSuperReference, "Super reference") \
V(kNeedSmiLiteral, "Need a Smi literal here") \
V(kNoCasesLeft, "No cases left") \
- V(kNoEmptyArraysHereInEmitFastAsciiArrayJoin, \
- "No empty arrays here in EmitFastAsciiArrayJoin") \
+ V(kNoEmptyArraysHereInEmitFastOneByteArrayJoin, \
+ "No empty arrays here in EmitFastOneByteArrayJoin") \
V(kNonInitializerAssignmentToConst, "Non-initializer assignment to const") \
V(kNonSmiIndex, "Non-smi index") \
V(kNonSmiKeyInArrayLiteral, "Non-smi key in array literal") \
DECLARE_CAST(StringTable)
private:
- template <bool seq_ascii> friend class JsonParser;
+ template <bool seq_one_byte>
+ friend class JsonParser;
DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable);
};
// If it is an atom regexp
// - a reference to a literal string to search for
// If it is an irregexp regexp:
-// - a reference to code for ASCII inputs (bytecode or compiled), or a smi
+// - a reference to code for Latin1 inputs (bytecode or compiled), or a smi
// used for tracking the last usage (used for code flushing).
// - a reference to code for UC16 inputs (bytecode or compiled), or a smi
// used for tracking the last usage (used for code flushing)..
// Set implementation data after the object has been prepared.
inline void SetDataAt(int index, Object* value);
- static int code_index(bool is_ascii) {
- if (is_ascii) {
- return kIrregexpASCIICodeIndex;
+ static int code_index(bool is_latin1) {
+ if (is_latin1) {
+ return kIrregexpLatin1CodeIndex;
} else {
return kIrregexpUC16CodeIndex;
}
}
- static int saved_code_index(bool is_ascii) {
- if (is_ascii) {
- return kIrregexpASCIICodeSavedIndex;
+ static int saved_code_index(bool is_latin1) {
+ if (is_latin1) {
+ return kIrregexpLatin1CodeSavedIndex;
} else {
return kIrregexpUC16CodeSavedIndex;
}
static const int kAtomDataSize = kAtomPatternIndex + 1;
- // Irregexp compiled code or bytecode for ASCII. If compilation
+ // Irregexp compiled code or bytecode for Latin1. If compilation
// fails, this fields hold an exception object that should be
// thrown if the regexp is used again.
- static const int kIrregexpASCIICodeIndex = kDataIndex;
+ static const int kIrregexpLatin1CodeIndex = kDataIndex;
// Irregexp compiled code or bytecode for UC16. If compilation
// fails, this fields hold an exception object that should be
// thrown if the regexp is used again.
static const int kIrregexpUC16CodeIndex = kDataIndex + 1;
- // Saved instance of Irregexp compiled code or bytecode for ASCII that
+ // Saved instance of Irregexp compiled code or bytecode for Latin1 that
// is a potential candidate for flushing.
- static const int kIrregexpASCIICodeSavedIndex = kDataIndex + 2;
+ static const int kIrregexpLatin1CodeSavedIndex = kDataIndex + 2;
// Saved instance of Irregexp compiled code or bytecode for UC16 that is
// a potential candidate for flushing.
static const int kIrregexpUC16CodeSavedIndex = kDataIndex + 3;
- // Maximal number of registers used by either ASCII or UC16.
+ // Maximal number of registers used by either Latin1 or UC16.
// Only used to check that there is enough stack space
static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 4;
// Number of captures in the compiled regexp.
// Offsets directly into the data fixed array.
static const int kDataTagOffset =
FixedArray::kHeaderSize + kTagIndex * kPointerSize;
- static const int kDataAsciiCodeOffset =
- FixedArray::kHeaderSize + kIrregexpASCIICodeIndex * kPointerSize;
+ static const int kDataOneByteCodeOffset =
+ FixedArray::kHeaderSize + kIrregexpLatin1CodeIndex * kPointerSize;
static const int kDataUC16CodeOffset =
FixedArray::kHeaderSize + kIrregexpUC16CodeIndex * kPointerSize;
static const int kIrregexpCaptureCountOffset =
inline bool IsCons();
inline bool IsSliced();
inline bool IsIndirect();
- inline bool IsExternalAscii();
+ inline bool IsExternalOneByte();
inline bool IsExternalTwoByte();
- inline bool IsSequentialAscii();
+ inline bool IsSequentialOneByte();
inline bool IsSequentialTwoByte();
inline bool IsInternalized();
inline StringRepresentationTag representation_tag();
// Representation of the flat content of a String.
// A non-flat string doesn't have flat content.
// A flat string has content that's encoded as a sequence of either
- // ASCII chars or two-byte UC16.
+ // one-byte chars or two-byte UC16.
// Returned by String::GetFlatContent().
class FlatContent {
public:
// Returns true if the string is flat and this structure contains content.
bool IsFlat() { return state_ != NON_FLAT; }
- // Returns true if the structure contains ASCII content.
- bool IsAscii() { return state_ == ASCII; }
+ // Returns true if the structure contains one-byte content.
+ bool IsOneByte() { return state_ == ONE_BYTE; }
// Returns true if the structure contains two-byte content.
bool IsTwoByte() { return state_ == TWO_BYTE; }
- // Return the one byte content of the string. Only use if IsAscii() returns
- // true.
+ // Return the one byte content of the string. Only use if IsOneByte()
+ // returns true.
Vector<const uint8_t> ToOneByteVector() {
- DCHECK_EQ(ASCII, state_);
+ DCHECK_EQ(ONE_BYTE, state_);
return Vector<const uint8_t>(onebyte_start, length_);
}
// Return the two-byte content of the string. Only use if IsTwoByte()
uc16 Get(int i) {
DCHECK(i < length_);
DCHECK(state_ != NON_FLAT);
- if (state_ == ASCII) return onebyte_start[i];
+ if (state_ == ONE_BYTE) return onebyte_start[i];
return twobyte_start[i];
}
private:
- enum State { NON_FLAT, ASCII, TWO_BYTE };
+ enum State { NON_FLAT, ONE_BYTE, TWO_BYTE };
// Constructors only used by String::GetFlatContent().
explicit FlatContent(const uint8_t* start, int length)
- : onebyte_start(start), length_(length), state_(ASCII) { }
+ : onebyte_start(start), length_(length), state_(ONE_BYTE) {}
explicit FlatContent(const uc16* start, int length)
: twobyte_start(start), length_(length), state_(TWO_BYTE) { }
FlatContent() : onebyte_start(NULL), length_(0), state_(NON_FLAT) { }
inline int synchronized_length() const;
inline void synchronized_set_length(int value);
- // Returns whether this string has only ASCII chars, i.e. all of them can
- // be ASCII encoded. This might be the case even if the string is
+ // Returns whether this string has only one-byte chars, i.e. all of them can
+ // be one-byte encoded. This might be the case even if the string is
// two-byte. Such strings may appear when the embedder prefers
- // two-byte external representations even for ASCII data.
+ // two-byte external representations even for one-byte data.
inline bool IsOneByteRepresentation() const;
inline bool IsTwoByteRepresentation() const;
inline String* GetUnderlying();
// Mark the string as an undetectable object. It only applies to
- // ASCII and two byte string types.
+ // one-byte and two-byte string types.
bool MarkAsUndetectable();
// String equality operations.
// Externalization.
bool MakeExternal(v8::String::ExternalStringResource* resource);
- bool MakeExternal(v8::String::ExternalAsciiStringResource* resource);
+ bool MakeExternal(v8::String::ExternalOneByteStringResource* resource);
// Conversion.
inline bool AsArrayIndex(uint32_t* index);
int from,
int to);
- // The return value may point to the first aligned word containing the
- // first non-ascii character, rather than directly to the non-ascii character.
- // If the return value is >= the passed length, the entire string was ASCII.
+ // The return value may point to the first aligned word containing the first
+ // non-one-byte character, rather than directly to the non-one-byte character.
+ // If the return value is >= the passed length, the entire string was
+ // one-byte.
static inline int NonAsciiStart(const char* chars, int length) {
const char* start = chars;
const char* limit = chars + length;
#ifdef V8_HOST_CAN_READ_UNALIGNED
DCHECK(unibrow::Utf8::kMaxOneByteChar == 0x7F);
- const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80;
+ const uintptr_t non_one_byte_mask = kUintptrAllBitsSet / 0xFF * 0x80;
while (chars + sizeof(uintptr_t) <= limit) {
- if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) {
+ if (*reinterpret_cast<const uintptr_t*>(chars) & non_one_byte_mask) {
return static_cast<int>(chars - start);
}
chars += sizeof(uintptr_t);
};
-// The AsciiString class captures sequential ASCII string objects.
-// Each character in the AsciiString is an ASCII character.
+// The OneByteString class captures sequential one-byte string objects.
+// Each character in the OneByteString is an one-byte character.
class SeqOneByteString: public SeqString {
public:
- static const bool kHasAsciiEncoding = true;
+ static const bool kHasOneByteEncoding = true;
// Dispatched behavior.
inline uint16_t SeqOneByteStringGet(int index);
DECLARE_CAST(SeqOneByteString)
// Garbage collection support. This method is called by the
- // garbage collector to compute the actual size of an AsciiString
+ // garbage collector to compute the actual size of an OneByteString
// instance.
inline int SeqOneByteStringSize(InstanceType instance_type);
- // Computes the size for an AsciiString instance of a given length.
+ // Computes the size for an OneByteString instance of a given length.
static int SizeFor(int length) {
return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize);
}
- // Maximal memory usage for a single sequential ASCII string.
+ // Maximal memory usage for a single sequential one-byte string.
static const int kMaxSize = 512 * MB - 1;
STATIC_ASSERT((kMaxSize - kHeaderSize) >= String::kMaxLength);
// Each character in the TwoByteString is a two-byte uint16_t.
class SeqTwoByteString: public SeqString {
public:
- static const bool kHasAsciiEncoding = false;
+ static const bool kHasOneByteEncoding = false;
// Dispatched behavior.
inline uint16_t SeqTwoByteStringGet(int index);
};
-// The ExternalAsciiString class is an external string backed by an
-// ASCII string.
-class ExternalAsciiString: public ExternalString {
+// The ExternalOneByteString class is an external string backed by an
+// one-byte string.
+class ExternalOneByteString : public ExternalString {
public:
- static const bool kHasAsciiEncoding = true;
+ static const bool kHasOneByteEncoding = true;
- typedef v8::String::ExternalAsciiStringResource Resource;
+ typedef v8::String::ExternalOneByteStringResource Resource;
// The underlying resource.
inline const Resource* resource();
inline const uint8_t* GetChars();
// Dispatched behavior.
- inline uint16_t ExternalAsciiStringGet(int index);
+ inline uint16_t ExternalOneByteStringGet(int index);
- DECLARE_CAST(ExternalAsciiString)
+ DECLARE_CAST(ExternalOneByteString)
// Garbage collection support.
- inline void ExternalAsciiStringIterateBody(ObjectVisitor* v);
+ inline void ExternalOneByteStringIterateBody(ObjectVisitor* v);
- template<typename StaticVisitor>
- inline void ExternalAsciiStringIterateBody();
+ template <typename StaticVisitor>
+ inline void ExternalOneByteStringIterateBody();
private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalAsciiString);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString);
};
// encoded string.
class ExternalTwoByteString: public ExternalString {
public:
- static const bool kHasAsciiEncoding = false;
+ static const bool kHasOneByteEncoding = false;
typedef v8::String::ExternalStringResource Resource;
int length() { return length_; }
private:
String** str_;
- bool is_ascii_;
+ bool is_one_byte_;
int length_;
const void* start_;
};
// Visits a runtime entry in the instruction stream.
virtual void VisitRuntimeEntry(RelocInfo* rinfo) {}
- // Visits the resource of an ASCII or two-byte string.
- virtual void VisitExternalAsciiString(
- v8::String::ExternalAsciiStringResource** resource) {}
+ // Visits the resource of an one-byte or two-byte string.
+ virtual void VisitExternalOneByteString(
+ v8::String::ExternalOneByteStringResource** resource) {}
virtual void VisitExternalTwoByteString(
v8::String::ExternalStringResource** resource) {}
if (subject->IsOneByteRepresentation()) {
const byte* address;
if (StringShape(subject).IsExternal()) {
- const uint8_t* data = ExternalAsciiString::cast(subject)->GetChars();
+ const uint8_t* data = ExternalOneByteString::cast(subject)->GetChars();
address = reinterpret_cast<const byte*>(data);
} else {
DCHECK(subject->IsSeqOneByteString());
subject_ptr = slice->parent();
slice_offset = slice->offset();
}
- // Ensure that an underlying string has the same ASCII-ness.
- bool is_ascii = subject_ptr->IsOneByteRepresentation();
+ // Ensure that an underlying string has the same representation.
+ bool is_one_byte = subject_ptr->IsOneByteRepresentation();
DCHECK(subject_ptr->IsExternalString() || subject_ptr->IsSeqString());
// String is now either Sequential or External
- int char_size_shift = is_ascii ? 0 : 1;
+ int char_size_shift = is_one_byte ? 0 : 1;
const byte* input_start =
StringCharacterPosition(subject_ptr, start_offset + slice_offset);
class NativeRegExpMacroAssembler: public RegExpMacroAssembler {
public:
// Type of input string to generate code for.
- enum Mode { ASCII = 1, UC16 = 2 };
+ enum Mode { LATIN1 = 1, UC16 = 2 };
// Result of calling generated native RegExp code.
// RETRY: Something significant changed during execution, and the matching
class ReplacementStringBuilder {
public:
- ReplacementStringBuilder(Heap* heap,
- Handle<String> subject,
+ ReplacementStringBuilder(Heap* heap, Handle<String> subject,
int estimated_part_count)
: heap_(heap),
array_builder_(heap->isolate(), estimated_part_count),
subject_(subject),
character_count_(0),
- is_ascii_(subject->IsOneByteRepresentation()) {
+ is_one_byte_(subject->IsOneByteRepresentation()) {
// Require a non-zero initial size. Ensures that doubling the size to
// extend the array will work.
DCHECK(estimated_part_count > 0);
DCHECK(length > 0);
AddElement(*string);
if (!string->IsOneByteRepresentation()) {
- is_ascii_ = false;
+ is_one_byte_ = false;
}
IncrementCharacterCount(length);
}
}
Handle<String> joined_string;
- if (is_ascii_) {
+ if (is_one_byte_) {
Handle<SeqOneByteString> seq;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, seq,
array_builder_.length());
joined_string = Handle<String>::cast(seq);
} else {
- // Non-ASCII.
+ // Two-byte.
Handle<SeqTwoByteString> seq;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, seq,
FixedArrayBuilder array_builder_;
Handle<String> subject_;
int character_count_;
- bool is_ascii_;
+ bool is_one_byte_;
};
String::FlatContent content = replacement->GetFlatContent();
DCHECK(content.IsFlat());
bool simple = false;
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
simple = ParseReplacementPattern(&parts_,
content.ToOneByteVector(),
capture_count,
}
-void FindAsciiStringIndices(Vector<const uint8_t> subject,
- char pattern,
- ZoneList<int>* indices,
- unsigned int limit,
- Zone* zone) {
+void FindOneByteStringIndices(Vector<const uint8_t> subject, char pattern,
+ ZoneList<int>* indices, unsigned int limit,
+ Zone* zone) {
DCHECK(limit > 0);
// Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values.
String::FlatContent pattern_content = pattern->GetFlatContent();
DCHECK(subject_content.IsFlat());
DCHECK(pattern_content.IsFlat());
- if (subject_content.IsAscii()) {
+ if (subject_content.IsOneByte()) {
Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector();
- if (pattern_content.IsAscii()) {
+ if (pattern_content.IsOneByte()) {
Vector<const uint8_t> pattern_vector =
pattern_content.ToOneByteVector();
if (pattern_vector.length() == 1) {
- FindAsciiStringIndices(subject_vector,
- pattern_vector[0],
- indices,
- limit,
- zone);
+ FindOneByteStringIndices(subject_vector, pattern_vector[0], indices,
+ limit, zone);
} else {
FindStringIndices(isolate,
subject_vector,
}
} else {
Vector<const uc16> subject_vector = subject_content.ToUC16Vector();
- if (pattern_content.IsAscii()) {
+ if (pattern_content.IsOneByte()) {
Vector<const uint8_t> pattern_vector =
pattern_content.ToOneByteVector();
if (pattern_vector.length() == 1) {
int result_pos = 0;
MaybeHandle<SeqString> maybe_res;
- if (ResultSeqString::kHasAsciiEncoding) {
+ if (ResultSeqString::kHasOneByteEncoding) {
maybe_res = isolate->factory()->NewRawOneByteString(result_len);
} else {
maybe_res = isolate->factory()->NewRawTwoByteString(result_len);
if (new_length == 0) return isolate->heap()->empty_string();
Handle<ResultSeqString> answer;
- if (ResultSeqString::kHasAsciiEncoding) {
+ if (ResultSeqString::kHasOneByteEncoding) {
answer = Handle<ResultSeqString>::cast(
isolate->factory()->NewRawOneByteString(new_length).ToHandleChecked());
} else {
pat = String::Flatten(pat);
DisallowHeapAllocation no_gc; // ensure vectors stay valid
- // Extract flattened substrings of cons strings before determining asciiness.
+ // Extract flattened substrings of cons strings before getting encoding.
String::FlatContent seq_sub = sub->GetFlatContent();
String::FlatContent seq_pat = pat->GetFlatContent();
// dispatch on type of strings
- if (seq_pat.IsAscii()) {
+ if (seq_pat.IsOneByte()) {
Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector();
- if (seq_sub.IsAscii()) {
+ if (seq_sub.IsOneByte()) {
return SearchString(isolate,
seq_sub.ToOneByteVector(),
pat_vector,
start_index);
}
Vector<const uc16> pat_vector = seq_pat.ToUC16Vector();
- if (seq_sub.IsAscii()) {
+ if (seq_sub.IsOneByte()) {
return SearchString(isolate,
seq_sub.ToOneByteVector(),
pat_vector,
String::FlatContent sub_content = sub->GetFlatContent();
String::FlatContent pat_content = pat->GetFlatContent();
- if (pat_content.IsAscii()) {
+ if (pat_content.IsOneByte()) {
Vector<const uint8_t> pat_vector = pat_content.ToOneByteVector();
- if (sub_content.IsAscii()) {
+ if (sub_content.IsOneByte()) {
position = StringMatchBackwards(sub_content.ToOneByteVector(),
pat_vector,
start_index);
}
} else {
Vector<const uc16> pat_vector = pat_content.ToUC16Vector();
- if (sub_content.IsAscii()) {
+ if (sub_content.IsOneByte()) {
position = StringMatchBackwards(sub_content.ToOneByteVector(),
pat_vector,
start_index);
String::FlatContent flat = subject->GetFlatContent();
// ECMA-262 section 15.1.2.3, empty string is NaN
- if (flat.IsAscii()) {
+ if (flat.IsOneByte()) {
value = StringToInt(
isolate->unicode_cache(), flat.ToOneByteVector(), radix);
} else {
}
-// Copies ASCII characters to the given fixed array looking up
+// Copies Latin1 characters to the given fixed array looking up
// one-char strings in the cache. Gives up on the first char that is
// not in the cache and fills the remainder with smi zeros. Returns
// the length of the successfully copied prefix.
-static int CopyCachedAsciiCharsToArray(Heap* heap,
- const uint8_t* chars,
- FixedArray* elements,
- int length) {
+static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars,
+ FixedArray* elements, int length) {
DisallowHeapAllocation no_gc;
- FixedArray* ascii_cache = heap->single_character_string_cache();
+ FixedArray* one_byte_cache = heap->single_character_string_cache();
Object* undefined = heap->undefined_value();
int i;
WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc);
for (i = 0; i < length; ++i) {
- Object* value = ascii_cache->get(chars[i]);
+ Object* value = one_byte_cache->get(chars[i]);
if (value == undefined) break;
elements->set(i, value, mode);
}
DisallowHeapAllocation no_gc;
String::FlatContent content = s->GetFlatContent();
- if (content.IsAscii()) {
+ if (content.IsOneByte()) {
Vector<const uint8_t> chars = content.ToOneByteVector();
// Note, this will initialize all elements (not only the prefix)
// to prevent GC from seeing partially initialized array.
- position = CopyCachedAsciiCharsToArray(isolate->heap(),
- chars.start(),
- *elements,
- length);
+ position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(),
+ *elements, length);
} else {
MemsetPointer(elements->data_start(),
isolate->heap()->undefined_value(),
}
DCHECK(sink == end);
- // Use %_FastAsciiArrayJoin instead.
+ // Use %_FastOneByteArrayJoin instead.
DCHECK(!answer->IsOneByteRepresentation());
return *answer;
}
// Find total length of join result.
int string_length = 0;
- bool is_ascii = separator->IsOneByteRepresentation();
+ bool is_one_byte = separator->IsOneByteRepresentation();
bool overflow = false;
CONVERT_NUMBER_CHECKED(int, elements_length, Int32, elements_array->length());
RUNTIME_ASSERT(elements_length <= elements_array->elements()->length());
for (int i = 0; i < elements_length; i += 2) {
String* string = String::cast(elements->get(i + 1));
int length = string->length();
- if (is_ascii && !string->IsOneByteRepresentation()) {
- is_ascii = false;
+ if (is_one_byte && !string->IsOneByteRepresentation()) {
+ is_one_byte = false;
}
if (length > String::kMaxLength ||
String::kMaxLength - length < string_length) {
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError());
}
- if (is_ascii) {
+ if (is_one_byte) {
Handle<SeqOneByteString> result = isolate->factory()->NewRawOneByteString(
string_length).ToHandleChecked();
JoinSparseArrayWithSeparator<uint8_t>(
int r;
String::FlatContent x_content = x->GetFlatContent();
String::FlatContent y_content = y->GetFlatContent();
- if (x_content.IsAscii()) {
+ if (x_content.IsOneByte()) {
Vector<const uint8_t> x_chars = x_content.ToOneByteVector();
- if (y_content.IsAscii()) {
+ if (y_content.IsOneByte()) {
Vector<const uint8_t> y_chars = y_content.ToOneByteVector();
r = CompareChars(x_chars.start(), y_chars.start(), prefix_length);
} else {
}
} else {
Vector<const uc16> x_chars = x_content.ToUC16Vector();
- if (y_content.IsAscii()) {
+ if (y_content.IsOneByte()) {
Vector<const uint8_t> y_chars = y_content.ToOneByteVector();
r = CompareChars(x_chars.start(), y_chars.start(), prefix_length);
} else {
if (args.length() == 2 &&
unoptimized->kind() == Code::FUNCTION) {
CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
- if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr")) && FLAG_use_osr) {
+ if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("osr")) && FLAG_use_osr) {
// Start patching from the currently patched loop nesting level.
DCHECK(BackEdgeTable::Verify(isolate, unoptimized));
isolate->runtime_profiler()->AttemptOnStackReplacement(
*function, Code::kMaxLoopNestingMarker);
- } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) &&
+ } else if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) &&
isolate->concurrent_recompilation_enabled()) {
function->MarkForConcurrentOptimization();
}
bool sync_with_compiler_thread = true;
if (args.length() == 2) {
CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
- if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) {
+ if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) {
sync_with_compiler_thread = false;
}
}
bool result;
String::FlatContent str_content = str->GetFlatContent();
- if (str_content.IsAscii()) {
+ if (str_content.IsOneByte()) {
result = DateParser::Parse(str_content.ToOneByteVector(),
*output_array,
isolate->unicode_cache());
CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
source = String::Flatten(source);
- // Optimized fast case where we only have ASCII characters.
+ // Optimized fast case where we only have Latin1 characters.
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
return *factory->NewStringFromAsciiChecked(result);
}
- return *factory->NewStringFromStaticAscii("und");
+ return *factory->NewStringFromStaticChars("und");
}
// Can be bumped when callers' requirements change.
RUNTIME_ASSERT(length < 100);
Handle<FixedArray> output = factory->NewFixedArray(length);
- Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized");
- Handle<Name> base = factory->NewStringFromStaticAscii("base");
+ Handle<Name> maximized = factory->NewStringFromStaticChars("maximized");
+ Handle<Name> base = factory->NewStringFromStaticChars("base");
for (unsigned int i = 0; i < length; ++i) {
Handle<Object> locale_id;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("dateFormat");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("dateFormat");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
// Make object handle weak so we can delete the data format once GC kicks in.
local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("numberFormat");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("numberFormat");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("collator");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("collator");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticAscii("breakIterator");
- Handle<String> value = factory->NewStringFromStaticAscii("valid");
+ Handle<String> key = factory->NewStringFromStaticChars("breakIterator");
+ Handle<String> value = factory->NewStringFromStaticChars("valid");
JSObject::AddProperty(local_object, key, value, NONE);
// Make object handle weak so we can delete the break iterator once GC kicks
int32_t status = rule_based_iterator->getRuleStatus();
// Keep return values in sync with JavaScript BreakType enum.
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("none");
+ return *isolate->factory()->NewStringFromStaticChars("none");
} else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
return *isolate->factory()->number_string();
} else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("letter");
+ return *isolate->factory()->NewStringFromStaticChars("letter");
} else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("kana");
+ return *isolate->factory()->NewStringFromStaticChars("kana");
} else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
- return *isolate->factory()->NewStringFromStaticAscii("ideo");
+ return *isolate->factory()->NewStringFromStaticChars("ideo");
} else {
- return *isolate->factory()->NewStringFromStaticAscii("unknown");
+ return *isolate->factory()->NewStringFromStaticChars("unknown");
}
}
#endif // V8_I18N_SUPPORT
Handle<FixedArray> elements = factory->NewFixedArray(entry_count);
int index = 0;
bool inline_runtime_functions = false;
-#define ADD_ENTRY(Name, argc, ressize) \
- { \
- HandleScope inner(isolate); \
- Handle<String> name; \
- /* Inline runtime functions have an underscore in front of the name. */ \
- if (inline_runtime_functions) { \
- name = factory->NewStringFromStaticAscii("_" #Name); \
- } else { \
- name = factory->NewStringFromStaticAscii(#Name); \
- } \
- Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
- pair_elements->set(0, *name); \
- pair_elements->set(1, Smi::FromInt(argc)); \
- Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
- elements->set(index++, *pair); \
+#define ADD_ENTRY(Name, argc, ressize) \
+ { \
+ HandleScope inner(isolate); \
+ Handle<String> name; \
+ /* Inline runtime functions have an underscore in front of the name. */ \
+ if (inline_runtime_functions) { \
+ name = factory->NewStringFromStaticChars("_" #Name); \
+ } else { \
+ name = factory->NewStringFromStaticChars(#Name); \
+ } \
+ Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
+ pair_elements->set(0, *name); \
+ pair_elements->set(1, Smi::FromInt(argc)); \
+ Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
+ elements->set(index++, *pair); \
}
inline_runtime_functions = false;
RUNTIME_FUNCTION_LIST(ADD_ENTRY)
}
-RUNTIME_FUNCTION(RuntimeReference_FastAsciiArrayJoin) {
+RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 2);
return isolate->heap()->undefined_value();
// INLINE_FUNCTION_LIST defines all inlined functions accessed
// with a native call of the form %_name from within JS code.
// Entries have the form F(name, number of arguments, number of return values).
-#define INLINE_FUNCTION_LIST(F) \
- F(IsSmi, 1, 1) \
- F(IsNonNegativeSmi, 1, 1) \
- F(IsArray, 1, 1) \
- F(IsRegExp, 1, 1) \
- F(IsConstructCall, 0, 1) \
- F(CallFunction, -1 /* receiver + n args + function */, 1) \
- F(ArgumentsLength, 0, 1) \
- F(Arguments, 1, 1) \
- F(ValueOf, 1, 1) \
- F(SetValueOf, 2, 1) \
- F(DateField, 2 /* date object, field index */, 1) \
- F(StringCharFromCode, 1, 1) \
- F(StringCharAt, 2, 1) \
- F(OneByteSeqStringSetChar, 3, 1) \
- F(TwoByteSeqStringSetChar, 3, 1) \
- F(ObjectEquals, 2, 1) \
- F(IsObject, 1, 1) \
- F(IsFunction, 1, 1) \
- F(IsUndetectableObject, 1, 1) \
- F(IsSpecObject, 1, 1) \
- F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
- F(MathPow, 2, 1) \
- F(IsMinusZero, 1, 1) \
- F(HasCachedArrayIndex, 1, 1) \
- F(GetCachedArrayIndex, 1, 1) \
- F(FastAsciiArrayJoin, 2, 1) \
- F(GeneratorNext, 2, 1) \
- F(GeneratorThrow, 2, 1) \
- F(DebugBreakInOptimizedCode, 0, 1) \
- F(ClassOf, 1, 1) \
- F(StringCharCodeAt, 2, 1) \
- F(StringAdd, 2, 1) \
- F(SubString, 3, 1) \
- F(StringCompare, 2, 1) \
- F(RegExpExec, 4, 1) \
- F(RegExpConstructResult, 3, 1) \
- F(GetFromCache, 2, 1) \
- F(NumberToString, 1, 1) \
+#define INLINE_FUNCTION_LIST(F) \
+ F(IsSmi, 1, 1) \
+ F(IsNonNegativeSmi, 1, 1) \
+ F(IsArray, 1, 1) \
+ F(IsRegExp, 1, 1) \
+ F(IsConstructCall, 0, 1) \
+ F(CallFunction, -1 /* receiver + n args + function */, 1) \
+ F(ArgumentsLength, 0, 1) \
+ F(Arguments, 1, 1) \
+ F(ValueOf, 1, 1) \
+ F(SetValueOf, 2, 1) \
+ F(DateField, 2 /* date object, field index */, 1) \
+ F(StringCharFromCode, 1, 1) \
+ F(StringCharAt, 2, 1) \
+ F(OneByteSeqStringSetChar, 3, 1) \
+ F(TwoByteSeqStringSetChar, 3, 1) \
+ F(ObjectEquals, 2, 1) \
+ F(IsObject, 1, 1) \
+ F(IsFunction, 1, 1) \
+ F(IsUndetectableObject, 1, 1) \
+ F(IsSpecObject, 1, 1) \
+ F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
+ F(MathPow, 2, 1) \
+ F(IsMinusZero, 1, 1) \
+ F(HasCachedArrayIndex, 1, 1) \
+ F(GetCachedArrayIndex, 1, 1) \
+ F(FastOneByteArrayJoin, 2, 1) \
+ F(GeneratorNext, 2, 1) \
+ F(GeneratorThrow, 2, 1) \
+ F(DebugBreakInOptimizedCode, 0, 1) \
+ F(ClassOf, 1, 1) \
+ F(StringCharCodeAt, 2, 1) \
+ F(StringAdd, 2, 1) \
+ F(SubString, 3, 1) \
+ F(StringCompare, 2, 1) \
+ F(RegExpExec, 4, 1) \
+ F(RegExpConstructResult, 3, 1) \
+ F(GetFromCache, 2, 1) \
+ F(NumberToString, 1, 1) \
F(DebugIsActive, 0, 1)
if (!name.is_one_byte()) return;
Vector<const uint8_t> name_literal = name.one_byte_literal();
LiteralBuffer* value;
- if (name_literal == STATIC_ASCII_VECTOR("sourceURL")) {
+ if (name_literal == STATIC_CHAR_VECTOR("sourceURL")) {
value = &source_url_;
- } else if (name_literal == STATIC_ASCII_VECTOR("sourceMappingURL")) {
+ } else if (name_literal == STATIC_CHAR_VECTOR("sourceMappingURL")) {
value = &source_mapping_url_;
} else {
return;
uint32_t DuplicateFinder::Hash(Vector<const uint8_t> key, bool is_one_byte) {
// Primitive hash function, almost identical to the one used
- // for strings (except that it's seeded by the length and ASCII-ness).
+ // for strings (except that it's seeded by the length and representation).
int length = key.length();
uint32_t hash = (length << 1) | (is_one_byte ? 1 : 0) ;
for (int i = 0; i < length; i++) {
bool DuplicateFinder::Match(void* first, void* second) {
// Decode lengths.
- // Length + ASCII-bit is encoded as base 128, most significant heptet first,
- // with a 8th bit being non-zero while there are more heptets.
+ // Length + representation is encoded as base 128, most significant heptet
+ // first, with a 8th bit being non-zero while there are more heptets.
// The value encodes the number of bytes following, and whether the original
- // was ASCII.
+ // was Latin1.
byte* s1 = reinterpret_cast<byte*>(first);
byte* s2 = reinterpret_cast<byte*>(second);
uint32_t length_one_byte_field = 0;
int AddTwoByteSymbol(Vector<const uint16_t> key, int value);
// Add a a number literal by converting it (if necessary)
// to the string that ToString(ToNumber(literal)) would generate.
- // and then adding that string with AddAsciiSymbol.
+ // and then adding that string with AddOneByteSymbol.
// This string is the actual value used as key in an object literal,
// and the one that must be different from the other keys.
int AddNumber(Vector<const uint8_t> key, int value);
uint8_t* BackupKey(Vector<const uint8_t> key, bool is_one_byte);
// Compare two encoded keys (both pointing into the backing store)
- // for having the same base-127 encoded lengths and ASCII-ness,
+ // for having the same base-127 encoded lengths and representation.
// and then having the same 'length' bytes following.
static bool Match(void* first, void* second);
// Creates a hash from a sequence of bytes.
for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
Object* source = isolate_->heap()->natives_source_cache()->get(i);
if (!source->IsUndefined()) {
- ExternalAsciiString::cast(source)->update_data_cache();
+ ExternalOneByteString::cast(source)->update_data_cache();
}
}
}
-void Serializer::ObjectSerializer::VisitExternalAsciiString(
- v8::String::ExternalAsciiStringResource** resource_pointer) {
+void Serializer::ObjectSerializer::VisitExternalOneByteString(
+ v8::String::ExternalOneByteStringResource** resource_pointer) {
Address references_start = reinterpret_cast<Address>(resource_pointer);
OutputRawData(references_start);
for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
Object* source =
serializer_->isolate()->heap()->natives_source_cache()->get(i);
if (!source->IsUndefined()) {
- ExternalAsciiString* string = ExternalAsciiString::cast(source);
- typedef v8::String::ExternalAsciiStringResource Resource;
+ ExternalOneByteString* string = ExternalOneByteString::cast(source);
+ typedef v8::String::ExternalOneByteStringResource Resource;
const Resource* resource = string->resource();
if (resource == *resource_pointer) {
sink_->Put(kNativesStringResource, "NativesStringResource");
void VisitCell(RelocInfo* rinfo);
void VisitRuntimeEntry(RelocInfo* reloc);
// Used for seralizing the external strings that hold the natives source.
- void VisitExternalAsciiString(
- v8::String::ExternalAsciiStringResource** resource);
+ void VisitExternalOneByteString(
+ v8::String::ExternalOneByteStringResource** resource);
// We can't serialize a heap with external two byte strings.
void VisitExternalTwoByteString(
v8::String::ExternalStringResource** resource) {
// a potentially less efficient searching, but is a safe approximation.
// For needles using only characters in the same Unicode 256-code point page,
// there is no search speed degradation.
- static const int kAsciiAlphabetSize = 256;
+ static const int kLatin1AlphabetSize = 256;
static const int kUC16AlphabetSize = Isolate::kUC16AlphabetSize;
// Bad-char shift table stored in the state. It's length is the alphabet size.
static inline int AlphabetSize() {
if (sizeof(PatternChar) == 1) {
- // ASCII needle.
- return kAsciiAlphabetSize;
+ // Latin1 needle.
+ return kLatin1AlphabetSize;
} else {
DCHECK(sizeof(PatternChar) == 2);
// UC16 needle.
DisallowHeapAllocation no_allocation;
switch (map->instance_type()) {
case STRING_TYPE:
- case ASCII_STRING_TYPE:
+ case ONE_BYTE_STRING_TYPE:
case CONS_STRING_TYPE:
- case CONS_ASCII_STRING_TYPE:
+ case CONS_ONE_BYTE_STRING_TYPE:
case SLICED_STRING_TYPE:
- case SLICED_ASCII_STRING_TYPE:
+ case SLICED_ONE_BYTE_STRING_TYPE:
case EXTERNAL_STRING_TYPE:
- case EXTERNAL_ASCII_STRING_TYPE:
+ case EXTERNAL_ONE_BYTE_STRING_TYPE:
case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
case SHORT_EXTERNAL_STRING_TYPE:
- case SHORT_EXTERNAL_ASCII_STRING_TYPE:
+ case SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE:
case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
case INTERNALIZED_STRING_TYPE:
- case ASCII_INTERNALIZED_STRING_TYPE:
+ case ONE_BYTE_INTERNALIZED_STRING_TYPE:
case EXTERNAL_INTERNALIZED_STRING_TYPE:
- case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE:
+ case EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE:
- case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE:
+ case SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
return kString;
case SYMBOL_TYPE:
template <>
Vector<const uint8_t> GetCharVector(Handle<String> string) {
String::FlatContent flat = string->GetFlatContent();
- DCHECK(flat.IsAscii());
+ DCHECK(flat.IsOneByte());
return flat.ToOneByteVector();
}
Handle<String> source) {
int index;
{ DisallowHeapAllocation no_allocation;
- StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%"));
+ StringSearch<uint8_t, Char> search(isolate, STATIC_CHAR_VECTOR("%"));
index = search.Search(GetCharVector<Char>(source), 0);
if (index < 0) return source;
}
var index = 0;
var k = 0;
- // Optimistically assume ascii string.
+ // Optimistically assume one-byte string.
for ( ; k < uriLength; k++) {
var code = uri.charCodeAt(k);
if (code == 37) { // '%'
if (k + 2 >= uriLength) throw new $URIError("URI malformed");
var cc = URIHexCharsToCharCode(uri.charCodeAt(k+1), uri.charCodeAt(k+2));
- if (cc >> 7) break; // Assumption wrong, two byte string.
+ if (cc >> 7) break; // Assumption wrong, two-byte string.
if (reserved(cc)) {
%_OneByteSeqStringSetChar(one_byte, index++, 37); // '%'.
%_OneByteSeqStringSetChar(one_byte, index++, uri.charCodeAt(k+1));
}
k += 2;
} else {
- if (code > 0x7f) break; // Assumption wrong, two byte string.
+ if (code > 0x7f) break; // Assumption wrong, two-byte string.
%_OneByteSeqStringSetChar(one_byte, index++, code);
}
}
};
-// Compare ASCII/16bit chars to ASCII/16bit chars.
+// Compare 8bit/16bit chars to 8bit/16bit chars.
template <typename lchar, typename rchar>
inline int CompareCharsUnsigned(const lchar* lhs,
const rchar* rhs,
}
-// Simple wrapper that allows an ExternalString to refer to a
-// Vector<const char>. Doesn't assume ownership of the data.
-class AsciiStringAdapter: public v8::String::ExternalAsciiStringResource {
- public:
- explicit AsciiStringAdapter(Vector<const char> data) : data_(data) {}
-
- virtual const char* data() const { return data_.start(); }
-
- virtual size_t length() const { return data_.length(); }
-
- private:
- Vector<const char> data_;
-};
-
-
// Simple support to read a file into a 0-terminated C-string.
// The returned buffer must be freed by the caller.
// On return, *exits tells whether the file existed.
INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, int chars));
#endif
-// Copy from ASCII/16bit chars to ASCII/16bit chars.
+// Copy from 8bit/16bit chars to 8bit/16bit chars.
template <typename sourcechar, typename sinkchar>
INLINE(void CopyChars(sinkchar* dest, const sourcechar* src, int chars));
}
-#define STATIC_ASCII_VECTOR(x) \
+#define STATIC_CHAR_VECTOR(x) \
v8::internal::Vector<const uint8_t>(reinterpret_cast<const uint8_t*>(x), \
- arraysize(x)-1)
+ arraysize(x) - 1)
inline Vector<const char> CStrVector(const char* data) {
return Vector<const char>(data, StrLength(data));
// (6) One byte sequential. Load regexp code for one byte.
__ bind(&seq_one_byte_string);
// rax: RegExp data (FixedArray)
- __ movp(r11, FieldOperand(rax, JSRegExp::kDataAsciiCodeOffset));
+ __ movp(r11, FieldOperand(rax, JSRegExp::kDataOneByteCodeOffset));
__ Set(rcx, 1); // Type is one byte.
// (E) Carry on. String handling is done.
// rdi: sequential subject string (or look-alike, external string)
// r15: original subject string
- // rcx: encoding of subject string (1 if ASCII, 0 if two_byte);
+ // rcx: encoding of subject string (1 if one_byte, 0 if two_byte);
// r11: code
// Load used arguments before starting to push arguments for call to native
// RegExp code to avoid handling changing stack height.
// rdi: subject string
// rbx: previous index
- // rcx: encoding of subject string (1 if ASCII 0 if two_byte);
+ // rcx: encoding of subject string (1 if one_byte 0 if two_byte);
// r11: code
// All checks done. Now push arguments for native regexp code.
Counters* counters = isolate()->counters();
// rdi: subject string
// rbx: previous index
- // rcx: encoding of subject string (1 if ASCII 0 if two_byte);
+ // rcx: encoding of subject string (1 if one_byte 0 if two_byte);
// r11: code
// r14: slice offset
// r15: original subject string
__ bind(&check_for_strings);
- __ JumpIfNotBothSequentialAsciiStrings(
- rdx, rax, rcx, rbx, &check_unequal_objects);
+ __ JumpIfNotBothSequentialOneByteStrings(rdx, rax, rcx, rbx,
+ &check_unequal_objects);
- // Inline comparison of ASCII strings.
+ // Inline comparison of one-byte strings.
if (cc == equal) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, rdx, rax, rcx, rbx);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, rdx, rax, rcx, rbx);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi,
- r8);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, rdx, rax, rcx, rbx,
+ rdi, r8);
}
#ifdef DEBUG
// StringCharCodeAtGenerator
void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
- Label flat_string;
- Label ascii_string;
- Label got_char_code;
- Label sliced_string;
-
// If the receiver is a smi trigger the non-string case.
__ JumpIfSmi(object_, receiver_not_string_);
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ testb(rbx, Immediate(kStringEncodingMask));
__ j(zero, &two_byte_slice, Label::kNear);
- __ AllocateAsciiSlicedString(rax, rbx, r14, &runtime);
+ __ AllocateOneByteSlicedString(rax, rbx, r14, &runtime);
__ jmp(&set_slice_header, Label::kNear);
__ bind(&two_byte_slice);
__ AllocateTwoByteSlicedString(rax, rbx, r14, &runtime);
__ j(zero, &two_byte_sequential);
// Allocate the result.
- __ AllocateAsciiString(rax, rcx, r11, r14, r15, &runtime);
+ __ AllocateOneByteString(rax, rcx, r11, r14, r15, &runtime);
// rax: result string
// rcx: result string length
}
-void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left, Register right,
- Register scratch1,
- Register scratch2) {
+void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
+ Register left,
+ Register right,
+ Register scratch1,
+ Register scratch2) {
Register length = scratch1;
// Compare lengths.
// Compare characters.
__ bind(&compare_chars);
Label strings_not_equal;
- GenerateAsciiCharsCompareLoop(masm, left, right, length, scratch2,
- &strings_not_equal, Label::kNear);
+ GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2,
+ &strings_not_equal, Label::kNear);
// Characters are equal.
__ Move(rax, Smi::FromInt(EQUAL));
}
-void StringHelper::GenerateCompareFlatAsciiStrings(
+void StringHelper::GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3, Register scratch4) {
// Ensure that you can always subtract a string length from a non-negative
// Compare loop.
Label result_not_equal;
- GenerateAsciiCharsCompareLoop(masm, left, right, min_length, scratch2,
- &result_not_equal,
- // In debug-code mode, SmiTest below might push
- // the target label outside the near range.
- Label::kFar);
+ GenerateOneByteCharsCompareLoop(
+ masm, left, right, min_length, scratch2, &result_not_equal,
+ // In debug-code mode, SmiTest below might push
+ // the target label outside the near range.
+ Label::kFar);
// Completed loop without finding different characters.
// Compare lengths (precomputed).
}
-void StringHelper::GenerateAsciiCharsCompareLoop(
+void StringHelper::GenerateOneByteCharsCompareLoop(
MacroAssembler* masm, Register left, Register right, Register length,
Register scratch, Label* chars_not_equal, Label::Distance near_jump) {
// Change index to run from -length to -1 by adding length to string
__ bind(¬_same);
- // Check that both are sequential ASCII strings.
- __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime);
+ // Check that both are sequential one-byte strings.
+ __ JumpIfNotBothSequentialOneByteStrings(rdx, rax, rcx, rbx, &runtime);
- // Inline comparison of ASCII strings.
+ // Inline comparison of one-byte strings.
__ IncrementCounter(counters->string_compare_native(), 1);
// Drop arguments from the stack
__ PopReturnAddressTo(rcx);
__ addp(rsp, Immediate(2 * kPointerSize));
__ PushReturnAddressFrom(rcx);
- StringHelper::GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi,
- r8);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, rdx, rax, rcx, rbx, rdi,
+ r8);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ bind(&do_compare);
}
- // Check that both strings are sequential ASCII.
+ // Check that both strings are sequential one-byte.
Label runtime;
- __ JumpIfNotBothSequentialAsciiStrings(left, right, tmp1, tmp2, &runtime);
+ __ JumpIfNotBothSequentialOneByteStrings(left, right, tmp1, tmp2, &runtime);
- // Compare flat ASCII strings. Returns when done.
+ // Compare flat one-byte strings. Returns when done.
if (equality) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1,
+ tmp2);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
- tmp3, kScratchRegister);
+ StringHelper::GenerateCompareFlatOneByteStrings(
+ masm, left, right, tmp1, tmp2, tmp3, kScratchRegister);
}
// Handle more complex cases in runtime.
Register count,
String::Encoding encoding);
- // Compares two flat ASCII strings and returns result in rax.
- static void GenerateCompareFlatAsciiStrings(
+ // Compares two flat one-byte strings and returns result in rax.
+ static void GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3, Register scratch4);
- // Compares two flat ASCII strings for equality and returns result in rax.
- static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left,
- Register right,
- Register scratch1,
- Register scratch2);
+ // Compares two flat one-byte strings for equality and returns result in rax.
+ static void GenerateFlatOneByteStringEquals(MacroAssembler* masm,
+ Register left, Register right,
+ Register scratch1,
+ Register scratch2);
private:
- static void GenerateAsciiCharsCompareLoop(
- MacroAssembler* masm,
- Register left,
- Register right,
- Register length,
- Register scratch,
- Label* chars_not_equal,
+ static void GenerateOneByteCharsCompareLoop(
+ MacroAssembler* masm, Register left, Register right, Register length,
+ Register scratch, Label* chars_not_equal,
Label::Distance near_jump = Label::kFar);
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
__ j(zero, &seq_string, Label::kNear);
// Handle external strings.
- Label ascii_external, done;
+ Label one_byte_external, done;
if (FLAG_debug_code) {
// Assert that we do not have a cons or slice (indirect strings) here.
// Sequential strings have already been ruled out.
STATIC_ASSERT(kTwoByteStringTag == 0);
__ testb(result, Immediate(kStringEncodingMask));
__ movp(result, FieldOperand(string, ExternalString::kResourceDataOffset));
- __ j(not_equal, &ascii_external, Label::kNear);
+ __ j(not_equal, &one_byte_external, Label::kNear);
// Two-byte string.
__ movzxwl(result, Operand(result, index, times_2, 0));
__ jmp(&done, Label::kNear);
- __ bind(&ascii_external);
- // Ascii string.
+ __ bind(&one_byte_external);
+ // One-byte string.
__ movzxbl(result, Operand(result, index, times_1, 0));
__ jmp(&done, Label::kNear);
- // Dispatch on the encoding: ASCII or two-byte.
- Label ascii;
+ // Dispatch on the encoding: one-byte or two-byte.
+ Label one_byte;
__ bind(&seq_string);
STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0);
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ testb(result, Immediate(kStringEncodingMask));
- __ j(not_zero, &ascii, Label::kNear);
+ __ j(not_zero, &one_byte, Label::kNear);
// Two-byte string.
// Load the two-byte character code into the result register.
SeqTwoByteString::kHeaderSize));
__ jmp(&done, Label::kNear);
- // ASCII string.
+ // One-byte string.
// Load the byte into the result register.
- __ bind(&ascii);
+ __ bind(&one_byte);
__ movzxbl(result, FieldOperand(string,
index,
times_1,
}
-void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
+void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
Label bailout, return_result, done, one_char_separator, long_separator,
non_trivial_array, not_size_one_array, loop,
loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
array = no_reg;
- // Check that all array elements are sequential ASCII strings, and
+ // Check that all array elements are sequential one-byte strings, and
// accumulate the sum of their lengths, as a smi-encoded value.
__ Set(index, 0);
__ Set(string_length, 0);
// scratch, string_length(int32), elements(FixedArray*).
if (generate_debug_code_) {
__ cmpp(index, array_length);
- __ Assert(below, kNoEmptyArraysHereInEmitFastAsciiArrayJoin);
+ __ Assert(below, kNoEmptyArraysHereInEmitFastOneByteArrayJoin);
}
__ bind(&loop);
__ movp(string, FieldOperand(elements,
// elements: FixedArray of strings.
// index: Array length.
- // Check that the separator is a sequential ASCII string.
+ // Check that the separator is a sequential one-byte string.
__ movp(string, separator_operand);
__ JumpIfSmi(string, &bailout);
__ movp(scratch, FieldOperand(string, HeapObject::kMapOffset));
// Live registers and stack values:
// string_length: Total length of result string.
// elements: FixedArray of strings.
- __ AllocateAsciiString(result_pos, string_length, scratch,
- index, string, &bailout);
+ __ AllocateOneByteString(result_pos, string_length, scratch, index, string,
+ &bailout);
__ movp(result_operand, result_pos);
__ leap(result_pos, FieldOperand(result_pos, SeqOneByteString::kHeaderSize));
// One-character separator case
__ bind(&one_char_separator);
- // Get the separator ASCII character value.
+ // Get the separator one-byte character value.
// Register "string" holds the separator.
__ movzxbl(scratch, FieldOperand(string, SeqOneByteString::kHeaderSize));
__ Set(index, 0);
}
-void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(
- Register first_object,
- Register second_object,
- Register scratch1,
- Register scratch2,
- Label* on_fail,
- Label::Distance near_jump) {
+void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(
+ Register first_object, Register second_object, Register scratch1,
+ Register scratch2, Label* on_fail, Label::Distance near_jump) {
// Check that both objects are not smis.
Condition either_smi = CheckEitherSmi(first_object, second_object);
j(either_smi, on_fail, near_jump);
movzxbl(scratch1, FieldOperand(scratch1, Map::kInstanceTypeOffset));
movzxbl(scratch2, FieldOperand(scratch2, Map::kInstanceTypeOffset));
- // Check that both are flat ASCII strings.
+ // Check that both are flat one-byte strings.
DCHECK(kNotStringTag != 0);
- const int kFlatAsciiStringMask =
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
- andl(scratch1, Immediate(kFlatAsciiStringMask));
- andl(scratch2, Immediate(kFlatAsciiStringMask));
+ andl(scratch1, Immediate(kFlatOneByteStringMask));
+ andl(scratch2, Immediate(kFlatOneByteStringMask));
// Interleave the bits to check both scratch1 and scratch2 in one test.
- DCHECK_EQ(0, kFlatAsciiStringMask & (kFlatAsciiStringMask << 3));
+ DCHECK_EQ(0, kFlatOneByteStringMask & (kFlatOneByteStringMask << 3));
leap(scratch1, Operand(scratch1, scratch2, times_8, 0));
cmpl(scratch1,
- Immediate(kFlatAsciiStringTag + (kFlatAsciiStringTag << 3)));
+ Immediate(kFlatOneByteStringTag + (kFlatOneByteStringTag << 3)));
j(not_equal, on_fail, near_jump);
}
-void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(
- Register instance_type,
- Register scratch,
- Label* failure,
+void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(
+ Register instance_type, Register scratch, Label* failure,
Label::Distance near_jump) {
if (!scratch.is(instance_type)) {
movl(scratch, instance_type);
}
- const int kFlatAsciiStringMask =
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
- andl(scratch, Immediate(kFlatAsciiStringMask));
+ andl(scratch, Immediate(kFlatOneByteStringMask));
cmpl(scratch, Immediate(kStringTag | kSeqStringTag | kOneByteStringTag));
j(not_equal, failure, near_jump);
}
-void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialAscii(
- Register first_object_instance_type,
- Register second_object_instance_type,
- Register scratch1,
- Register scratch2,
- Label* on_fail,
+void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte(
+ Register first_object_instance_type, Register second_object_instance_type,
+ Register scratch1, Register scratch2, Label* on_fail,
Label::Distance near_jump) {
// Load instance type for both strings.
movp(scratch1, first_object_instance_type);
movp(scratch2, second_object_instance_type);
- // Check that both are flat ASCII strings.
+ // Check that both are flat one-byte strings.
DCHECK(kNotStringTag != 0);
- const int kFlatAsciiStringMask =
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
- andl(scratch1, Immediate(kFlatAsciiStringMask));
- andl(scratch2, Immediate(kFlatAsciiStringMask));
+ andl(scratch1, Immediate(kFlatOneByteStringMask));
+ andl(scratch2, Immediate(kFlatOneByteStringMask));
// Interleave the bits to check both scratch1 and scratch2 in one test.
- DCHECK_EQ(0, kFlatAsciiStringMask & (kFlatAsciiStringMask << 3));
+ DCHECK_EQ(0, kFlatOneByteStringMask & (kFlatOneByteStringMask << 3));
leap(scratch1, Operand(scratch1, scratch2, times_8, 0));
cmpl(scratch1,
- Immediate(kFlatAsciiStringTag + (kFlatAsciiStringTag << 3)));
+ Immediate(kFlatOneByteStringTag + (kFlatOneByteStringTag << 3)));
j(not_equal, on_fail, near_jump);
}
}
-void MacroAssembler::AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3,
+ Label* gc_required) {
// Calculate the number of bytes needed for the characters in the string while
// observing object alignment.
const int kHeaderAlignment = SeqOneByteString::kHeaderSize &
subp(scratch1, Immediate(kHeaderAlignment));
}
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(SeqOneByteString::kHeaderSize,
times_1,
scratch1,
TAG_OBJECT);
// Set the map, length and hash field.
- LoadRoot(kScratchRegister, Heap::kAsciiStringMapRootIndex);
+ LoadRoot(kScratchRegister, Heap::kOneByteStringMapRootIndex);
movp(FieldOperand(result, HeapObject::kMapOffset), kScratchRegister);
Integer32ToSmi(scratch1, length);
movp(FieldOperand(result, String::kLengthOffset), scratch1);
}
-void MacroAssembler::AllocateAsciiConsString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteConsString(Register result,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
Allocate(ConsString::kSize,
result,
scratch1,
TAG_OBJECT);
// Set the map. The other fields are left uninitialized.
- LoadRoot(kScratchRegister, Heap::kConsAsciiStringMapRootIndex);
+ LoadRoot(kScratchRegister, Heap::kConsOneByteStringMapRootIndex);
movp(FieldOperand(result, HeapObject::kMapOffset), kScratchRegister);
}
}
-void MacroAssembler::AllocateAsciiSlicedString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteSlicedString(Register result,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
// Allocate heap number in new space.
Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
TAG_OBJECT);
// Set the map. The other fields are left uninitialized.
- LoadRoot(kScratchRegister, Heap::kSlicedAsciiStringMapRootIndex);
+ LoadRoot(kScratchRegister, Heap::kSlicedOneByteStringMapRootIndex);
movp(FieldOperand(result, HeapObject::kMapOffset), kScratchRegister);
}
jmp(&is_data_object, Label::kNear);
bind(¬_external);
- // Sequential string, either ASCII or UC16.
+ // Sequential string, either Latin1 or UC16.
DCHECK(kOneByteStringTag == 0x04);
andp(length, Immediate(kStringEncodingMask));
xorp(length, Immediate(kStringEncodingMask));
addp(length, Immediate(0x04));
- // Value now either 4 (if ASCII) or 8 (if UC16), i.e. char-size shifted by 2.
+ // Value now either 4 (if Latin1) or 8 (if UC16), i.e. char-size shifted by 2.
imulp(length, FieldOperand(value, String::kLengthOffset));
shrp(length, Immediate(2 + kSmiTagSize + kSmiShiftSize));
addp(length, Immediate(SeqString::kHeaderSize + kObjectAlignmentMask));
Label::Distance near_jump = Label::kFar);
- void JumpIfNotBothSequentialAsciiStrings(
- Register first_object,
- Register second_object,
- Register scratch1,
- Register scratch2,
- Label* on_not_both_flat_ascii,
+ void JumpIfNotBothSequentialOneByteStrings(
+ Register first_object, Register second_object, Register scratch1,
+ Register scratch2, Label* on_not_both_flat_one_byte,
Label::Distance near_jump = Label::kFar);
- // Check whether the instance type represents a flat ASCII string. Jump to the
- // label if not. If the instance type can be scratched specify same register
- // for both instance type and scratch.
- void JumpIfInstanceTypeIsNotSequentialAscii(
- Register instance_type,
- Register scratch,
- Label*on_not_flat_ascii_string,
+ // Check whether the instance type represents a flat one-byte string. Jump
+ // to the label if not. If the instance type can be scratched specify same
+ // register for both instance type and scratch.
+ void JumpIfInstanceTypeIsNotSequentialOneByte(
+ Register instance_type, Register scratch,
+ Label* on_not_flat_one_byte_string,
Label::Distance near_jump = Label::kFar);
- void JumpIfBothInstanceTypesAreNotSequentialAscii(
- Register first_object_instance_type,
- Register second_object_instance_type,
- Register scratch1,
- Register scratch2,
- Label* on_fail,
+ void JumpIfBothInstanceTypesAreNotSequentialOneByte(
+ Register first_object_instance_type, Register second_object_instance_type,
+ Register scratch1, Register scratch2, Label* on_fail,
Label::Distance near_jump = Label::kFar);
void EmitSeqStringSetCharCheck(Register string,
Register scratch2,
Register scratch3,
Label* gc_required);
- void AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required);
+ void AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3, Label* gc_required);
// Allocate a raw cons string object. Only the map field of the result is
// initialized.
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiConsString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteConsString(Register result, Register scratch1,
+ Register scratch2, Label* gc_required);
// Allocate a raw sliced string object. Only the map field of the result is
// initialized.
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiSlicedString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteSlicedString(Register result, Register scratch1,
+ Register scratch2, Label* gc_required);
// ---------------------------------------------------------------------------
// Support functions.
/*
* This assembler uses the following register assignment convention
- * - rdx : Currently loaded character(s) as ASCII or UC16. Must be loaded
+ * - rdx : Currently loaded character(s) as Latin1 or UC16. Must be loaded
* using LoadCurrentCharacter before using any of the dispatch methods.
* Temporarily stores the index of capture start after a matching pass
* for a global regexp.
__ addl(rax, rbx);
BranchOrBacktrack(greater, on_no_match);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
Label loop_increment;
if (on_no_match == NULL) {
on_no_match = &backtrack_label_;
Label loop;
__ bind(&loop);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
__ movzxbl(rax, Operand(rdx, 0));
__ cmpb(rax, Operand(rbx, 0));
} else {
Label* on_bit_set) {
__ Move(rax, table);
Register index = current_character();
- if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) {
+ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) {
__ movp(rbx, current_character());
__ andp(rbx, Immediate(kTableMask));
index = rbx;
switch (type) {
case 's':
// Match space-characters
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
Label success;
__ cmpl(current_character(), Immediate(' '));
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c
__ subl(rax, Immediate(0x0b));
__ cmpl(rax, Immediate(0x0c - 0x0b));
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
BranchOrBacktrack(above, on_no_match);
} else {
Label done;
return true;
}
case 'w': {
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ cmpl(current_character(), Immediate('z'));
BranchOrBacktrack(above, on_no_match);
}
}
case 'W': {
Label done;
- if (mode_ != ASCII) {
- // Table is 128 entries, so all ASCII characters can be tested.
+ if (mode_ != LATIN1) {
+ // Table is 256 entries, so all Latin1 characters can be tested.
__ cmpl(current_character(), Immediate('z'));
__ j(above, &done);
}
__ testb(Operand(rbx, current_character(), times_1, 0),
current_character());
BranchOrBacktrack(not_zero, on_no_match);
- if (mode_ != ASCII) {
+ if (mode_ != LATIN1) {
__ bind(&done);
}
return true;
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
- bool is_ascii = subject->IsOneByteRepresentationUnderneath();
+ bool is_one_byte = subject->IsOneByteRepresentationUnderneath();
DCHECK(re_code->instruction_start() <= *return_address);
DCHECK(*return_address <=
}
// String might have changed.
- if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
- // If we changed between an ASCII and an UC16 string, the specialized
+ if (subject_tmp->IsOneByteRepresentation() != is_one_byte) {
+ // If we changed between an Latin1 and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).
return RETRY;
void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset,
int characters) {
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
if (characters == 4) {
__ movl(current_character(), Operand(rsi, rdi, times_1, cp_offset));
} else if (characters == 2) {
ZoneList<int> code_relative_fixup_positions_;
- // Which mode to generate code for (ASCII or UC16).
+ // Which mode to generate code for (LATIN1 or UC16).
Mode mode_;
// One greater than maximal register index actually used.
Handle<AccessorInfo> TestAccessorInfo(
Isolate* isolate, PropertyAttributes attributes) {
- Handle<String> name = isolate->factory()->NewStringFromStaticAscii("get");
+ Handle<String> name = isolate->factory()->NewStringFromStaticChars("get");
return Accessors::MakeAccessor(isolate, name, &TestGetter, &TestSetter,
attributes);
}
};
-class TestAsciiResource: public String::ExternalAsciiStringResource {
+class TestOneByteResource : public String::ExternalOneByteStringResource {
public:
- explicit TestAsciiResource(const char* data, int* counter = NULL,
- size_t offset = 0)
+ explicit TestOneByteResource(const char* data, int* counter = NULL,
+ size_t offset = 0)
: orig_data_(data),
data_(data + offset),
length_(strlen(data) - offset),
counter_(counter) {}
- ~TestAsciiResource() {
+ ~TestOneByteResource() {
i::DeleteArray(orig_data_);
if (counter_ != NULL) ++*counter_;
}
}
-THREADED_TEST(ScriptUsingAsciiStringResource) {
+THREADED_TEST(ScriptUsingOneByteStringResource) {
int dispose_count = 0;
const char* c_source = "1 + 2 * 3";
{
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source),
- &dispose_count);
+ TestOneByteResource* resource =
+ new TestOneByteResource(i::StrDup(c_source), &dispose_count);
Local<String> source = String::NewExternal(env->GetIsolate(), resource);
- CHECK(source->IsExternalAscii());
+ CHECK(source->IsExternalOneByte());
CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource),
- source->GetExternalAsciiStringResource());
+ source->GetExternalOneByteStringResource());
String::Encoding encoding = String::UNKNOWN_ENCODING;
CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource),
source->GetExternalStringResourceBase(&encoding));
- CHECK_EQ(String::ASCII_ENCODING, encoding);
+ CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
Local<Script> script = v8_compile(source);
Local<Value> value = script->Run();
CHECK(value->IsNumber());
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
CHECK_EQ(source->IsExternal(), false);
- CHECK_EQ(source->IsExternalAscii(), false);
+ CHECK_EQ(source->IsExternalOneByte(), false);
String::Encoding encoding = String::UNKNOWN_ENCODING;
CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding));
- CHECK_EQ(String::ASCII_ENCODING, encoding);
+ CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
bool success = source->MakeExternal(new TestResource(two_byte_source,
&dispose_count));
CHECK(success);
}
-THREADED_TEST(ScriptMakingExternalAsciiString) {
+THREADED_TEST(ScriptMakingExternalOneByteString) {
int dispose_count = 0;
const char* c_source = "1 + 2 * 3";
{
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
bool success = source->MakeExternal(
- new TestAsciiResource(i::StrDup(c_source), &dispose_count));
+ new TestOneByteResource(i::StrDup(c_source), &dispose_count));
CHECK(success);
Local<Script> script = v8_compile(source);
Local<Value> value = script->Run();
}
-TEST(MakingExternalAsciiStringConditions) {
+TEST(MakingExternalOneByteStringConditions) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
}
-TEST(MakingExternalUnalignedAsciiString) {
+TEST(MakingExternalUnalignedOneByteString) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
// Turn into external string with unaligned resource data.
const char* c_cons = "_abcdefghijklmnopqrstuvwxyz";
- bool success = cons->MakeExternal(
- new TestAsciiResource(i::StrDup(c_cons), NULL, 1));
+ bool success =
+ cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1));
CHECK(success);
const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
- success = slice->MakeExternal(
- new TestAsciiResource(i::StrDup(c_slice), NULL, 1));
+ success =
+ slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1));
CHECK(success);
// Trigger GCs and force evacuation.
}
-THREADED_TEST(UsingExternalAsciiString) {
+THREADED_TEST(UsingExternalOneByteString) {
i::Factory* factory = CcTest::i_isolate()->factory();
{
v8::HandleScope scope(CcTest::isolate());
const char* one_byte_string = "test string";
Local<String> string = String::NewExternal(
- CcTest::isolate(), new TestAsciiResource(i::StrDup(one_byte_string)));
+ CcTest::isolate(), new TestOneByteResource(i::StrDup(one_byte_string)));
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
// Trigger GCs so that the newly allocated string moves to old gen.
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
}
-THREADED_TEST(ScavengeExternalAsciiString) {
+THREADED_TEST(ScavengeExternalOneByteString) {
i::FLAG_stress_compaction = false;
i::FLAG_gc_global = false;
int dispose_count = 0;
const char* one_byte_string = "test string";
Local<String> string = String::NewExternal(
CcTest::isolate(),
- new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count));
+ new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count));
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
in_new_space = CcTest::heap()->InNewSpace(*istring);
}
-class TestAsciiResourceWithDisposeControl: public TestAsciiResource {
+class TestOneByteResourceWithDisposeControl : public TestOneByteResource {
public:
// Only used by non-threaded tests, so it can use static fields.
static int dispose_calls;
static int dispose_count;
- TestAsciiResourceWithDisposeControl(const char* data, bool dispose)
- : TestAsciiResource(data, &dispose_count),
- dispose_(dispose) { }
+ TestOneByteResourceWithDisposeControl(const char* data, bool dispose)
+ : TestOneByteResource(data, &dispose_count), dispose_(dispose) {}
void Dispose() {
++dispose_calls;
};
-int TestAsciiResourceWithDisposeControl::dispose_count = 0;
-int TestAsciiResourceWithDisposeControl::dispose_calls = 0;
+int TestOneByteResourceWithDisposeControl::dispose_count = 0;
+int TestOneByteResourceWithDisposeControl::dispose_calls = 0;
TEST(ExternalStringWithDisposeHandling) {
const char* c_source = "1 + 2 * 3";
// Use a stack allocated external string resource allocated object.
- TestAsciiResourceWithDisposeControl::dispose_count = 0;
- TestAsciiResourceWithDisposeControl::dispose_calls = 0;
- TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false);
+ TestOneByteResourceWithDisposeControl::dispose_count = 0;
+ TestOneByteResourceWithDisposeControl::dispose_calls = 0;
+ TestOneByteResourceWithDisposeControl res_stack(i::StrDup(c_source), false);
{
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
CcTest::heap()->CollectAllAvailableGarbage();
- CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
+ CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count);
}
CcTest::i_isolate()->compilation_cache()->Clear();
CcTest::heap()->CollectAllAvailableGarbage();
- CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
- CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
+ CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_calls);
+ CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count);
// Use a heap allocated external string resource allocated object.
- TestAsciiResourceWithDisposeControl::dispose_count = 0;
- TestAsciiResourceWithDisposeControl::dispose_calls = 0;
- TestAsciiResource* res_heap =
- new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true);
+ TestOneByteResourceWithDisposeControl::dispose_count = 0;
+ TestOneByteResourceWithDisposeControl::dispose_calls = 0;
+ TestOneByteResource* res_heap =
+ new TestOneByteResourceWithDisposeControl(i::StrDup(c_source), true);
{
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
CcTest::heap()->CollectAllAvailableGarbage();
- CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
+ CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count);
}
CcTest::i_isolate()->compilation_cache()->Clear();
CcTest::heap()->CollectAllAvailableGarbage();
- CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
- CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count);
+ CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_calls);
+ CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_count);
}
Local<String> source = String::Concat(left, right);
right = String::NewExternal(
- env->GetIsolate(), new TestAsciiResource(i::StrDup(one_byte_extern_1)));
+ env->GetIsolate(),
+ new TestOneByteResource(i::StrDup(one_byte_extern_1)));
source = String::Concat(source, right);
right = String::NewExternal(
env->GetIsolate(),
}
-class AsciiVectorResource : public v8::String::ExternalAsciiStringResource {
+class OneByteVectorResource : public v8::String::ExternalOneByteStringResource {
public:
- explicit AsciiVectorResource(i::Vector<const char> vector)
+ explicit OneByteVectorResource(i::Vector<const char> vector)
: data_(vector) {}
- virtual ~AsciiVectorResource() {}
+ virtual ~OneByteVectorResource() {}
virtual size_t length() const { return data_.length(); }
virtual const char* data() const { return data_.start(); }
private:
static void MorphAString(i::String* string,
- AsciiVectorResource* ascii_resource,
+ OneByteVectorResource* one_byte_resource,
UC16VectorResource* uc16_resource) {
CHECK(i::StringShape(string).IsExternal());
if (string->IsOneByteRepresentation()) {
// Check old map is not internalized or long.
- CHECK(string->map() == CcTest::heap()->external_ascii_string_map());
+ CHECK(string->map() == CcTest::heap()->external_one_byte_string_map());
// Morph external string to be TwoByte string.
string->set_map(CcTest::heap()->external_string_map());
i::ExternalTwoByteString* morphed =
} else {
// Check old map is not internalized or long.
CHECK(string->map() == CcTest::heap()->external_string_map());
- // Morph external string to be ASCII string.
- string->set_map(CcTest::heap()->external_ascii_string_map());
- i::ExternalAsciiString* morphed =
- i::ExternalAsciiString::cast(string);
- morphed->set_resource(ascii_resource);
+ // Morph external string to be one-byte string.
+ string->set_map(CcTest::heap()->external_one_byte_string_map());
+ i::ExternalOneByteString* morphed = i::ExternalOneByteString::cast(string);
+ morphed->set_resource(one_byte_resource);
}
}
LocalContext env;
i::Factory* factory = CcTest::i_isolate()->factory();
v8::HandleScope scope(env->GetIsolate());
- AsciiVectorResource ascii_resource(
+ OneByteVectorResource one_byte_resource(
i::Vector<const char>(c_string, i::StrLength(c_string)));
UC16VectorResource uc16_resource(
i::Vector<const uint16_t>(two_byte_string,
i::StrLength(c_string)));
- Local<String> lhs(v8::Utils::ToLocal(
- factory->NewExternalStringFromAscii(&ascii_resource)
- .ToHandleChecked()));
- Local<String> rhs(v8::Utils::ToLocal(
- factory->NewExternalStringFromAscii(&ascii_resource)
- .ToHandleChecked()));
+ Local<String> lhs(
+ v8::Utils::ToLocal(factory->NewExternalStringFromOneByte(
+ &one_byte_resource).ToHandleChecked()));
+ Local<String> rhs(
+ v8::Utils::ToLocal(factory->NewExternalStringFromOneByte(
+ &one_byte_resource).ToHandleChecked()));
env->Global()->Set(v8_str("lhs"), lhs);
env->Global()->Set(v8_str("rhs"), rhs);
CHECK(lhs->IsOneByte());
CHECK(rhs->IsOneByte());
- MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource);
- MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource);
+ MorphAString(*v8::Utils::OpenHandle(*lhs), &one_byte_resource,
+ &uc16_resource);
+ MorphAString(*v8::Utils::OpenHandle(*rhs), &one_byte_resource,
+ &uc16_resource);
// This should UTF-8 without flattening, since everything is ASCII.
Handle<String> cons = v8_compile("cons")->Run().As<String>();
// This is a very short list of sources, which currently is to check for a
// regression caused by r2703.
- const char* ascii_sources[] = {
- "0.5",
- "-0.5", // This mainly testes PushBack in the Scanner.
- "--0.5", // This mainly testes PushBack in the Scanner.
- NULL
- };
+ const char* one_byte_sources[] = {
+ "0.5",
+ "-0.5", // This mainly testes PushBack in the Scanner.
+ "--0.5", // This mainly testes PushBack in the Scanner.
+ NULL};
// Compile the sources as external two byte strings.
- for (int i = 0; ascii_sources[i] != NULL; i++) {
- uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]);
+ for (int i = 0; one_byte_sources[i] != NULL; i++) {
+ uint16_t* two_byte_string = AsciiToTwoByteString(one_byte_sources[i]);
TestResource* uc16_resource = new TestResource(two_byte_string);
v8::Local<v8::String> source =
v8::String::NewExternal(context->GetIsolate(), uc16_resource);
RegExpInterruptionThread timeout_thread(CcTest::isolate());
v8::V8::AddGCPrologueCallback(RunBeforeGC);
- static const char* ascii_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- i::uc16* uc16_content = AsciiToTwoByteString(ascii_content);
- v8::Local<v8::String> string = v8_str(ascii_content);
+ static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content);
+ v8::Local<v8::String> string = v8_str(one_byte_content);
CcTest::global()->Set(v8_str("a"), string);
regexp_interruption_data.string.Reset(CcTest::isolate(), string);
regexp_interruption_data.string_resource = new UC16VectorResource(
- i::Vector<const i::uc16>(uc16_content, i::StrLength(ascii_content)));
+ i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content)));
v8::TryCatch try_catch;
timeout_thread.Start();
virtual ~VisitorImpl() {}
virtual void VisitExternalString(v8::Handle<v8::String> string) {
if (!string->IsExternal()) {
- CHECK(string->IsExternalAscii());
+ CHECK(string->IsExternalOneByte());
return;
}
v8::String::ExternalStringResource* resource =
CHECK(CcTest::heap()->old_pointer_space()->Contains(
*v8::Utils::OpenHandle(*cons)));
- TestAsciiResource* resource =
- new TestAsciiResource(i::StrDup("Romeo Montague Juliet Capulet"));
+ TestOneByteResource* resource =
+ new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet"));
cons->MakeExternal(resource);
- CHECK(cons->IsExternalAscii());
- CHECK_EQ(resource, cons->GetExternalAsciiStringResource());
+ CHECK(cons->IsExternalOneByte());
+ CHECK_EQ(resource, cons->GetExternalOneByteStringResource());
String::Encoding encoding;
CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding));
CHECK_EQ(String::ONE_BYTE_ENCODING, encoding);
{ v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
const char* s = "One string to test them all, one string to find them.";
- TestAsciiResource* inscription =
- new TestAsciiResource(i::StrDup(s), &destroyed);
+ TestOneByteResource* inscription =
+ new TestOneByteResource(i::StrDup(s), &destroyed);
v8::Local<v8::String> ring = v8::String::NewExternal(isolate, inscription);
// Ring is still alive. Orcs are roaming freely across our lands.
CHECK_EQ(0, destroyed);
v8::HandleScope handle_scope(isolate);
CompileRun("var ring = 'One string to test them all';");
const char* s = "One string to test them all";
- TestAsciiResource* inscription =
- new TestAsciiResource(i::StrDup(s), &destroyed);
+ TestOneByteResource* inscription =
+ new TestOneByteResource(i::StrDup(s), &destroyed);
v8::Local<v8::String> ring = CompileRun("ring")->ToString();
CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString());
ring->MakeExternal(inscription);
v8::HandleScope handle_scope(env->GetIsolate());
CompileRun("var ring = 'One string to test them all';");
const char* s = "One string to test them all";
- TestAsciiResource* inscription =
- new TestAsciiResource(i::StrDup(s), &destroyed);
+ TestOneByteResource* inscription =
+ new TestOneByteResource(i::StrDup(s), &destroyed);
v8::Local<v8::String> ring = CompileRun("ring")->ToString();
CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString());
ring->MakeExternal(inscription);
}
-THREADED_TEST(TwoByteStringInAsciiCons) {
+THREADED_TEST(TwoByteStringInOneByteCons) {
// See Chromium issue 47824.
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
// If the cons string has been short-circuited, skip the following checks.
if (!string.is_identical_to(flat_string)) {
- // At this point, we should have a Cons string which is flat and ASCII,
+ // At this point, we should have a Cons string which is flat and one-byte,
// with a first half that is a two-byte string (although it only contains
- // ASCII characters). This is a valid sequence of steps, and it can happen
- // in real pages.
+ // one-byte characters). This is a valid sequence of steps, and it can
+ // happen in real pages.
CHECK(string->IsOneByteRepresentation());
i::ConsString* cons = i::ConsString::cast(*string);
CHECK_EQ(0, cons->second()->length());
Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun0, global, 0, NULL).Check();
- Handle<String> foo_string = isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("foo"));
+ Handle<String> foo_string =
+ isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("foo"));
Handle<Object> fun1 = Object::GetProperty(
isolate->global_object(), foo_string).ToHandleChecked();
CHECK(fun1->IsJSFunction());
- Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString(
- STATIC_ASCII_VECTOR("hello")) };
+ Handle<Object> argv[] = {isolate->factory()->InternalizeOneByteString(
+ STATIC_CHAR_VECTOR("hello"))};
Execution::Call(isolate,
Handle<JSFunction>::cast(fun1),
global,
Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast(
v8::Utils::OpenHandle(*context_->Global())));
Handle<v8::internal::String> debug_string =
- factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
+ factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("debug"));
v8::internal::Runtime::DefineObjectProperty(global, debug_string,
handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check();
}
CHECK_EQ(1, global->InternalFieldCount());
i::Factory* factory = CcTest::i_isolate()->factory();
- i::Handle<i::String> first = factory->NewStringFromStaticAscii("0123456789");
- i::Handle<i::String> second = factory->NewStringFromStaticAscii("0123456789");
+ i::Handle<i::String> first = factory->NewStringFromStaticChars("0123456789");
+ i::Handle<i::String> second = factory->NewStringFromStaticChars("0123456789");
i::Handle<i::String> cons_string =
factory->NewConsString(first, second).ToHandleChecked();
int abort_countdown_;
};
-class AsciiResource: public v8::String::ExternalAsciiStringResource {
+class OneByteResource : public v8::String::ExternalOneByteStringResource {
public:
- explicit AsciiResource(i::Vector<char> string): data_(string.start()) {
+ explicit OneByteResource(i::Vector<char> string) : data_(string.start()) {
length_ = string.length();
}
virtual const char* data() const { return data_; }
stream.WriteTo(json);
// Verify that snapshot string is valid JSON.
- AsciiResource* json_res = new AsciiResource(json);
+ OneByteResource* json_res = new OneByteResource(json);
v8::Local<v8::String> json_string =
v8::String::NewExternal(env->GetIsolate(), json_res);
env->Global()->Set(v8_str("json_snapshot"), json_string);
v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
i::Factory* factory = CcTest::i_isolate()->factory();
- i::Handle<i::String> string = factory->NewStringFromStaticAscii("string");
+ i::Handle<i::String> string = factory->NewStringFromStaticChars("string");
i::Handle<i::Object> box = factory->NewBox(string);
global->Set(0, v8::ToApiHandle<v8::Object>(box));
CHECK(factory->nan_value()->IsNumber());
CHECK(std::isnan(factory->nan_value()->Number()));
- Handle<String> s = factory->NewStringFromStaticAscii("fisk hest ");
+ Handle<String> s = factory->NewStringFromStaticChars("fisk hest ");
CHECK(s->IsString());
CHECK_EQ(10, s->length());
{
HandleScope scope(isolate);
- Handle<Object> i = factory->NewStringFromStaticAscii("fisk");
+ Handle<Object> i = factory->NewStringFromStaticChars("fisk");
Handle<Object> u = factory->NewNumber(1.12344);
h1 = global_handles->Create(*i);
{
HandleScope scope(isolate);
- Handle<Object> i = factory->NewStringFromStaticAscii("fisk");
+ Handle<Object> i = factory->NewStringFromStaticChars("fisk");
Handle<Object> u = factory->NewNumber(1.12344);
h1 = global_handles->Create(*i);
{
HandleScope scope(isolate);
- Handle<Object> i = factory->NewStringFromStaticAscii("fisk");
+ Handle<Object> i = factory->NewStringFromStaticChars("fisk");
Handle<Object> u = factory->NewNumber(1.12344);
h1 = global_handles->Create(*i);
{
HandleScope scope(isolate);
- Handle<Object> i = factory->NewStringFromStaticAscii("fisk");
+ Handle<Object> i = factory->NewStringFromStaticChars("fisk");
h = global_handles->Create(*i);
}
const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
for (int length = 0; length < 100; length++) {
v8::HandleScope scope(CcTest::isolate());
- char* non_ascii = NewArray<char>(3 * length + 1);
- char* ascii = NewArray<char>(length + 1);
- non_ascii[3 * length] = 0;
- ascii[length] = 0;
+ char* non_one_byte = NewArray<char>(3 * length + 1);
+ char* one_byte = NewArray<char>(length + 1);
+ non_one_byte[3 * length] = 0;
+ one_byte[length] = 0;
for (int i = 0; i < length; i++) {
- ascii[i] = 'a';
- non_ascii[3 * i] = chars[0];
- non_ascii[3 * i + 1] = chars[1];
- non_ascii[3 * i + 2] = chars[2];
+ one_byte[i] = 'a';
+ non_one_byte[3 * i] = chars[0];
+ non_one_byte[3 * i + 1] = chars[1];
+ non_one_byte[3 * i + 2] = chars[2];
}
- Handle<String> non_ascii_sym =
- factory->InternalizeUtf8String(
- Vector<const char>(non_ascii, 3 * length));
- CHECK_EQ(length, non_ascii_sym->length());
- Handle<String> ascii_sym =
- factory->InternalizeOneByteString(OneByteVector(ascii, length));
- CHECK_EQ(length, ascii_sym->length());
- Handle<String> non_ascii_str = factory->NewStringFromUtf8(
- Vector<const char>(non_ascii, 3 * length)).ToHandleChecked();
- non_ascii_str->Hash();
- CHECK_EQ(length, non_ascii_str->length());
- Handle<String> ascii_str = factory->NewStringFromUtf8(
- Vector<const char>(ascii, length)).ToHandleChecked();
- ascii_str->Hash();
- CHECK_EQ(length, ascii_str->length());
- DeleteArray(non_ascii);
- DeleteArray(ascii);
+ Handle<String> non_one_byte_sym = factory->InternalizeUtf8String(
+ Vector<const char>(non_one_byte, 3 * length));
+ CHECK_EQ(length, non_one_byte_sym->length());
+ Handle<String> one_byte_sym =
+ factory->InternalizeOneByteString(OneByteVector(one_byte, length));
+ CHECK_EQ(length, one_byte_sym->length());
+ Handle<String> non_one_byte_str =
+ factory->NewStringFromUtf8(Vector<const char>(non_one_byte, 3 * length))
+ .ToHandleChecked();
+ non_one_byte_str->Hash();
+ CHECK_EQ(length, non_one_byte_str->length());
+ Handle<String> one_byte_str =
+ factory->NewStringFromUtf8(Vector<const char>(one_byte, length))
+ .ToHandleChecked();
+ one_byte_str->Hash();
+ CHECK_EQ(length, one_byte_str->length());
+ DeleteArray(non_one_byte);
+ DeleteArray(one_byte);
}
}
TENURED);
// Allocate a small string to OLD_DATA_SPACE and NEW_SPACE
+ objs[next_objs_index++] = factory->NewStringFromStaticChars("abcdefghij");
objs[next_objs_index++] =
- factory->NewStringFromStaticAscii("abcdefghij");
- objs[next_objs_index++] =
- factory->NewStringFromStaticAscii("abcdefghij", TENURED);
+ factory->NewStringFromStaticChars("abcdefghij", TENURED);
// Allocate a large string (for large object space).
int large_size = Page::kMaxRegularHeapObjectSize + 1;
}
-class SourceResource: public v8::String::ExternalAsciiStringResource {
+class SourceResource : public v8::String::ExternalOneByteStringResource {
public:
explicit SourceResource(const char* data)
: data_(data), length_(strlen(data)) { }
Handle<Map> map1 = Map::Create(isolate->object_function(), 1);
Handle<Map> map2 =
- Map::CopyWithField(map1, factory->NewStringFromStaticAscii("foo"),
+ Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"),
HeapType::Any(isolate), NONE, Representation::Tagged(),
OMIT_TRANSITION).ToHandleChecked();
}
-class ScriptResource : public v8::String::ExternalAsciiStringResource {
+class ScriptResource : public v8::String::ExternalOneByteStringResource {
public:
ScriptResource(const char* data, size_t length)
: data_(data), length_(length) { }
#define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2))
-void TestCharacterStream(const char* ascii_source,
- unsigned length,
- unsigned start = 0,
- unsigned end = 0) {
+void TestCharacterStream(const char* one_byte_source, unsigned length,
+ unsigned start = 0, unsigned end = 0) {
if (end == 0) end = length;
unsigned sub_length = end - start;
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope test_scope(isolate);
i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]);
for (unsigned i = 0; i < length; i++) {
- uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]);
+ uc16_buffer[i] = static_cast<i::uc16>(one_byte_source[i]);
}
- i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length));
- i::Handle<i::String> ascii_string =
- factory->NewStringFromAscii(ascii_vector).ToHandleChecked();
+ i::Vector<const char> one_byte_vector(one_byte_source,
+ static_cast<int>(length));
+ i::Handle<i::String> one_byte_string =
+ factory->NewStringFromAscii(one_byte_vector).ToHandleChecked();
TestExternalResource resource(uc16_buffer.get(), length);
i::Handle<i::String> uc16_string(
factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked());
i::ExternalTwoByteStringUtf16CharacterStream uc16_stream(
i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end);
- i::GenericStringUtf16CharacterStream string_stream(ascii_string, start, end);
+ i::GenericStringUtf16CharacterStream string_stream(one_byte_string, start,
+ end);
i::Utf8ToUtf16CharacterStream utf8_stream(
- reinterpret_cast<const i::byte*>(ascii_source), end);
+ reinterpret_cast<const i::byte*>(one_byte_source), end);
utf8_stream.SeekForward(start);
unsigned i = start;
CHECK_EQU(i, uc16_stream.pos());
CHECK_EQU(i, string_stream.pos());
CHECK_EQU(i, utf8_stream.pos());
- int32_t c0 = ascii_source[i];
+ int32_t c0 = one_byte_source[i];
int32_t c1 = uc16_stream.Advance();
int32_t c2 = string_stream.Advance();
int32_t c3 = utf8_stream.Advance();
}
while (i > start + sub_length / 4) {
// Pushback, re-read, pushback again.
- int32_t c0 = ascii_source[i - 1];
+ int32_t c0 = one_byte_source[i - 1];
CHECK_EQU(i, uc16_stream.pos());
CHECK_EQU(i, string_stream.pos());
CHECK_EQU(i, utf8_stream.pos());
CHECK_EQU(i, uc16_stream.pos());
CHECK_EQU(i, string_stream.pos());
CHECK_EQU(i, utf8_stream.pos());
- int32_t c0 = ascii_source[i];
+ int32_t c0 = one_byte_source[i];
int32_t c1 = uc16_stream.Advance();
int32_t c2 = string_stream.Advance();
int32_t c3 = utf8_stream.Advance();
scanner.CurrentSymbol(&ast_value_factory)->string();
i::DisallowHeapAllocation no_alloc;
i::String::FlatContent content = val->GetFlatContent();
- CHECK(content.IsAscii());
+ CHECK(content.IsOneByte());
i::Vector<const uint8_t> actual = content.ToOneByteVector();
for (int i = 0; i < actual.length(); i++) {
CHECK_NE('\0', expected[i]);
"var obj1 = { oXj2 : { foo1: function() {} } }; "
"%FunctionGetInferredName(obj1.oXj2.foo1)");
uint16_t* two_byte_name = AsciiToTwoByteString("obj1.oXj2.foo1");
- // Make it really non-ASCII (replace the Xs with a non-ASCII character).
+ // Make it really non-Latin1 (replace the Xs with a non-Latin1 character).
two_byte_source[14] = two_byte_source[78] = two_byte_name[6] = 0x010d;
v8::Local<v8::String> source =
v8::String::NewFromTwoByte(isolate, two_byte_source);
}
-static RegExpNode* Compile(const char* input,
- bool multiline,
- bool is_ascii,
+static RegExpNode* Compile(const char* input, bool multiline, bool is_one_byte,
Zone* zone) {
V8::Initialize(NULL);
Isolate* isolate = CcTest::i_isolate();
NewStringFromUtf8(CStrVector(input)).ToHandleChecked();
Handle<String> sample_subject =
isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked();
- RegExpEngine::Compile(&compile_data,
- false,
- false,
- multiline,
- pattern,
- sample_subject,
- is_ascii,
- zone);
+ RegExpEngine::Compile(&compile_data, false, false, multiline, pattern,
+ sample_subject, is_one_byte, zone);
return compile_data.node;
}
-static void Execute(const char* input,
- bool multiline,
- bool is_ascii,
+static void Execute(const char* input, bool multiline, bool is_one_byte,
bool dot_output = false) {
v8::HandleScope scope(CcTest::isolate());
Zone zone(CcTest::i_isolate());
- RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
+ RegExpNode* node = Compile(input, multiline, is_one_byte, &zone);
USE(node);
#ifdef DEBUG
if (dot_output) {
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone);
m.Succeed();
- Handle<String> source = factory->NewStringFromStaticAscii("");
+ Handle<String> source = factory->NewStringFromStaticChars("");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
int captures[4] = {42, 37, 87, 117};
- Handle<String> input = factory->NewStringFromStaticAscii("foofoo");
+ Handle<String> input = factory->NewStringFromStaticChars("foofoo");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
const byte* start_adr =
reinterpret_cast<const byte*>(seq_input->GetCharsAddress());
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone);
Label fail, backtrack;
m.PushBacktrack(&fail);
m.Bind(&fail);
m.Fail();
- Handle<String> source = factory->NewStringFromStaticAscii("^foo");
+ Handle<String> source = factory->NewStringFromStaticChars("^foo");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
int captures[4] = {42, 37, 87, 117};
- Handle<String> input = factory->NewStringFromStaticAscii("foofoo");
+ Handle<String> input = factory->NewStringFromStaticChars("foofoo");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
CHECK_EQ(-1, captures[2]);
CHECK_EQ(-1, captures[3]);
- input = factory->NewStringFromStaticAscii("barbarbar");
+ input = factory->NewStringFromStaticChars("barbarbar");
seq_input = Handle<SeqOneByteString>::cast(input);
start_adr = seq_input->GetCharsAddress();
m.Bind(&fail);
m.Fail();
- Handle<String> source = factory->NewStringFromStaticAscii("^foo");
+ Handle<String> source = factory->NewStringFromStaticChars("^foo");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone);
Label fail;
Label backtrack;
m.Bind(&backtrack);
m.Fail();
- Handle<String> source = factory->NewStringFromStaticAscii("..........");
+ Handle<String> source = factory->NewStringFromStaticChars("..........");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
- Handle<String> input = factory->NewStringFromStaticAscii("foofoo");
+ Handle<String> input = factory->NewStringFromStaticChars("foofoo");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
}
-TEST(MacroAssemblerNativeBackReferenceASCII) {
+TEST(MacroAssemblerNativeBackReferenceLATIN1) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone);
m.WriteCurrentPositionToRegister(0, 0);
m.AdvanceCurrentPosition(2);
m.Bind(&missing_match);
m.Fail();
- Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1");
+ Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
- Handle<String> input = factory->NewStringFromStaticAscii("fooofo");
+ Handle<String> input = factory->NewStringFromStaticChars("fooofo");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
m.Bind(&missing_match);
m.Fail();
- Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1");
+ Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone);
Label not_at_start, newline, fail;
m.CheckNotAtStart(¬_at_start);
m.CheckNotCharacter('b', &fail);
m.Succeed();
- Handle<String> source = factory->NewStringFromStaticAscii("(^f|ob)");
+ Handle<String> source = factory->NewStringFromStaticChars("(^f|ob)");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
- Handle<String> input = factory->NewStringFromStaticAscii("foobar");
+ Handle<String> input = factory->NewStringFromStaticChars("foobar");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone);
Label fail, succ;
m.Succeed();
Handle<String> source =
- factory->NewStringFromStaticAscii("^(abc)\1\1(?!\1)...(?!\1)");
+ factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
- Handle<String> input =
- factory->NewStringFromStaticAscii("aBcAbCABCxYzab");
+ Handle<String> input = factory->NewStringFromStaticChars("aBcAbCABCxYzab");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 6, &zone);
uc16 foo_chars[3] = {'f', 'o', 'o'};
Vector<const uc16> foo(foo_chars, 3);
m.Bind(&fail);
m.Fail();
- Handle<String> source =
- factory->NewStringFromStaticAscii("<loop test>");
+ Handle<String> source = factory->NewStringFromStaticChars("<loop test>");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
// String long enough for test (content doesn't matter).
- Handle<String> input =
- factory->NewStringFromStaticAscii("foofoofoofoofoo");
+ Handle<String> input = factory->NewStringFromStaticChars("foofoofoofoofoo");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone);
Label loop;
m.Bind(&loop);
m.GoTo(&loop);
Handle<String> source =
- factory->NewStringFromStaticAscii("<stack overflow test>");
+ factory->NewStringFromStaticChars("<stack overflow test>");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
// String long enough for test (content doesn't matter).
- Handle<String> input =
- factory->NewStringFromStaticAscii("dummy");
+ Handle<String> input = factory->NewStringFromStaticChars("dummy");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
Factory* factory = isolate->factory();
Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone);
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 2, &zone);
// At least 2048, to ensure the allocated space for registers
// span one full page.
m.Succeed();
Handle<String> source =
- factory->NewStringFromStaticAscii("<huge register space test>");
+ factory->NewStringFromStaticChars("<huge register space test>");
Handle<Object> code_object = m.GetCode(source);
Handle<Code> code = Handle<Code>::cast(code_object);
// String long enough for test (content doesn't matter).
- Handle<String> input =
- factory->NewStringFromStaticAscii("sample text");
+ Handle<String> input = factory->NewStringFromStaticChars("sample text");
Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input);
Address start_adr = seq_input->GetCharsAddress();
Factory* factory = isolate->factory();
HandleScope scope(isolate);
- Handle<String> source = factory->NewStringFromStaticAscii("^f(o)o");
+ Handle<String> source = factory->NewStringFromStaticChars("^f(o)o");
Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source));
int captures[5];
CHECK(isolate->global_object()->IsJSObject());
CHECK(isolate->native_context()->IsContext());
CHECK(CcTest::heap()->string_table()->IsStringTable());
- isolate->factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
+ isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
}
};
-class AsciiResource: public v8::String::ExternalAsciiStringResource {
+class OneByteResource : public v8::String::ExternalOneByteStringResource {
public:
- AsciiResource(const char* data, size_t length)
+ OneByteResource(const char* data, size_t length)
: data_(data), length_(length) {}
- ~AsciiResource() { i::DeleteArray(data_); }
+ ~OneByteResource() { i::DeleteArray(data_); }
virtual const char* data() const { return data_; }
virtual size_t length() const { return length_; }
for (int j = 0; j < len; j++) {
buf[j] = rng->next(0x80);
}
- AsciiResource* resource = new AsciiResource(buf, len);
+ OneByteResource* resource = new OneByteResource(buf, len);
building_blocks[i] =
v8::Utils::OpenHandle(
*v8::String::NewExternal(CcTest::isolate(), resource));
ConsStringGenerationData* data,
int depth) {
Factory* factory = CcTest::i_isolate()->factory();
- Handle<String> answer = factory->NewStringFromStaticAscii("");
+ Handle<String> answer = factory->NewStringFromStaticChars("");
data->stats_.leaves_++;
for (int i = 0; i < depth; i++) {
Handle<String> block = data->block(i);
ConsStringGenerationData* data,
int depth) {
Factory* factory = CcTest::i_isolate()->factory();
- Handle<String> answer = factory->NewStringFromStaticAscii("");
+ Handle<String> answer = factory->NewStringFromStaticChars("");
data->stats_.leaves_++;
for (int i = depth - 1; i >= 0; i--) {
Handle<String> block = data->block(i);
}
-static const int DEEP_ASCII_DEPTH = 100000;
+static const int kDeepOneByteDepth = 100000;
-TEST(DeepAscii) {
- printf("TestDeepAscii\n");
+TEST(DeepOneByte) {
CcTest::InitializeVM();
Factory* factory = CcTest::i_isolate()->factory();
v8::HandleScope scope(CcTest::isolate());
- char* foo = NewArray<char>(DEEP_ASCII_DEPTH);
- for (int i = 0; i < DEEP_ASCII_DEPTH; i++) {
+ char* foo = NewArray<char>(kDeepOneByteDepth);
+ for (int i = 0; i < kDeepOneByteDepth; i++) {
foo[i] = "foo "[i % 4];
}
- Handle<String> string = factory->NewStringFromOneByte(
- OneByteVector(foo, DEEP_ASCII_DEPTH)).ToHandleChecked();
- Handle<String> foo_string = factory->NewStringFromStaticAscii("foo");
- for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) {
+ Handle<String> string =
+ factory->NewStringFromOneByte(OneByteVector(foo, kDeepOneByteDepth))
+ .ToHandleChecked();
+ Handle<String> foo_string = factory->NewStringFromStaticChars("foo");
+ for (int i = 0; i < kDeepOneByteDepth; i += 10) {
string = factory->NewConsString(string, foo_string).ToHandleChecked();
}
Handle<String> flat_string =
String::Flatten(flat_string);
for (int i = 0; i < 500; i++) {
- TraverseFirst(flat_string, string, DEEP_ASCII_DEPTH);
+ TraverseFirst(flat_string, string, kDeepOneByteDepth);
}
DeleteArray<char>(foo);
}
// Smoke test for converting strings to utf-8.
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate());
- // A simple ascii string
- const char* ascii_string = "abcdef12345";
- int len = v8::String::NewFromUtf8(CcTest::isolate(), ascii_string,
+ // A simple one-byte string
+ const char* one_byte_string = "abcdef12345";
+ int len = v8::String::NewFromUtf8(CcTest::isolate(), one_byte_string,
v8::String::kNormalString,
- StrLength(ascii_string))->Utf8Length();
- CHECK_EQ(StrLength(ascii_string), len);
- // A mixed ascii and non-ascii string
+ StrLength(one_byte_string))->Utf8Length();
+ CHECK_EQ(StrLength(one_byte_string), len);
+ // A mixed one-byte and two-byte string
// U+02E4 -> CB A4
// U+0064 -> 64
// U+12E4 -> E1 8B A4
CHECK_GT(kMaxLength, i::ConsString::kMinLength);
// Allocate two JavaScript arrays for holding short strings.
- v8::Handle<v8::Array> ascii_external_strings =
+ v8::Handle<v8::Array> one_byte_external_strings =
v8::Array::New(CcTest::isolate(), kMaxLength + 1);
- v8::Handle<v8::Array> non_ascii_external_strings =
+ v8::Handle<v8::Array> non_one_byte_external_strings =
v8::Array::New(CcTest::isolate(), kMaxLength + 1);
- // Generate short ascii and non-ascii external strings.
+ // Generate short one-byte and two-byte external strings.
for (int i = 0; i <= kMaxLength; i++) {
- char* ascii = NewArray<char>(i + 1);
+ char* one_byte = NewArray<char>(i + 1);
for (int j = 0; j < i; j++) {
- ascii[j] = 'a';
+ one_byte[j] = 'a';
}
// Terminating '\0' is left out on purpose. It is not required for external
// string data.
- AsciiResource* ascii_resource = new AsciiResource(ascii, i);
- v8::Local<v8::String> ascii_external_string =
- v8::String::NewExternal(CcTest::isolate(), ascii_resource);
+ OneByteResource* one_byte_resource = new OneByteResource(one_byte, i);
+ v8::Local<v8::String> one_byte_external_string =
+ v8::String::NewExternal(CcTest::isolate(), one_byte_resource);
- ascii_external_strings->Set(v8::Integer::New(CcTest::isolate(), i),
- ascii_external_string);
- uc16* non_ascii = NewArray<uc16>(i + 1);
+ one_byte_external_strings->Set(v8::Integer::New(CcTest::isolate(), i),
+ one_byte_external_string);
+ uc16* non_one_byte = NewArray<uc16>(i + 1);
for (int j = 0; j < i; j++) {
- non_ascii[j] = 0x1234;
+ non_one_byte[j] = 0x1234;
}
// Terminating '\0' is left out on purpose. It is not required for external
// string data.
- Resource* resource = new Resource(non_ascii, i);
- v8::Local<v8::String> non_ascii_external_string =
- v8::String::NewExternal(CcTest::isolate(), resource);
- non_ascii_external_strings->Set(v8::Integer::New(CcTest::isolate(), i),
- non_ascii_external_string);
+ Resource* resource = new Resource(non_one_byte, i);
+ v8::Local<v8::String> non_one_byte_external_string =
+ v8::String::NewExternal(CcTest::isolate(), resource);
+ non_one_byte_external_strings->Set(v8::Integer::New(CcTest::isolate(), i),
+ non_one_byte_external_string);
}
// Add the arrays with the short external strings in the global object.
v8::Handle<v8::Object> global = context->Global();
- global->Set(v8_str("external_ascii"), ascii_external_strings);
- global->Set(v8_str("external_non_ascii"), non_ascii_external_strings);
+ global->Set(v8_str("external_one_byte"), one_byte_external_strings);
+ global->Set(v8_str("external_non_one_byte"), non_one_byte_external_strings);
global->Set(v8_str("max_length"),
v8::Integer::New(CcTest::isolate(), kMaxLength));
- // Add short external ascii and non-ascii strings checking the result.
+ // Add short external one-byte and two-byte strings checking the result.
static const char* source =
- "function test() {"
- " var ascii_chars = 'aaaaaaaaaaaaaaaaaaaa';"
- " var non_ascii_chars = '\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234';" //NOLINT
- " if (ascii_chars.length != max_length) return 1;"
- " if (non_ascii_chars.length != max_length) return 2;"
- " var ascii = Array(max_length + 1);"
- " var non_ascii = Array(max_length + 1);"
- " for (var i = 0; i <= max_length; i++) {"
- " ascii[i] = ascii_chars.substring(0, i);"
- " non_ascii[i] = non_ascii_chars.substring(0, i);"
- " };"
- " for (var i = 0; i <= max_length; i++) {"
- " if (ascii[i] != external_ascii[i]) return 3;"
- " if (non_ascii[i] != external_non_ascii[i]) return 4;"
- " for (var j = 0; j < i; j++) {"
- " if (external_ascii[i] !="
- " (external_ascii[j] + external_ascii[i - j])) return 5;"
- " if (external_non_ascii[i] !="
- " (external_non_ascii[j] + external_non_ascii[i - j])) return 6;"
- " if (non_ascii[i] != (non_ascii[j] + non_ascii[i - j])) return 7;"
- " if (ascii[i] != (ascii[j] + ascii[i - j])) return 8;"
- " if (ascii[i] != (external_ascii[j] + ascii[i - j])) return 9;"
- " if (ascii[i] != (ascii[j] + external_ascii[i - j])) return 10;"
- " if (non_ascii[i] !="
- " (external_non_ascii[j] + non_ascii[i - j])) return 11;"
- " if (non_ascii[i] !="
- " (non_ascii[j] + external_non_ascii[i - j])) return 12;"
- " }"
- " }"
- " return 0;"
- "};"
- "test()";
+ "function test() {"
+ " var one_byte_chars = 'aaaaaaaaaaaaaaaaaaaa';"
+ " var non_one_byte_chars = "
+ "'\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1"
+ "234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\"
+ "u1234';" // NOLINT
+ " if (one_byte_chars.length != max_length) return 1;"
+ " if (non_one_byte_chars.length != max_length) return 2;"
+ " var one_byte = Array(max_length + 1);"
+ " var non_one_byte = Array(max_length + 1);"
+ " for (var i = 0; i <= max_length; i++) {"
+ " one_byte[i] = one_byte_chars.substring(0, i);"
+ " non_one_byte[i] = non_one_byte_chars.substring(0, i);"
+ " };"
+ " for (var i = 0; i <= max_length; i++) {"
+ " if (one_byte[i] != external_one_byte[i]) return 3;"
+ " if (non_one_byte[i] != external_non_one_byte[i]) return 4;"
+ " for (var j = 0; j < i; j++) {"
+ " if (external_one_byte[i] !="
+ " (external_one_byte[j] + external_one_byte[i - j])) return "
+ "5;"
+ " if (external_non_one_byte[i] !="
+ " (external_non_one_byte[j] + external_non_one_byte[i - "
+ "j])) return 6;"
+ " if (non_one_byte[i] != (non_one_byte[j] + non_one_byte[i - "
+ "j])) return 7;"
+ " if (one_byte[i] != (one_byte[j] + one_byte[i - j])) return 8;"
+ " if (one_byte[i] != (external_one_byte[j] + one_byte[i - j])) "
+ "return 9;"
+ " if (one_byte[i] != (one_byte[j] + external_one_byte[i - j])) "
+ "return 10;"
+ " if (non_one_byte[i] !="
+ " (external_non_one_byte[j] + non_one_byte[i - j])) return "
+ "11;"
+ " if (non_one_byte[i] !="
+ " (non_one_byte[j] + external_non_one_byte[i - j])) return "
+ "12;"
+ " }"
+ " }"
+ " return 0;"
+ "};"
+ "test()";
CHECK_EQ(0, CompileRun(source)->Int32Value());
}
Factory* factory = CcTest::i_isolate()->factory();
v8::HandleScope scope(CcTest::isolate());
Handle<String> string =
- factory->NewStringFromStaticAscii("parentparentparent");
+ factory->NewStringFromStaticChars("parentparentparent");
Handle<String> parent =
factory->NewConsString(string, string).ToHandleChecked();
CHECK(parent->IsConsString());
}
-class AsciiVectorResource : public v8::String::ExternalAsciiStringResource {
+class OneByteVectorResource : public v8::String::ExternalOneByteStringResource {
public:
- explicit AsciiVectorResource(i::Vector<const char> vector)
+ explicit OneByteVectorResource(i::Vector<const char> vector)
: data_(vector) {}
- virtual ~AsciiVectorResource() {}
+ virtual ~OneByteVectorResource() {}
virtual size_t length() const { return data_.length(); }
virtual const char* data() const { return data_.start(); }
private:
CcTest::InitializeVM();
Factory* factory = CcTest::i_isolate()->factory();
v8::HandleScope scope(CcTest::isolate());
- AsciiVectorResource resource(
+ OneByteVectorResource resource(
i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
Handle<String> string =
- factory->NewExternalStringFromAscii(&resource).ToHandleChecked();
+ factory->NewExternalStringFromOneByte(&resource).ToHandleChecked();
CHECK(string->IsExternalString());
Handle<String> slice = factory->NewSubString(string, 1, 25);
CHECK(slice->IsSlicedString());
}
-TEST(AsciiArrayJoin) {
+TEST(OneByteArrayJoin) {
// Set heap limits.
v8::ResourceConstraints constraints;
constraints.set_max_semi_space_size(1);
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
v8::Local<v8::Value> result = CompileRun(
- "var subject = 'ascii~only~string~'; "
+ "var subject = 'one_byte~only~string~'; "
"var replace = '\x80'; "
"subject.replace(/~/g, replace); ");
CHECK(result->IsString());
Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result));
CHECK(string->IsSeqTwoByteString());
- v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80");
+ v8::Local<v8::String> expected = v8_str("one_byte\x80only\x80string\x80");
CHECK(expected->Equals(result));
}
Isolate* isolate = CcTest::i_isolate();
{ HandleScope scope(isolate);
DummyOneByteResource r;
- CHECK(isolate->factory()->NewExternalStringFromAscii(&r).is_null());
+ CHECK(isolate->factory()->NewExternalStringFromOneByte(&r).is_null());
CHECK(isolate->has_pending_exception());
isolate->clear_pending_exception();
}
externalizeString(ascii, false);
externalizeString(twobyte, true);
} catch (ex) { }
- assertTrue(isAsciiString(ascii));
- assertFalse(isAsciiString(twobyte));
+ assertTrue(isOneByteString(ascii));
+ assertFalse(isOneByteString(twobyte));
var ascii_slice = ascii.slice(1,-1);
var twobyte_slice = twobyte.slice(2,-1);
var ascii_cons = ascii + ascii;
externalizeString(long_ascii, false);
externalizeString(short_twobyte, true);
externalizeString(long_twobyte, true);
- assertTrue(isAsciiString(short_asii) && isAsciiString(long_ascii));
- assertFalse(isAsciiString(short_twobyte) || isAsciiString(long_twobyte));
+ assertTrue(isOneByteString(short_asii) && isOneByteString(long_ascii));
+ assertFalse(isOneByteString(short_twobyte) || isOneByteString(long_twobyte));
} catch (ex) { }
assertEquals("E=MCsquared", short_ascii + long_ascii);
- assertTrue(isAsciiString(short_ascii + long_ascii));
+ assertTrue(isOneByteString(short_ascii + long_ascii));
assertEquals("MCsquaredE=", long_ascii + short_ascii);
assertEquals("E\u1234MCsquare\u1234", short_twobyte + long_twobyte);
- assertFalse(isAsciiString(short_twobyte + long_twobyte));
+ assertFalse(isOneByteString(short_twobyte + long_twobyte));
assertEquals("E=MCsquared", "E=" + long_ascii);
assertEquals("E\u1234MCsquared", short_twobyte + "MCsquared");
assertEquals("E\u1234MCsquared", short_twobyte + long_ascii);
- assertFalse(isAsciiString(short_twobyte + long_ascii));
+ assertFalse(isOneByteString(short_twobyte + long_ascii));
}
// Run the test many times to ensure IC-s don't break things.
for (var i = 0; i < size; i++) {
str += String.fromCharCode(i & 0x7f);
}
- assertTrue(isAsciiString(str));
+ assertTrue(isOneByteString(str));
- var twoByteExternalWithAsciiData =
+ var twoByteExternalWithOneByteData =
"AA" + (function() { return "A"; })();
- externalizeString(twoByteExternalWithAsciiData, true /* force two-byte */);
- assertFalse(isAsciiString(twoByteExternalWithAsciiData));
+ externalizeString(twoByteExternalWithOneByteData, true /* force two-byte */);
+ assertFalse(isOneByteString(twoByteExternalWithOneByteData));
var realTwoByteExternalString =
"\u1234\u1234\u1234\u1234" + (function() { return "\u1234"; })();
externalizeString(realTwoByteExternalString);
- assertFalse(isAsciiString(realTwoByteExternalString));
+ assertFalse(isOneByteString(realTwoByteExternalString));
- assertTrue(isAsciiString(["a", twoByteExternalWithAsciiData].join("")));
+ assertTrue(isOneByteString(["a", twoByteExternalWithOneByteData].join("")));
// Appending a two-byte string that contains only ascii chars should
// still produce an ascii cons.
- var str1 = str + twoByteExternalWithAsciiData;
- assertTrue(isAsciiString(str1));
+ var str1 = str + twoByteExternalWithOneByteData;
+ assertTrue(isOneByteString(str1));
// Force flattening of the string.
- var old_length = str1.length - twoByteExternalWithAsciiData.length;
+ var old_length = str1.length - twoByteExternalWithOneByteData.length;
for (var i = 0; i < old_length; i++) {
assertEquals(String.fromCharCode(i & 0x7f), str1[i]);
}
}
// Flattened string should still be ascii.
- assertTrue(isAsciiString(str1));
+ assertTrue(isOneByteString(str1));
// Lower-casing an ascii string should produce ascii.
- assertTrue(isAsciiString(str1.toLowerCase()));
+ assertTrue(isOneByteString(str1.toLowerCase()));
- assertFalse(isAsciiString(["a", realTwoByteExternalString].join("")));
+ assertFalse(isOneByteString(["a", realTwoByteExternalString].join("")));
// Appending a real two-byte string should produce a two-byte cons.
var str2 = str + realTwoByteExternalString;
- assertFalse(isAsciiString(str2));
+ assertFalse(isOneByteString(str2));
// Force flattening of the string.
old_length = str2.length - realTwoByteExternalString.length;
}
// Flattened string should still be two-byte.
- assertFalse(isAsciiString(str2));
+ assertFalse(isOneByteString(str2));
}
// Run the test many times to ensure IC-s don't break things.
var b = "23456789qwertyuiopasdfghjklzxcvbn"
assertEquals(a.slice(1,-1), b);
-assertTrue(isAsciiString(a));
+assertTrue(isOneByteString(a));
externalizeString(a, true);
-assertFalse(isAsciiString(a));
+assertFalse(isOneByteString(a));
assertEquals(a.slice(1,-1), b);
assertTrue(/3456789qwe/.test(a));