| Index: src/runtime.cc
|
| ===================================================================
|
| --- src/runtime.cc (revision 4792)
|
| +++ src/runtime.cc (working copy)
|
| @@ -7245,6 +7245,24 @@
|
| }
|
|
|
|
|
| +static ObjectPair CompileGlobalEval(Handle<String> source,
|
| + Handle<Object> receiver) {
|
| + // Deal with a normal eval call with a string argument. Compile it
|
| + // and return the compiled function bound in the local context.
|
| + Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
|
| + source,
|
| + Handle<Context>(Top::context()),
|
| + Top::context()->IsGlobalContext(),
|
| + Compiler::DONT_VALIDATE_JSON);
|
| + if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
|
| + Handle<JSFunction> compiled = Factory::NewFunctionFromSharedFunctionInfo(
|
| + shared,
|
| + Handle<Context>(Top::context()),
|
| + NOT_TENURED);
|
| + return MakePair(*compiled, *receiver);
|
| +}
|
| +
|
| +
|
| static ObjectPair Runtime_ResolvePossiblyDirectEval(Arguments args) {
|
| ASSERT(args.length() == 3);
|
| if (!args[0]->IsJSFunction()) {
|
| @@ -7310,23 +7328,30 @@
|
| return MakePair(*callee, Top::context()->global()->global_receiver());
|
| }
|
|
|
| - // Deal with a normal eval call with a string argument. Compile it
|
| - // and return the compiled function bound in the local context.
|
| - Handle<String> source = args.at<String>(1);
|
| - Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
|
| - source,
|
| - Handle<Context>(Top::context()),
|
| - Top::context()->IsGlobalContext(),
|
| - Compiler::DONT_VALIDATE_JSON);
|
| - if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
|
| - callee = Factory::NewFunctionFromSharedFunctionInfo(
|
| - shared,
|
| - Handle<Context>(Top::context()),
|
| - NOT_TENURED);
|
| - return MakePair(*callee, args[2]);
|
| + return CompileGlobalEval(args.at<String>(1), args.at<Object>(2));
|
| }
|
|
|
|
|
| +static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(Arguments args) {
|
| + ASSERT(args.length() == 3);
|
| + if (!args[0]->IsJSFunction()) {
|
| + return MakePair(Top::ThrowIllegalOperation(), NULL);
|
| + }
|
| +
|
| + HandleScope scope;
|
| + Handle<JSFunction> callee = args.at<JSFunction>(0);
|
| +
|
| + // 'eval' is bound in the global context, but it may have been overwritten.
|
| + // Compare it to the builtin 'GlobalEval' function to make sure.
|
| + if (*callee != Top::global_context()->global_eval_fun() ||
|
| + !args[1]->IsString()) {
|
| + return MakePair(*callee, Top::context()->global()->global_receiver());
|
| + }
|
| +
|
| + return CompileGlobalEval(args.at<String>(1), args.at<Object>(2));
|
| +}
|
| +
|
| +
|
| static Object* Runtime_SetNewFunctionAttributes(Arguments args) {
|
| // This utility adjusts the property attributes for newly created Function
|
| // object ("new Function(...)") by changing the map.
|
|
|