OLD | NEW |
---|---|
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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 PassOwnPtr<CompileFn> selectCompileFunction(ScriptResource* resource, ScriptStre amer* streamer) | 348 PassOwnPtr<CompileFn> selectCompileFunction(ScriptResource* resource, ScriptStre amer* streamer) |
349 { | 349 { |
350 // We don't stream scripts which don't have a Resource. | 350 // We don't stream scripts which don't have a Resource. |
351 ASSERT(resource); | 351 ASSERT(resource); |
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 | |
359 void throwSourceTooLargeException(const v8::FunctionCallbackInfo<v8::Value>& inf o) | |
360 { | |
361 V8ThrowException::throwGeneralError(info.GetIsolate(), "Source file too larg e."); | |
362 } | |
363 | |
358 } // namespace | 364 } // namespace |
359 | 365 |
360 v8::Local<v8::Script> V8ScriptRunner::compileScript(const ScriptSourceCode& sour ce, v8::Isolate* isolate, AccessControlStatus corsStatus, V8CacheOptions cacheOp tions) | 366 v8::Local<v8::Script> V8ScriptRunner::compileScript(const ScriptSourceCode& sour ce, v8::Isolate* isolate, AccessControlStatus corsStatus, V8CacheOptions cacheOp tions) |
361 { | 367 { |
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); | 368 v8::Handle<v8::String> sourceAsV8String(v8String(isolate, source.source())); |
369 if (sourceAsV8String.IsEmpty()) { | |
370 // String conversion fails when the source size exceeds the V8 string | |
371 // length of (currently) 256MB. | |
372 V8RecursionScope scope(isolate); | |
373 v8::Function::New(isolate, throwSourceTooLargeException)->Call(v8::Undef ined(isolate), 0, 0); | |
haraken
2015/03/09 23:21:56
Can we use a (already existing) helper function in
| |
374 return v8::Local<v8::Script>(); | |
375 } | |
376 | |
377 return compileScript(sourceAsV8String, source.url(), source.sourceMapUrl(), source.startPosition(), isolate, source.resource(), source.streamer(), source.re source() ? source.resource()->cacheHandler() : nullptr, corsStatus, cacheOptions ); | |
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 Loading... | |
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 |
OLD | NEW |