@@ -1165,14 +1165,22 @@ void ObjectTemplate::SetInternalFieldCount(int value) {
1165
1165
1166
1166
1167
1167
ScriptData* ScriptData::PreCompile (const char * input, int length) {
1168
- unibrow::Utf8InputBuffer<> buf (input, length);
1169
- return i::ParserApi::PreParse (i::Handle <i::String>(), &buf, NULL );
1168
+ i::Utf8ToUC16CharacterStream stream (
1169
+ reinterpret_cast <const unsigned char *>(input), length);
1170
+ return i::ParserApi::PreParse (&stream, NULL );
1170
1171
}
1171
1172
1172
1173
1173
1174
ScriptData* ScriptData::PreCompile (v8::Handle <String> source) {
1174
1175
i::Handle <i::String> str = Utils::OpenHandle (*source);
1175
- return i::ParserApi::PreParse (str, NULL , NULL );
1176
+ if (str->IsExternalTwoByteString ()) {
1177
+ i::ExternalTwoByteStringUC16CharacterStream stream (
1178
+ i::Handle <i::ExternalTwoByteString>::cast (str), 0 , str->length ());
1179
+ return i::ParserApi::PreParse (&stream, NULL );
1180
+ } else {
1181
+ i::GenericStringUC16CharacterStream stream (str, 0 , str->length ());
1182
+ return i::ParserApi::PreParse (&stream, NULL );
1183
+ }
1176
1184
}
1177
1185
1178
1186
@@ -3119,14 +3127,15 @@ int String::Write(uint16_t* buffer,
3119
3127
// using StringInputBuffer or Get(i) to access the characters.
3120
3128
str->TryFlatten ();
3121
3129
}
3122
- int end = length;
3123
- if ( (length == -1 ) || (length > str->length () - start) )
3124
- end = str->length () - start ;
3130
+ int end = start + length;
3131
+ if ((length == -1 ) || (length > str->length () - start) )
3132
+ end = str->length ();
3125
3133
if (end < 0 ) return 0 ;
3126
3134
i::String::WriteToFlat (*str, buffer, start, end);
3127
- if (length == -1 || end < length)
3128
- buffer[end] = ' \0 ' ;
3129
- return end;
3135
+ if (length == -1 || end - start < length) {
3136
+ buffer[end - start] = ' \0 ' ;
3137
+ }
3138
+ return end - start;
3130
3139
}
3131
3140
3132
3141
@@ -4939,7 +4948,8 @@ const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
4939
4948
4940
4949
4941
4950
const HeapSnapshot* HeapProfiler::TakeSnapshot (Handle <String> title,
4942
- HeapSnapshot::Type type) {
4951
+ HeapSnapshot::Type type,
4952
+ ActivityControl* control) {
4943
4953
IsDeadCheck (" v8::HeapProfiler::TakeSnapshot" );
4944
4954
i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull ;
4945
4955
switch (type) {
@@ -4953,7 +4963,8 @@ const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
4953
4963
UNREACHABLE ();
4954
4964
}
4955
4965
return reinterpret_cast <const HeapSnapshot*>(
4956
- i::HeapProfiler::TakeSnapshot (*Utils::OpenHandle (*title), internal_type));
4966
+ i::HeapProfiler::TakeSnapshot (
4967
+ *Utils::OpenHandle (*title), internal_type, control));
4957
4968
}
4958
4969
4959
4970
#endif // ENABLE_LOGGING_AND_PROFILING
@@ -4968,6 +4979,7 @@ void Testing::SetStressRunType(Testing::StressType type) {
4968
4979
}
4969
4980
4970
4981
int Testing::GetStressRuns () {
4982
+ if (internal::FLAG_stress_runs != 0 ) return internal::FLAG_stress_runs;
4971
4983
#ifdef DEBUG
4972
4984
// In debug mode the code runs much slower so stressing will only make two
4973
4985
// runs.
0 commit comments