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

Side by Side Diff: src/runtime/runtime-compiler.cc

Issue 1053563002: Revert of Correctly compute line numbers in functions from the function constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added regression test Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime.h ('k') | src/v8natives.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/frames.h" 10 #include "src/frames.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } else { 342 } else {
343 // Callback set. Let it decide if code generation is allowed. 343 // Callback set. Let it decide if code generation is allowed.
344 VMState<EXTERNAL> state(isolate); 344 VMState<EXTERNAL> state(isolate);
345 return callback(v8::Utils::ToLocal(context)); 345 return callback(v8::Utils::ToLocal(context));
346 } 346 }
347 } 347 }
348 348
349 349
350 RUNTIME_FUNCTION(Runtime_CompileString) { 350 RUNTIME_FUNCTION(Runtime_CompileString) {
351 HandleScope scope(isolate); 351 HandleScope scope(isolate);
352 DCHECK(args.length() == 3); 352 DCHECK(args.length() == 2);
353 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 353 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
354 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); 354 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1);
355 CONVERT_SMI_ARG_CHECKED(source_offset, 2);
356 355
357 // Extract native context. 356 // Extract native context.
358 Handle<Context> context(isolate->native_context()); 357 Handle<Context> context(isolate->native_context());
359 358
360 // Check if native context allows code generation from 359 // Check if native context allows code generation from
361 // strings. Throw an exception if it doesn't. 360 // strings. Throw an exception if it doesn't.
362 if (context->allow_code_gen_from_strings()->IsFalse() && 361 if (context->allow_code_gen_from_strings()->IsFalse() &&
363 !CodeGenerationFromStringsAllowed(isolate, context)) { 362 !CodeGenerationFromStringsAllowed(isolate, context)) {
364 Handle<Object> error_message = 363 Handle<Object> error_message =
365 context->ErrorMessageForCodeGenerationFromStrings(); 364 context->ErrorMessageForCodeGenerationFromStrings();
366 THROW_NEW_ERROR_RETURN_FAILURE( 365 THROW_NEW_ERROR_RETURN_FAILURE(
367 isolate, NewEvalError("code_gen_from_strings", 366 isolate, NewEvalError("code_gen_from_strings",
368 HandleVector<Object>(&error_message, 1))); 367 HandleVector<Object>(&error_message, 1)));
369 } 368 }
370 369
371 // Compile source string in the native context. 370 // Compile source string in the native context.
372 ParseRestriction restriction = function_literal_only 371 ParseRestriction restriction = function_literal_only
373 ? ONLY_SINGLE_FUNCTION_LITERAL 372 ? ONLY_SINGLE_FUNCTION_LITERAL
374 : NO_PARSE_RESTRICTION; 373 : NO_PARSE_RESTRICTION;
375 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); 374 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate);
376 Handle<JSFunction> fun; 375 Handle<JSFunction> fun;
377 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
378 isolate, fun, 377 isolate, fun,
379 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY, 378 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
380 restriction, RelocInfo::kNoPosition)); 379 restriction, RelocInfo::kNoPosition));
381 if (function_literal_only) {
382 // The actual body is wrapped, which shifts line numbers.
383 Handle<Script> script(Script::cast(fun->shared()->script()), isolate);
384 if (script->line_offset() == 0) {
385 int line_num = Script::GetLineNumber(script, source_offset);
386 script->set_line_offset(Smi::FromInt(-line_num));
387 }
388 }
389 return *fun; 380 return *fun;
390 } 381 }
391 382
392 383
393 static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source, 384 static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source,
394 Handle<SharedFunctionInfo> outer_info, 385 Handle<SharedFunctionInfo> outer_info,
395 Handle<Object> receiver, 386 Handle<Object> receiver,
396 LanguageMode language_mode, 387 LanguageMode language_mode,
397 int scope_position) { 388 int scope_position) {
398 Handle<Context> context = Handle<Context>(isolate->context()); 389 Handle<Context> context = Handle<Context>(isolate->context());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 DCHECK(is_valid_language_mode(args.smi_at(4))); 435 DCHECK(is_valid_language_mode(args.smi_at(4)));
445 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4)); 436 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4));
446 DCHECK(args[5]->IsSmi()); 437 DCHECK(args[5]->IsSmi());
447 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), 438 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(),
448 isolate); 439 isolate);
449 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, 440 return CompileGlobalEval(isolate, args.at<String>(1), outer_info,
450 args.at<Object>(3), language_mode, args.smi_at(5)); 441 args.at<Object>(3), language_mode, args.smi_at(5));
451 } 442 }
452 } 443 }
453 } // namespace v8::internal 444 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698