| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4965 | 4965 |
| 4966 | 4966 |
| 4967 static Object* Runtime_CompileString(Arguments args) { | 4967 static Object* Runtime_CompileString(Arguments args) { |
| 4968 HandleScope scope; | 4968 HandleScope scope; |
| 4969 ASSERT_EQ(2, args.length()); | 4969 ASSERT_EQ(2, args.length()); |
| 4970 CONVERT_ARG_CHECKED(String, source, 0); | 4970 CONVERT_ARG_CHECKED(String, source, 0); |
| 4971 CONVERT_ARG_CHECKED(Oddball, is_json, 1) | 4971 CONVERT_ARG_CHECKED(Oddball, is_json, 1) |
| 4972 | 4972 |
| 4973 // Compile source string in the global context. | 4973 // Compile source string in the global context. |
| 4974 Handle<Context> context(Top::context()->global_context()); | 4974 Handle<Context> context(Top::context()->global_context()); |
| 4975 Compiler::ValidationState validate = (is_json->IsTrue()) |
| 4976 ? Compiler::VALIDATE_JSON : Compiler::DONT_VALIDATE_JSON; |
| 4975 Handle<JSFunction> boilerplate = Compiler::CompileEval(source, | 4977 Handle<JSFunction> boilerplate = Compiler::CompileEval(source, |
| 4976 context, | 4978 context, |
| 4977 true, | 4979 true, |
| 4978 is_json->IsTrue()); | 4980 validate); |
| 4979 if (boilerplate.is_null()) return Failure::Exception(); | 4981 if (boilerplate.is_null()) return Failure::Exception(); |
| 4980 Handle<JSFunction> fun = | 4982 Handle<JSFunction> fun = |
| 4981 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 4983 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 4982 return *fun; | 4984 return *fun; |
| 4983 } | 4985 } |
| 4984 | 4986 |
| 4985 | 4987 |
| 4986 static Handle<JSFunction> GetBuiltinFunction(String* name) { | 4988 static Handle<JSFunction> GetBuiltinFunction(String* name) { |
| 4987 LookupResult result; | 4989 LookupResult result; |
| 4988 Top::global_context()->builtins()->LocalLookup(name, &result); | 4990 Top::global_context()->builtins()->LocalLookup(name, &result); |
| 4989 return Handle<JSFunction>(JSFunction::cast(result.GetValue())); | 4991 return Handle<JSFunction>(JSFunction::cast(result.GetValue())); |
| 4990 } | 4992 } |
| 4991 | 4993 |
| 4992 | 4994 |
| 4993 static Object* CompileDirectEval(Handle<String> source) { | 4995 static Object* CompileDirectEval(Handle<String> source) { |
| 4994 // Compute the eval context. | 4996 // Compute the eval context. |
| 4995 HandleScope scope; | 4997 HandleScope scope; |
| 4996 StackFrameLocator locator; | 4998 StackFrameLocator locator; |
| 4997 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 4999 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
| 4998 Handle<Context> context(Context::cast(frame->context())); | 5000 Handle<Context> context(Context::cast(frame->context())); |
| 4999 bool is_global = context->IsGlobalContext(); | 5001 bool is_global = context->IsGlobalContext(); |
| 5000 | 5002 |
| 5001 // Compile source string in the current context. | 5003 // Compile source string in the current context. |
| 5002 Handle<JSFunction> boilerplate = | 5004 Handle<JSFunction> boilerplate = Compiler::CompileEval( |
| 5003 Compiler::CompileEval(source, context, is_global, false); | 5005 source, |
| 5006 context, |
| 5007 is_global, |
| 5008 Compiler::DONT_VALIDATE_JSON); |
| 5004 if (boilerplate.is_null()) return Failure::Exception(); | 5009 if (boilerplate.is_null()) return Failure::Exception(); |
| 5005 Handle<JSFunction> fun = | 5010 Handle<JSFunction> fun = |
| 5006 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 5011 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 5007 return *fun; | 5012 return *fun; |
| 5008 } | 5013 } |
| 5009 | 5014 |
| 5010 | 5015 |
| 5011 static Object* Runtime_ResolvePossiblyDirectEval(Arguments args) { | 5016 static Object* Runtime_ResolvePossiblyDirectEval(Arguments args) { |
| 5012 ASSERT(args.length() == 2); | 5017 ASSERT(args.length() == 2); |
| 5013 | 5018 |
| (...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7035 static const char* source_str = | 7040 static const char* source_str = |
| 7036 "function(arguments,__source__){return eval(__source__);}"; | 7041 "function(arguments,__source__){return eval(__source__);}"; |
| 7037 static const int source_str_length = strlen(source_str); | 7042 static const int source_str_length = strlen(source_str); |
| 7038 Handle<String> function_source = | 7043 Handle<String> function_source = |
| 7039 Factory::NewStringFromAscii(Vector<const char>(source_str, | 7044 Factory::NewStringFromAscii(Vector<const char>(source_str, |
| 7040 source_str_length)); | 7045 source_str_length)); |
| 7041 Handle<JSFunction> boilerplate = | 7046 Handle<JSFunction> boilerplate = |
| 7042 Compiler::CompileEval(function_source, | 7047 Compiler::CompileEval(function_source, |
| 7043 context, | 7048 context, |
| 7044 context->IsGlobalContext(), | 7049 context->IsGlobalContext(), |
| 7045 false); | 7050 Compiler::DONT_VALIDATE_JSON); |
| 7046 if (boilerplate.is_null()) return Failure::Exception(); | 7051 if (boilerplate.is_null()) return Failure::Exception(); |
| 7047 Handle<JSFunction> compiled_function = | 7052 Handle<JSFunction> compiled_function = |
| 7048 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 7053 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 7049 | 7054 |
| 7050 // Invoke the result of the compilation to get the evaluation function. | 7055 // Invoke the result of the compilation to get the evaluation function. |
| 7051 bool has_pending_exception; | 7056 bool has_pending_exception; |
| 7052 Handle<Object> receiver(frame->receiver()); | 7057 Handle<Object> receiver(frame->receiver()); |
| 7053 Handle<Object> evaluation_function = | 7058 Handle<Object> evaluation_function = |
| 7054 Execution::Call(compiled_function, receiver, 0, NULL, | 7059 Execution::Call(compiled_function, receiver, 0, NULL, |
| 7055 &has_pending_exception); | 7060 &has_pending_exception); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7103 | 7108 |
| 7104 // Get the global context now set to the top context from before the | 7109 // Get the global context now set to the top context from before the |
| 7105 // debugger was invoked. | 7110 // debugger was invoked. |
| 7106 Handle<Context> context = Top::global_context(); | 7111 Handle<Context> context = Top::global_context(); |
| 7107 | 7112 |
| 7108 // Compile the source to be evaluated. | 7113 // Compile the source to be evaluated. |
| 7109 Handle<JSFunction> boilerplate = | 7114 Handle<JSFunction> boilerplate = |
| 7110 Handle<JSFunction>(Compiler::CompileEval(source, | 7115 Handle<JSFunction>(Compiler::CompileEval(source, |
| 7111 context, | 7116 context, |
| 7112 true, | 7117 true, |
| 7113 false)); | 7118 Compiler::DONT_VALIDATE_JSON)); |
| 7114 if (boilerplate.is_null()) return Failure::Exception(); | 7119 if (boilerplate.is_null()) return Failure::Exception(); |
| 7115 Handle<JSFunction> compiled_function = | 7120 Handle<JSFunction> compiled_function = |
| 7116 Handle<JSFunction>(Factory::NewFunctionFromBoilerplate(boilerplate, | 7121 Handle<JSFunction>(Factory::NewFunctionFromBoilerplate(boilerplate, |
| 7117 context)); | 7122 context)); |
| 7118 | 7123 |
| 7119 // Invoke the result of the compilation to get the evaluation function. | 7124 // Invoke the result of the compilation to get the evaluation function. |
| 7120 bool has_pending_exception; | 7125 bool has_pending_exception; |
| 7121 Handle<Object> receiver = Top::global(); | 7126 Handle<Object> receiver = Top::global(); |
| 7122 Handle<Object> result = | 7127 Handle<Object> result = |
| 7123 Execution::Call(compiled_function, receiver, 0, NULL, | 7128 Execution::Call(compiled_function, receiver, 0, NULL, |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7600 } else { | 7605 } else { |
| 7601 // Handle last resort GC and make sure to allow future allocations | 7606 // Handle last resort GC and make sure to allow future allocations |
| 7602 // to grow the heap without causing GCs (if possible). | 7607 // to grow the heap without causing GCs (if possible). |
| 7603 Counters::gc_last_resort_from_js.Increment(); | 7608 Counters::gc_last_resort_from_js.Increment(); |
| 7604 Heap::CollectAllGarbage(); | 7609 Heap::CollectAllGarbage(); |
| 7605 } | 7610 } |
| 7606 } | 7611 } |
| 7607 | 7612 |
| 7608 | 7613 |
| 7609 } } // namespace v8::internal | 7614 } } // namespace v8::internal |
| OLD | NEW |