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

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

Issue 1180043004: Revert of Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 6 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 | « src/runtime/runtime.h ('k') | src/scopeinfo.cc » ('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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); 374 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate);
375 Handle<JSFunction> fun; 375 Handle<JSFunction> fun;
376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 376 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
377 isolate, fun, 377 isolate, fun,
378 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY, 378 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
379 restriction, RelocInfo::kNoPosition)); 379 restriction, RelocInfo::kNoPosition));
380 return *fun; 380 return *fun;
381 } 381 }
382 382
383 383
384 static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source, 384 static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source,
385 Handle<SharedFunctionInfo> outer_info, 385 Handle<SharedFunctionInfo> outer_info,
386 LanguageMode language_mode, 386 Handle<Object> receiver,
387 int scope_position) { 387 LanguageMode language_mode,
388 int scope_position) {
388 Handle<Context> context = Handle<Context>(isolate->context()); 389 Handle<Context> context = Handle<Context>(isolate->context());
389 Handle<Context> native_context = Handle<Context>(context->native_context()); 390 Handle<Context> native_context = Handle<Context>(context->native_context());
390 391
391 // Check if native context allows code generation from 392 // Check if native context allows code generation from
392 // strings. Throw an exception if it doesn't. 393 // strings. Throw an exception if it doesn't.
393 if (native_context->allow_code_gen_from_strings()->IsFalse() && 394 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
394 !CodeGenerationFromStringsAllowed(isolate, native_context)) { 395 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
395 Handle<Object> error_message = 396 Handle<Object> error_message =
396 native_context->ErrorMessageForCodeGenerationFromStrings(); 397 native_context->ErrorMessageForCodeGenerationFromStrings();
397 Handle<Object> error; 398 Handle<Object> error;
398 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( 399 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError(
399 MessageTemplate::kCodeGenFromStrings, error_message); 400 MessageTemplate::kCodeGenFromStrings, error_message);
400 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); 401 if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
401 return isolate->heap()->exception(); 402 return MakePair(isolate->heap()->exception(), NULL);
402 } 403 }
403 404
404 // Deal with a normal eval call with a string argument. Compile it 405 // Deal with a normal eval call with a string argument. Compile it
405 // and return the compiled function bound in the local context. 406 // and return the compiled function bound in the local context.
406 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; 407 static const ParseRestriction restriction = NO_PARSE_RESTRICTION;
407 Handle<JSFunction> compiled; 408 Handle<JSFunction> compiled;
408 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 409 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
409 isolate, compiled, 410 isolate, compiled,
410 Compiler::GetFunctionFromEval(source, outer_info, context, language_mode, 411 Compiler::GetFunctionFromEval(source, outer_info, context, language_mode,
411 restriction, scope_position), 412 restriction, scope_position),
412 isolate->heap()->exception()); 413 MakePair(isolate->heap()->exception(), NULL));
413 return *compiled; 414 return MakePair(*compiled, *receiver);
414 } 415 }
415 416
416 417
417 RUNTIME_FUNCTION(Runtime_ResolvePossiblyDirectEval) { 418 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval) {
418 HandleScope scope(isolate); 419 HandleScope scope(isolate);
419 DCHECK(args.length() == 5); 420 DCHECK(args.length() == 6);
420 421
421 Handle<Object> callee = args.at<Object>(0); 422 Handle<Object> callee = args.at<Object>(0);
422 423
423 // If "eval" didn't refer to the original GlobalEval, it's not a 424 // If "eval" didn't refer to the original GlobalEval, it's not a
424 // direct call to eval. 425 // direct call to eval.
425 // (And even if it is, but the first argument isn't a string, just let 426 // (And even if it is, but the first argument isn't a string, just let
426 // execution default to an indirect call to eval, which will also return 427 // execution default to an indirect call to eval, which will also return
427 // the first argument without doing anything). 428 // the first argument without doing anything).
428 if (*callee != isolate->native_context()->global_eval_fun() || 429 if (*callee != isolate->native_context()->global_eval_fun() ||
429 !args[1]->IsString()) { 430 !args[1]->IsString()) {
430 return *callee; 431 return MakePair(*callee, isolate->heap()->undefined_value());
431 } 432 }
432 433
433 DCHECK(args[3]->IsSmi());
434 DCHECK(is_valid_language_mode(args.smi_at(3)));
435 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3));
436 DCHECK(args[4]->IsSmi()); 434 DCHECK(args[4]->IsSmi());
435 DCHECK(is_valid_language_mode(args.smi_at(4)));
436 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(4));
437 DCHECK(args[5]->IsSmi());
437 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), 438 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(),
438 isolate); 439 isolate);
439 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, 440 return CompileGlobalEval(isolate, args.at<String>(1), outer_info,
440 language_mode, args.smi_at(4)); 441 args.at<Object>(3), language_mode, args.smi_at(5));
441 } 442 }
442 } // namespace internal 443 } // namespace internal
443 } // namespace v8 444 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698