- Changed regexp logging to include the string being matched and to

  escape commas.
- Fixed issue with block-comparing unaligned strings on arm.
- Added short documentation to one of the Persistent constructors.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@554 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 949729c0
......@@ -327,6 +327,10 @@ template <class T> class EXPORT_INLINE Persistent : public Handle<T> {
template <class S> inline Persistent(S* that) : Handle<T>(that) { }
/**
* "Casts" a plain handle which is known to be a persistent handle
* to a persistent handle.
*/
template <class S> explicit inline Persistent(Handle<S> that)
: Handle<T>(*that) { }
......@@ -1056,7 +1060,7 @@ class EXPORT Object : public Value {
* Turns on access check on the object if the object is an instance of
* a template that has access check callbacks. If an object has no
* access check info, the object cannot be accessed by anyone.
*/
*/
void TurnOnAccessCheck();
static Local<Object> New();
......
......@@ -237,11 +237,10 @@ void Shell::Initialize() {
// Install the debugger object in the utility scope
i::Debug::Load();
i::JSObject* raw_debug = i::Debug::debug_context()->global();
i::JSGlobalObject* debug = i::JSGlobalObject::cast(raw_debug);
debug->set_security_token(i::Heap::undefined_value());
i::Debug::debug_context()->set_security_token(i::Heap::undefined_value());
i::JSObject* debug = i::Debug::debug_context()->global();
utility_context_->Global()->Set(String::New("$debug"),
Utils::ToLocal(&raw_debug));
Utils::ToLocal(&debug));
// Run the d8 shell utility script in the utility context
int source_index = i::NativesCollection<i::D8>::GetIndex("d8");
......
......@@ -73,6 +73,9 @@ typedef byte* Address;
typedef uint16_t uc16;
typedef signed int uc32;
#ifndef ARM
#define CAN_READ_UNALIGNED 1
#endif
// -----------------------------------------------------------------------------
// Constants
......
......@@ -349,6 +349,24 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path,
#ifdef ENABLE_LOGGING_AND_PROFILING
void Logger::LogString(Handle<String> str) {
int len = str->length();
if (len > 256)
len = 256;
for (int i = 0; i < len; i++) {
uc32 c = str->Get(i);
if (c < 32 || (c > 126 && c <= 255)) {
fprintf(logfile_, "\\x%02x", c);
} else if (c > 255) {
fprintf(logfile_, "\\u%04x", c);
} else if (c == ',') {
fprintf(logfile_, "\\,");
} else {
fprintf(logfile_, "%lc", c);
}
}
}
void Logger::LogRegExpSource(Handle<JSRegExp> regexp) {
// Prints "/" + re.source + "/" +
// (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"")
......@@ -358,9 +376,7 @@ void Logger::LogRegExpSource(Handle<JSRegExp> regexp) {
fprintf(logfile_, "no source");
return;
}
Handle<String> source_string = Handle<String>::cast(source);
SmartPointer<uc16> cstring = source_string->ToWideCString();
if (regexp->type()->IsSmi()) {
switch (regexp->type_tag()) {
case JSRegExp::ATOM:
......@@ -371,16 +387,7 @@ void Logger::LogRegExpSource(Handle<JSRegExp> regexp) {
}
}
fprintf(logfile_, "/");
for (int i = 0, n = source_string->length(); i < n; i++) {
uc16 c = cstring[i];
if (c < 32 || (c > 126 && c <= 255)) {
fprintf(logfile_, "\\x%02x", c);
} else if (c > 255) {
fprintf(logfile_, "\\u%04x", c);
} else {
fprintf(logfile_, "%lc", c);
}
}
LogString(Handle<String>::cast(source));
fprintf(logfile_, "/");
// global flag
......@@ -423,8 +430,9 @@ void Logger::RegExpExecEvent(Handle<JSRegExp> regexp,
fprintf(logfile_, "regexp-run,");
LogRegExpSource(regexp);
fprintf(logfile_, ",0x%08x,%d..%d\n",
input_string->Hash(), start_index, input_string->length());
fprintf(logfile_, ",");
LogString(input_string);
fprintf(logfile_, ",%d..%d\n", start_index, input_string->length());
#endif
}
......
......@@ -199,6 +199,8 @@ class Logger {
// Emits the source code of a regexp. Used by regexp events.
static void LogRegExpSource(Handle<JSRegExp> regexp);
static void LogString(Handle<String> str);
// Emits a profiler tick event. Used by the profiler thread.
static void TickEvent(TickSample* sample, bool overflow);
......
......@@ -3727,6 +3727,19 @@ static inline bool CompareRawStringContents(Vector<Char> a, Vector<Char> b) {
int endpoint = length - kStepSize;
const Char* pa = a.start();
const Char* pb = b.start();
#ifndef CAN_READ_UNALIGNED
// If this architecture isn't comfortable reading unaligned ints
// then we have to check that the strings are alingned and fall back
// to the standard comparison if they are not.
const int kAlignmentMask = sizeof(uint32_t) - 1; // NOLINT
uint32_t pa_addr = reinterpret_cast<uint32_t>(pa);
uint32_t pb_addr = reinterpret_cast<uint32_t>(pb);
if ((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask) != 0) {
VectorIterator<Char> ia(a);
VectorIterator<Char> ib(b);
return CompareStringContents(&ia, &ib);
}
#endif
int i;
// Compare blocks until we reach near the end of the string.
for (i = 0; i <= endpoint; i += kStepSize) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment