OLD | NEW |
---|---|
1 // Copyright 2006-2008 Google Inc. All Rights Reserved. | 1 // Copyright 2006-2008 Google Inc. 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 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3321 // through an alias, and the corresponding frame doesn't have a | 3321 // through an alias, and the corresponding frame doesn't have a |
3322 // proper eval context set up. | 3322 // proper eval context set up. |
3323 Object* eval_context = EvalContext(); | 3323 Object* eval_context = EvalContext(); |
3324 if (eval_context->IsFailure()) return eval_context; | 3324 if (eval_context->IsFailure()) return eval_context; |
3325 context = Handle<Context>(Context::cast(eval_context)); | 3325 context = Handle<Context>(Context::cast(eval_context)); |
3326 } else { | 3326 } else { |
3327 context = Handle<Context>(Top::context()->global_context()); | 3327 context = Handle<Context>(Top::context()->global_context()); |
3328 } | 3328 } |
3329 | 3329 |
3330 // Compile eval() source. | 3330 // Compile eval() source. |
3331 bool is_global_context = context->IsGlobalContext(); | |
Kasper Lund
2008/09/05 09:16:29
I think you should move this code to the Compiler
Feng Qian
2008/09/09 03:42:50
Done.
| |
3331 Handle<String> source(String::cast(args[0])); | 3332 Handle<String> source(String::cast(args[0])); |
3332 Handle<JSFunction> boilerplate = | 3333 Object* obj = Heap::LookupEvalCache(is_global_context, *source); |
3333 Compiler::CompileEval(context->IsGlobalContext(), source); | 3334 if (obj->IsFailure()) return obj; |
3334 if (boilerplate.is_null()) return Failure::Exception(); | 3335 |
3336 Handle<JSFunction> boilerplate; | |
3337 if (!obj->IsJSFunction()) { | |
3338 Counters::eval_cache_misses.Increment(); | |
3339 boilerplate = Compiler::CompileEval(is_global_context, source); | |
3340 if (boilerplate.is_null()) return Failure::Exception(); | |
3341 | |
3342 Object* obj = | |
3343 Heap::PutInEvalCache(is_global_context, *source, *boilerplate); | |
3344 if (obj->IsFailure()) return obj; | |
3345 | |
3346 } else { | |
3347 Counters::eval_cache_hits.Increment(); | |
3348 boilerplate = Handle<JSFunction>(JSFunction::cast(obj)); | |
3349 } | |
3350 | |
3335 Handle<JSFunction> fun = | 3351 Handle<JSFunction> fun = |
3336 Factory::NewFunctionFromBoilerplate(boilerplate, context); | 3352 Factory::NewFunctionFromBoilerplate(boilerplate, context); |
3337 return *fun; | 3353 return *fun; |
3338 } | 3354 } |
3339 | 3355 |
3340 | 3356 |
3341 static Object* Runtime_CompileScript(Arguments args) { | 3357 static Object* Runtime_CompileScript(Arguments args) { |
3342 HandleScope scope; | 3358 HandleScope scope; |
3343 ASSERT(args.length() == 4); | 3359 ASSERT(args.length() == 4); |
3344 | 3360 |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4904 | 4920 |
4905 void Runtime::PerformGC(Object* result) { | 4921 void Runtime::PerformGC(Object* result) { |
4906 Failure* failure = Failure::cast(result); | 4922 Failure* failure = Failure::cast(result); |
4907 // Try to do a garbage collection; ignore it if it fails. The C | 4923 // Try to do a garbage collection; ignore it if it fails. The C |
4908 // entry stub will throw an out-of-memory exception in that case. | 4924 // entry stub will throw an out-of-memory exception in that case. |
4909 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); | 4925 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); |
4910 } | 4926 } |
4911 | 4927 |
4912 | 4928 |
4913 } } // namespace v8::internal | 4929 } } // namespace v8::internal |
OLD | NEW |