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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp

Issue 2709703004: Clean up V8ObjectConstructor (Closed)
Patch Set: Rebase Created 3 years, 10 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 | « third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 v8::MaybeLocal<v8::Value> V8ScriptRunner::evaluateModule( 690 v8::MaybeLocal<v8::Value> V8ScriptRunner::evaluateModule(
691 v8::Local<v8::Module> module, 691 v8::Local<v8::Module> module,
692 v8::Local<v8::Context> context, 692 v8::Local<v8::Context> context,
693 v8::Isolate* isolate) { 693 v8::Isolate* isolate) {
694 TRACE_EVENT0("v8", "v8.evaluateModule"); 694 TRACE_EVENT0("v8", "v8.evaluateModule");
695 v8::MicrotasksScope microtasksScope(isolate, 695 v8::MicrotasksScope microtasksScope(isolate,
696 v8::MicrotasksScope::kRunMicrotasks); 696 v8::MicrotasksScope::kRunMicrotasks);
697 return module->Evaluate(context); 697 return module->Evaluate(context);
698 } 698 }
699 699
700 v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObject(
701 v8::Isolate* isolate,
702 v8::Local<v8::ObjectTemplate> objectTemplate) {
703 TRACE_EVENT0("v8", "v8.newInstance");
704
705 v8::MicrotasksScope microtasksScope(isolate,
706 v8::MicrotasksScope::kDoNotRunMicrotasks);
707 v8::MaybeLocal<v8::Object> result =
708 objectTemplate->NewInstance(isolate->GetCurrentContext());
709 CHECK(!isolate->IsDead());
710 return result;
711 }
712
713 v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObject(
714 v8::Isolate* isolate,
715 v8::Local<v8::Function> function,
716 int argc,
717 v8::Local<v8::Value> argv[]) {
718 TRACE_EVENT0("v8", "v8.newInstance");
719
720 v8::MicrotasksScope microtasksScope(isolate,
721 v8::MicrotasksScope::kDoNotRunMicrotasks);
722 v8::MaybeLocal<v8::Object> result =
723 function->NewInstance(isolate->GetCurrentContext(), argc, argv);
724 CHECK(!isolate->IsDead());
725 return result;
726 }
727
728 v8::MaybeLocal<v8::Object> V8ScriptRunner::instantiateObjectInDocument(
729 v8::Isolate* isolate,
730 v8::Local<v8::Function> function,
731 ExecutionContext* context,
732 int argc,
733 v8::Local<v8::Value> argv[]) {
734 TRACE_EVENT0("v8", "v8.newInstance");
735 if (ScriptForbiddenScope::isScriptForbidden()) {
736 throwScriptForbiddenException(isolate);
737 return v8::MaybeLocal<v8::Object>();
738 }
739 v8::MicrotasksScope microtasksScope(isolate,
740 v8::MicrotasksScope::kRunMicrotasks);
741 v8::MaybeLocal<v8::Object> result =
742 function->NewInstance(isolate->GetCurrentContext(), argc, argv);
743 CHECK(!isolate->IsDead());
744 return result;
745 }
746
747 uint32_t V8ScriptRunner::tagForParserCache( 700 uint32_t V8ScriptRunner::tagForParserCache(
748 CachedMetadataHandler* cacheHandler) { 701 CachedMetadataHandler* cacheHandler) {
749 return cacheTag(CacheTagParser, cacheHandler); 702 return cacheTag(CacheTagParser, cacheHandler);
750 } 703 }
751 704
752 uint32_t V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) { 705 uint32_t V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) {
753 return cacheTag(CacheTagCode, cacheHandler); 706 return cacheTag(CacheTagCode, cacheHandler);
754 } 707 }
755 708
756 // Store a timestamp to the cache as hint. 709 // Store a timestamp to the cache as hint.
(...skipping 25 matching lines...) Expand all
782 v8AtomicString(isolate, "((e) => { throw e; })"), origin) 735 v8AtomicString(isolate, "((e) => { throw e; })"), origin)
783 .ToLocalChecked(); 736 .ToLocalChecked();
784 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script) 737 v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script)
785 .ToLocalChecked() 738 .ToLocalChecked()
786 .As<v8::Function>(); 739 .As<v8::Function>();
787 v8::Local<v8::Value> args[] = {exception}; 740 v8::Local<v8::Value> args[] = {exception};
788 callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate); 741 callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate);
789 } 742 }
790 743
791 } // namespace blink 744 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698