| Index: src/d8.cc
|
| diff --git a/src/d8.cc b/src/d8.cc
|
| index 6eb7248b0e8fa0d84b802f59132cf29c1931d0c6..357c8a48992bdb157de3df6133ae8abd847f6bc5 100644
|
| --- a/src/d8.cc
|
| +++ b/src/d8.cc
|
| @@ -160,6 +160,7 @@ i::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
|
| CounterCollection Shell::local_counters_;
|
| CounterCollection* Shell::counters_ = &local_counters_;
|
| i::Mutex Shell::context_mutex_;
|
| +const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow();
|
| Persistent<Context> Shell::utility_context_;
|
| #endif // V8_SHARED
|
|
|
| @@ -289,6 +290,15 @@ int PerIsolateData::RealmFind(Handle<Context> context) {
|
| }
|
|
|
|
|
| +#ifndef V8_SHARED
|
| +// performance.now() returns a time stamp as double, measured in milliseconds.
|
| +void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| + i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks;
|
| + args.GetReturnValue().Set(delta.InMillisecondsF());
|
| +}
|
| +#endif // V8_SHARED
|
| +
|
| +
|
| // Realm.current() returns the index of the currently active realm.
|
| void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| Isolate* isolate = args.GetIsolate();
|
| @@ -872,6 +882,13 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
|
| RealmSharedGet, RealmSharedSet);
|
| global_template->Set(String::New("Realm"), realm_template);
|
|
|
| +#ifndef V8_SHARED
|
| + Handle<ObjectTemplate> performance_template = ObjectTemplate::New();
|
| + performance_template->Set(String::New("now"),
|
| + FunctionTemplate::New(PerformanceNow));
|
| + global_template->Set(String::New("performance"), performance_template);
|
| +#endif // V8_SHARED
|
| +
|
| #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
|
| Handle<ObjectTemplate> os_templ = ObjectTemplate::New();
|
| AddOSMethods(os_templ);
|
| @@ -1231,6 +1248,7 @@ SourceGroup::~SourceGroup() {
|
|
|
|
|
| void SourceGroup::Execute(Isolate* isolate) {
|
| + bool exception_was_thrown = false;
|
| for (int i = begin_offset_; i < end_offset_; ++i) {
|
| const char* arg = argv_[i];
|
| if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) {
|
| @@ -1239,7 +1257,8 @@ void SourceGroup::Execute(Isolate* isolate) {
|
| Handle<String> file_name = String::New("unnamed");
|
| Handle<String> source = String::New(argv_[i + 1]);
|
| if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
|
| - Shell::Exit(1);
|
| + exception_was_thrown = true;
|
| + break;
|
| }
|
| ++i;
|
| } else if (arg[0] == '-') {
|
| @@ -1254,10 +1273,14 @@ void SourceGroup::Execute(Isolate* isolate) {
|
| Shell::Exit(1);
|
| }
|
| if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
|
| - Shell::Exit(1);
|
| + exception_was_thrown = true;
|
| + break;
|
| }
|
| }
|
| }
|
| + if (exception_was_thrown != Shell::options.expected_to_throw) {
|
| + Shell::Exit(1);
|
| + }
|
| }
|
|
|
|
|
| @@ -1413,6 +1436,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
|
| options.dump_heap_constants = true;
|
| argv[i] = NULL;
|
| #endif
|
| + } else if (strcmp(argv[i], "--throws") == 0) {
|
| + options.expected_to_throw = true;
|
| + argv[i] = NULL;
|
| }
|
| #ifdef V8_SHARED
|
| else if (strcmp(argv[i], "--dump-counters") == 0) {
|
|
|