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

Side by Side Diff: src/runtime.cc

Issue 165446: Fixed issue 19212 (Closed)
Patch Set: Fixed lint problem Created 11 years, 4 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/compiler.cc ('k') | test/mjsunit/json.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 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 4955 matching lines...) Expand 10 before | Expand all | Expand 10 after
4966 4966
4967 4967
4968 static Object* Runtime_CompileString(Arguments args) { 4968 static Object* Runtime_CompileString(Arguments args) {
4969 HandleScope scope; 4969 HandleScope scope;
4970 ASSERT_EQ(2, args.length()); 4970 ASSERT_EQ(2, args.length());
4971 CONVERT_ARG_CHECKED(String, source, 0); 4971 CONVERT_ARG_CHECKED(String, source, 0);
4972 CONVERT_ARG_CHECKED(Oddball, is_json, 1) 4972 CONVERT_ARG_CHECKED(Oddball, is_json, 1)
4973 4973
4974 // Compile source string in the global context. 4974 // Compile source string in the global context.
4975 Handle<Context> context(Top::context()->global_context()); 4975 Handle<Context> context(Top::context()->global_context());
4976 Compiler::ValidationState validate = (is_json->IsTrue())
4977 ? Compiler::VALIDATE_JSON : Compiler::DONT_VALIDATE_JSON;
4976 Handle<JSFunction> boilerplate = Compiler::CompileEval(source, 4978 Handle<JSFunction> boilerplate = Compiler::CompileEval(source,
4977 context, 4979 context,
4978 true, 4980 true,
4979 is_json->IsTrue()); 4981 validate);
4980 if (boilerplate.is_null()) return Failure::Exception(); 4982 if (boilerplate.is_null()) return Failure::Exception();
4981 Handle<JSFunction> fun = 4983 Handle<JSFunction> fun =
4982 Factory::NewFunctionFromBoilerplate(boilerplate, context); 4984 Factory::NewFunctionFromBoilerplate(boilerplate, context);
4983 return *fun; 4985 return *fun;
4984 } 4986 }
4985 4987
4986 4988
4987 static Handle<JSFunction> GetBuiltinFunction(String* name) { 4989 static Handle<JSFunction> GetBuiltinFunction(String* name) {
4988 LookupResult result; 4990 LookupResult result;
4989 Top::global_context()->builtins()->LocalLookup(name, &result); 4991 Top::global_context()->builtins()->LocalLookup(name, &result);
4990 return Handle<JSFunction>(JSFunction::cast(result.GetValue())); 4992 return Handle<JSFunction>(JSFunction::cast(result.GetValue()));
4991 } 4993 }
4992 4994
4993 4995
4994 static Object* CompileDirectEval(Handle<String> source) { 4996 static Object* CompileDirectEval(Handle<String> source) {
4995 // Compute the eval context. 4997 // Compute the eval context.
4996 HandleScope scope; 4998 HandleScope scope;
4997 StackFrameLocator locator; 4999 StackFrameLocator locator;
4998 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 5000 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
4999 Handle<Context> context(Context::cast(frame->context())); 5001 Handle<Context> context(Context::cast(frame->context()));
5000 bool is_global = context->IsGlobalContext(); 5002 bool is_global = context->IsGlobalContext();
5001 5003
5002 // Compile source string in the current context. 5004 // Compile source string in the current context.
5003 Handle<JSFunction> boilerplate = 5005 Handle<JSFunction> boilerplate = Compiler::CompileEval(
5004 Compiler::CompileEval(source, context, is_global, false); 5006 source,
5007 context,
5008 is_global,
5009 Compiler::DONT_VALIDATE_JSON);
5005 if (boilerplate.is_null()) return Failure::Exception(); 5010 if (boilerplate.is_null()) return Failure::Exception();
5006 Handle<JSFunction> fun = 5011 Handle<JSFunction> fun =
5007 Factory::NewFunctionFromBoilerplate(boilerplate, context); 5012 Factory::NewFunctionFromBoilerplate(boilerplate, context);
5008 return *fun; 5013 return *fun;
5009 } 5014 }
5010 5015
5011 5016
5012 static Object* Runtime_ResolvePossiblyDirectEval(Arguments args) { 5017 static Object* Runtime_ResolvePossiblyDirectEval(Arguments args) {
5013 ASSERT(args.length() == 2); 5018 ASSERT(args.length() == 2);
5014 5019
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
7036 static const char* source_str = 7041 static const char* source_str =
7037 "function(arguments,__source__){return eval(__source__);}"; 7042 "function(arguments,__source__){return eval(__source__);}";
7038 static const int source_str_length = strlen(source_str); 7043 static const int source_str_length = strlen(source_str);
7039 Handle<String> function_source = 7044 Handle<String> function_source =
7040 Factory::NewStringFromAscii(Vector<const char>(source_str, 7045 Factory::NewStringFromAscii(Vector<const char>(source_str,
7041 source_str_length)); 7046 source_str_length));
7042 Handle<JSFunction> boilerplate = 7047 Handle<JSFunction> boilerplate =
7043 Compiler::CompileEval(function_source, 7048 Compiler::CompileEval(function_source,
7044 context, 7049 context,
7045 context->IsGlobalContext(), 7050 context->IsGlobalContext(),
7046 false); 7051 Compiler::DONT_VALIDATE_JSON);
7047 if (boilerplate.is_null()) return Failure::Exception(); 7052 if (boilerplate.is_null()) return Failure::Exception();
7048 Handle<JSFunction> compiled_function = 7053 Handle<JSFunction> compiled_function =
7049 Factory::NewFunctionFromBoilerplate(boilerplate, context); 7054 Factory::NewFunctionFromBoilerplate(boilerplate, context);
7050 7055
7051 // Invoke the result of the compilation to get the evaluation function. 7056 // Invoke the result of the compilation to get the evaluation function.
7052 bool has_pending_exception; 7057 bool has_pending_exception;
7053 Handle<Object> receiver(frame->receiver()); 7058 Handle<Object> receiver(frame->receiver());
7054 Handle<Object> evaluation_function = 7059 Handle<Object> evaluation_function =
7055 Execution::Call(compiled_function, receiver, 0, NULL, 7060 Execution::Call(compiled_function, receiver, 0, NULL,
7056 &has_pending_exception); 7061 &has_pending_exception);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
7104 7109
7105 // Get the global context now set to the top context from before the 7110 // Get the global context now set to the top context from before the
7106 // debugger was invoked. 7111 // debugger was invoked.
7107 Handle<Context> context = Top::global_context(); 7112 Handle<Context> context = Top::global_context();
7108 7113
7109 // Compile the source to be evaluated. 7114 // Compile the source to be evaluated.
7110 Handle<JSFunction> boilerplate = 7115 Handle<JSFunction> boilerplate =
7111 Handle<JSFunction>(Compiler::CompileEval(source, 7116 Handle<JSFunction>(Compiler::CompileEval(source,
7112 context, 7117 context,
7113 true, 7118 true,
7114 false)); 7119 Compiler::DONT_VALIDATE_JSON));
7115 if (boilerplate.is_null()) return Failure::Exception(); 7120 if (boilerplate.is_null()) return Failure::Exception();
7116 Handle<JSFunction> compiled_function = 7121 Handle<JSFunction> compiled_function =
7117 Handle<JSFunction>(Factory::NewFunctionFromBoilerplate(boilerplate, 7122 Handle<JSFunction>(Factory::NewFunctionFromBoilerplate(boilerplate,
7118 context)); 7123 context));
7119 7124
7120 // Invoke the result of the compilation to get the evaluation function. 7125 // Invoke the result of the compilation to get the evaluation function.
7121 bool has_pending_exception; 7126 bool has_pending_exception;
7122 Handle<Object> receiver = Top::global(); 7127 Handle<Object> receiver = Top::global();
7123 Handle<Object> result = 7128 Handle<Object> result =
7124 Execution::Call(compiled_function, receiver, 0, NULL, 7129 Execution::Call(compiled_function, receiver, 0, NULL,
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
7601 } else { 7606 } else {
7602 // Handle last resort GC and make sure to allow future allocations 7607 // Handle last resort GC and make sure to allow future allocations
7603 // to grow the heap without causing GCs (if possible). 7608 // to grow the heap without causing GCs (if possible).
7604 Counters::gc_last_resort_from_js.Increment(); 7609 Counters::gc_last_resort_from_js.Increment();
7605 Heap::CollectAllGarbage(); 7610 Heap::CollectAllGarbage();
7606 } 7611 }
7607 } 7612 }
7608 7613
7609 7614
7610 } } // namespace v8::internal 7615 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | test/mjsunit/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698