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) { }
* 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();
// 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");
typedef uint16_t uc16;
typedef signed int uc32;
+#ifndef ARM
+#define CAN_READ_UNALIGNED 1
+#endif
// -----------------------------------------------------------------------------
// Constants
#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":"")
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:
}
}
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
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
}
// 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);
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) {