| 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 4870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4881 static Object* Runtime_GlobalReceiver(Arguments args) { | 4881 static Object* Runtime_GlobalReceiver(Arguments args) { |
| 4882 ASSERT(args.length() == 1); | 4882 ASSERT(args.length() == 1); |
| 4883 Object* global = args[0]; | 4883 Object* global = args[0]; |
| 4884 if (!global->IsJSGlobalObject()) return Heap::null_value(); | 4884 if (!global->IsJSGlobalObject()) return Heap::null_value(); |
| 4885 return JSGlobalObject::cast(global)->global_receiver(); | 4885 return JSGlobalObject::cast(global)->global_receiver(); |
| 4886 } | 4886 } |
| 4887 | 4887 |
| 4888 | 4888 |
| 4889 static Object* Runtime_CompileString(Arguments args) { | 4889 static Object* Runtime_CompileString(Arguments args) { |
| 4890 HandleScope scope; | 4890 HandleScope scope; |
| 4891 ASSERT_EQ(3, args.length()); | 4891 ASSERT_EQ(2, args.length()); |
| 4892 CONVERT_ARG_CHECKED(String, source, 0); | 4892 CONVERT_ARG_CHECKED(String, source, 0); |
| 4893 CONVERT_ARG_CHECKED(Smi, line_offset, 1); | 4893 CONVERT_ARG_CHECKED(Oddball, is_json, 1) |
| 4894 CONVERT_ARG_CHECKED(Oddball, is_json, 2) | |
| 4895 | 4894 |
| 4896 // Compile source string in the global context. | 4895 // Compile source string in the global context. |
| 4897 Handle<Context> context(Top::context()->global_context()); | 4896 Handle<Context> context(Top::context()->global_context()); |
| 4898 Handle<JSFunction> boilerplate = Compiler::CompileEval(source, | 4897 Handle<JSFunction> boilerplate = Compiler::CompileEval(source, |
| 4899 context, | 4898 context, |
| 4900 line_offset->value(), | |
| 4901 true, | 4899 true, |
| 4902 is_json->IsTrue()); | 4900 is_json->IsTrue()); |
| 4903 if (boilerplate.is_null()) return Failure::Exception(); | 4901 if (boilerplate.is_null()) return Failure::Exception(); |
| 4904 Handle<JSFunction> fun = | 4902 Handle<JSFunction> fun = |
| 4905 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 4903 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 4906 return *fun; | 4904 return *fun; |
| 4907 } | 4905 } |
| 4908 | 4906 |
| 4909 | 4907 |
| 4910 static Handle<JSFunction> GetBuiltinFunction(String* name) { | 4908 static Handle<JSFunction> GetBuiltinFunction(String* name) { |
| 4911 LookupResult result; | 4909 LookupResult result; |
| 4912 Top::global_context()->builtins()->LocalLookup(name, &result); | 4910 Top::global_context()->builtins()->LocalLookup(name, &result); |
| 4913 return Handle<JSFunction>(JSFunction::cast(result.GetValue())); | 4911 return Handle<JSFunction>(JSFunction::cast(result.GetValue())); |
| 4914 } | 4912 } |
| 4915 | 4913 |
| 4916 | 4914 |
| 4917 static Object* CompileDirectEval(Handle<String> source) { | 4915 static Object* CompileDirectEval(Handle<String> source) { |
| 4918 // Compute the eval context. | 4916 // Compute the eval context. |
| 4919 HandleScope scope; | 4917 HandleScope scope; |
| 4920 StackFrameLocator locator; | 4918 StackFrameLocator locator; |
| 4921 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 4919 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
| 4922 Handle<Context> context(Context::cast(frame->context())); | 4920 Handle<Context> context(Context::cast(frame->context())); |
| 4923 bool is_global = context->IsGlobalContext(); | 4921 bool is_global = context->IsGlobalContext(); |
| 4924 | 4922 |
| 4925 // Compile source string in the current context. | 4923 // Compile source string in the current context. |
| 4926 Handle<JSFunction> boilerplate = | 4924 Handle<JSFunction> boilerplate = |
| 4927 Compiler::CompileEval(source, context, 0, is_global, false); | 4925 Compiler::CompileEval(source, context, is_global, false); |
| 4928 if (boilerplate.is_null()) return Failure::Exception(); | 4926 if (boilerplate.is_null()) return Failure::Exception(); |
| 4929 Handle<JSFunction> fun = | 4927 Handle<JSFunction> fun = |
| 4930 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 4928 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 4931 return *fun; | 4929 return *fun; |
| 4932 } | 4930 } |
| 4933 | 4931 |
| 4934 | 4932 |
| 4935 static Object* Runtime_ResolvePossiblyDirectEval(Arguments args) { | 4933 static Object* Runtime_ResolvePossiblyDirectEval(Arguments args) { |
| 4936 ASSERT(args.length() == 2); | 4934 ASSERT(args.length() == 2); |
| 4937 | 4935 |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6550 // function(arguments,__source__) {return eval(__source__);} | 6548 // function(arguments,__source__) {return eval(__source__);} |
| 6551 static const char* source_str = | 6549 static const char* source_str = |
| 6552 "function(arguments,__source__){return eval(__source__);}"; | 6550 "function(arguments,__source__){return eval(__source__);}"; |
| 6553 static const int source_str_length = strlen(source_str); | 6551 static const int source_str_length = strlen(source_str); |
| 6554 Handle<String> function_source = | 6552 Handle<String> function_source = |
| 6555 Factory::NewStringFromAscii(Vector<const char>(source_str, | 6553 Factory::NewStringFromAscii(Vector<const char>(source_str, |
| 6556 source_str_length)); | 6554 source_str_length)); |
| 6557 Handle<JSFunction> boilerplate = | 6555 Handle<JSFunction> boilerplate = |
| 6558 Compiler::CompileEval(function_source, | 6556 Compiler::CompileEval(function_source, |
| 6559 context, | 6557 context, |
| 6560 0, | |
| 6561 context->IsGlobalContext(), | 6558 context->IsGlobalContext(), |
| 6562 false); | 6559 false); |
| 6563 if (boilerplate.is_null()) return Failure::Exception(); | 6560 if (boilerplate.is_null()) return Failure::Exception(); |
| 6564 Handle<JSFunction> compiled_function = | 6561 Handle<JSFunction> compiled_function = |
| 6565 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 6562 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
| 6566 | 6563 |
| 6567 // Invoke the result of the compilation to get the evaluation function. | 6564 // Invoke the result of the compilation to get the evaluation function. |
| 6568 bool has_pending_exception; | 6565 bool has_pending_exception; |
| 6569 Handle<Object> receiver(frame->receiver()); | 6566 Handle<Object> receiver(frame->receiver()); |
| 6570 Handle<Object> evaluation_function = | 6567 Handle<Object> evaluation_function = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6612 } | 6609 } |
| 6613 | 6610 |
| 6614 // Get the global context now set to the top context from before the | 6611 // Get the global context now set to the top context from before the |
| 6615 // debugger was invoked. | 6612 // debugger was invoked. |
| 6616 Handle<Context> context = Top::global_context(); | 6613 Handle<Context> context = Top::global_context(); |
| 6617 | 6614 |
| 6618 // Compile the source to be evaluated. | 6615 // Compile the source to be evaluated. |
| 6619 Handle<JSFunction> boilerplate = | 6616 Handle<JSFunction> boilerplate = |
| 6620 Handle<JSFunction>(Compiler::CompileEval(source, | 6617 Handle<JSFunction>(Compiler::CompileEval(source, |
| 6621 context, | 6618 context, |
| 6622 0, | |
| 6623 true, | 6619 true, |
| 6624 false)); | 6620 false)); |
| 6625 if (boilerplate.is_null()) return Failure::Exception(); | 6621 if (boilerplate.is_null()) return Failure::Exception(); |
| 6626 Handle<JSFunction> compiled_function = | 6622 Handle<JSFunction> compiled_function = |
| 6627 Handle<JSFunction>(Factory::NewFunctionFromBoilerplate(boilerplate, | 6623 Handle<JSFunction>(Factory::NewFunctionFromBoilerplate(boilerplate, |
| 6628 context)); | 6624 context)); |
| 6629 | 6625 |
| 6630 // Invoke the result of the compilation to get the evaluation function. | 6626 // Invoke the result of the compilation to get the evaluation function. |
| 6631 bool has_pending_exception; | 6627 bool has_pending_exception; |
| 6632 Handle<Object> receiver = Top::global(); | 6628 Handle<Object> receiver = Top::global(); |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7083 } else { | 7079 } else { |
| 7084 // Handle last resort GC and make sure to allow future allocations | 7080 // Handle last resort GC and make sure to allow future allocations |
| 7085 // to grow the heap without causing GCs (if possible). | 7081 // to grow the heap without causing GCs (if possible). |
| 7086 Counters::gc_last_resort_from_js.Increment(); | 7082 Counters::gc_last_resort_from_js.Increment(); |
| 7087 Heap::CollectAllGarbage(); | 7083 Heap::CollectAllGarbage(); |
| 7088 } | 7084 } |
| 7089 } | 7085 } |
| 7090 | 7086 |
| 7091 | 7087 |
| 7092 } } // namespace v8::internal | 7088 } } // namespace v8::internal |
| OLD | NEW |