Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/d8.cc

Issue 1260813008: [d8 Workers] Throw when calling Worker constructor without new (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress-4399.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 #ifndef V8_SHARED 693 #ifndef V8_SHARED
694 void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { 694 void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
695 Isolate* isolate = args.GetIsolate(); 695 Isolate* isolate = args.GetIsolate();
696 HandleScope handle_scope(isolate); 696 HandleScope handle_scope(isolate);
697 if (args.Length() < 1 || !args[0]->IsString()) { 697 if (args.Length() < 1 || !args[0]->IsString()) {
698 Throw(args.GetIsolate(), "1st argument must be string"); 698 Throw(args.GetIsolate(), "1st argument must be string");
699 return; 699 return;
700 } 700 }
701 701
702 if (!args.IsConstructCall()) {
703 Throw(args.GetIsolate(), "Worker must be constructed with new");
704 return;
705 }
706
702 { 707 {
703 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); 708 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
704 // Initialize the internal field to NULL; if we return early without 709 // Initialize the internal field to NULL; if we return early without
705 // creating a new Worker (because the main thread is terminating) we can 710 // creating a new Worker (because the main thread is terminating) we can
706 // early-out from the instance calls. 711 // early-out from the instance calls.
707 args.Holder()->SetAlignedPointerInInternalField(0, NULL); 712 args.Holder()->SetAlignedPointerInInternalField(0, NULL);
708 713
709 if (!allow_new_workers_) return; 714 if (!allow_new_workers_) return;
710 715
711 Worker* worker = new Worker; 716 Worker* worker = new Worker;
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 } 2469 }
2465 2470
2466 } // namespace v8 2471 } // namespace v8
2467 2472
2468 2473
2469 #ifndef GOOGLE3 2474 #ifndef GOOGLE3
2470 int main(int argc, char* argv[]) { 2475 int main(int argc, char* argv[]) {
2471 return v8::Shell::Main(argc, argv); 2476 return v8::Shell::Main(argc, argv);
2472 } 2477 }
2473 #endif 2478 #endif
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress-4399.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698