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

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

Issue 989573002: Cleanly handle excessively long JS source strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: syntax error => general error Created 5 years, 9 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
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // Failed resources should never get this far. 352 // Failed resources should never get this far.
353 ASSERT(!resource->errorOccurred()); 353 ASSERT(!resource->errorOccurred());
354 ASSERT(streamer->isFinished()); 354 ASSERT(streamer->isFinished());
355 ASSERT(!streamer->streamingSuppressed()); 355 ASSERT(!streamer->streamingSuppressed());
356 return WTF::bind<v8::Isolate*, v8::Handle<v8::String>, v8::ScriptOrigin>(pos tStreamCompile, resource->cacheHandler(), streamer); 356 return WTF::bind<v8::Isolate*, v8::Handle<v8::String>, v8::ScriptOrigin>(pos tStreamCompile, resource->cacheHandler(), streamer);
357 } 357 }
358 } // namespace 358 } // namespace
359 359
360 v8::Local<v8::Script> V8ScriptRunner::compileScript(const ScriptSourceCode& sour ce, v8::Isolate* isolate, AccessControlStatus corsStatus, V8CacheOptions cacheOp tions) 360 v8::Local<v8::Script> V8ScriptRunner::compileScript(const ScriptSourceCode& sour ce, v8::Isolate* isolate, AccessControlStatus corsStatus, V8CacheOptions cacheOp tions)
361 { 361 {
362 return compileScript(v8String(isolate, source.source()), source.url(), sourc e.sourceMapUrl(), source.startPosition(), isolate, source.resource(), source.str eamer(), source.resource() ? source.resource()->cacheHandler() : nullptr, corsSt atus, cacheOptions); 362 v8::Handle<v8::String> sourceAsV8String(v8String(isolate, source.source()));
363 if (sourceAsV8String.IsEmpty()) {
364 V8ThrowException::throwGeneralError(isolate, "Source file too large.");
365 return v8::Local<v8::Script>();
366 }
367 return compileScript(sourceAsV8String, source.url(), source.sourceMapUrl(), source.startPosition(), isolate, source.resource(), source.streamer(), source.re source() ? source.resource()->cacheHandler() : nullptr, corsStatus, cacheOptions );
368 }
369
370 v8::Local<v8::Script> V8ScriptRunner::compileScript(const String& code, const St ring& fileName, const String& sourceMapUrl, const TextPosition& textPosition, v8 ::Isolate* isolate, CachedMetadataHandler* cacheMetadataHandler, AccessControlSt atus accessControlStatus, V8CacheOptions v8CacheOptions)
371 {
372 v8::Handle<v8::String> codeAsV8String(v8String(isolate, code));
373 if (codeAsV8String.IsEmpty()) {
374 V8ThrowException::throwGeneralError(isolate, "Source file too large.");
375 return v8::Local<v8::Script>();
376 }
377 return compileScript(codeAsV8String, fileName, sourceMapUrl, textPosition, i solate, nullptr, nullptr, cacheMetadataHandler, accessControlStatus, v8CacheOpti ons);
363 } 378 }
364 379
365 v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, const String& fileName, const String& sourceMapUrl, const TextPosition& scriptS tartPosition, v8::Isolate* isolate, ScriptResource* resource, ScriptStreamer* st reamer, CachedMetadataHandler* cacheHandler, AccessControlStatus corsStatus, V8C acheOptions cacheOptions, bool isInternalScript) 380 v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, const String& fileName, const String& sourceMapUrl, const TextPosition& scriptS tartPosition, v8::Isolate* isolate, ScriptResource* resource, ScriptStreamer* st reamer, CachedMetadataHandler* cacheHandler, AccessControlStatus corsStatus, V8C acheOptions cacheOptions, bool isInternalScript)
366 { 381 {
367 TRACE_EVENT1("v8", "v8.compile", "fileName", fileName.utf8()); 382 TRACE_EVENT1("v8", "v8.compile", "fileName", fileName.utf8());
368 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Compile"); 383 TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Compile");
369 384
370 ASSERT(!streamer || resource); 385 ASSERT(!streamer || resource);
371 ASSERT(!resource || resource->cacheHandler() == cacheHandler); 386 ASSERT(!resource || resource->cacheHandler() == cacheHandler);
372 387
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 { 521 {
507 return cacheTag(CacheTagParser, cacheHandler); 522 return cacheTag(CacheTagParser, cacheHandler);
508 } 523 }
509 524
510 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) 525 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler)
511 { 526 {
512 return cacheTag(CacheTagCode, cacheHandler); 527 return cacheTag(CacheTagCode, cacheHandler);
513 } 528 }
514 529
515 } // namespace blink 530 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8ScriptRunner.h ('k') | Source/bindings/core/v8/WorkerScriptController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698