| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 | 131 |
| 132 // Sub-cache for eval scripts. | 132 // Sub-cache for eval scripts. |
| 133 class CompilationCacheEval: public CompilationSubCache { | 133 class CompilationCacheEval: public CompilationSubCache { |
| 134 public: | 134 public: |
| 135 explicit CompilationCacheEval(int generations) | 135 explicit CompilationCacheEval(int generations) |
| 136 : CompilationSubCache(generations) { } | 136 : CompilationSubCache(generations) { } |
| 137 | 137 |
| 138 Handle<SharedFunctionInfo> Lookup(Handle<String> source, | 138 Handle<SharedFunctionInfo> Lookup(Handle<String> source, |
| 139 Handle<Context> context); | 139 Handle<Context> context, |
| 140 bool is_strict); |
| 140 | 141 |
| 141 void Put(Handle<String> source, | 142 void Put(Handle<String> source, |
| 142 Handle<Context> context, | 143 Handle<Context> context, |
| 143 Handle<SharedFunctionInfo> function_info); | 144 Handle<SharedFunctionInfo> function_info); |
| 144 | 145 |
| 145 private: | 146 private: |
| 146 MUST_USE_RESULT MaybeObject* TryTablePut( | 147 MUST_USE_RESULT MaybeObject* TryTablePut( |
| 147 Handle<String> source, | 148 Handle<String> source, |
| 148 Handle<Context> context, | 149 Handle<Context> context, |
| 149 Handle<SharedFunctionInfo> function_info); | 150 Handle<SharedFunctionInfo> function_info); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 365 |
| 365 | 366 |
| 366 void CompilationCacheScript::Put(Handle<String> source, | 367 void CompilationCacheScript::Put(Handle<String> source, |
| 367 Handle<SharedFunctionInfo> function_info) { | 368 Handle<SharedFunctionInfo> function_info) { |
| 368 HandleScope scope; | 369 HandleScope scope; |
| 369 SetFirstTable(TablePut(source, function_info)); | 370 SetFirstTable(TablePut(source, function_info)); |
| 370 } | 371 } |
| 371 | 372 |
| 372 | 373 |
| 373 Handle<SharedFunctionInfo> CompilationCacheEval::Lookup( | 374 Handle<SharedFunctionInfo> CompilationCacheEval::Lookup( |
| 374 Handle<String> source, Handle<Context> context) { | 375 Handle<String> source, Handle<Context> context, bool is_strict) { |
| 375 // Make sure not to leak the table into the surrounding handle | 376 // Make sure not to leak the table into the surrounding handle |
| 376 // scope. Otherwise, we risk keeping old tables around even after | 377 // scope. Otherwise, we risk keeping old tables around even after |
| 377 // having cleared the cache. | 378 // having cleared the cache. |
| 378 Object* result = NULL; | 379 Object* result = NULL; |
| 379 int generation; | 380 int generation; |
| 380 { HandleScope scope; | 381 { HandleScope scope; |
| 381 for (generation = 0; generation < generations(); generation++) { | 382 for (generation = 0; generation < generations(); generation++) { |
| 382 Handle<CompilationCacheTable> table = GetTable(generation); | 383 Handle<CompilationCacheTable> table = GetTable(generation); |
| 383 result = table->LookupEval(*source, *context); | 384 result = table->LookupEval(*source, *context, is_strict); |
| 384 if (result->IsSharedFunctionInfo()) { | 385 if (result->IsSharedFunctionInfo()) { |
| 385 break; | 386 break; |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 } | 389 } |
| 389 if (result->IsSharedFunctionInfo()) { | 390 if (result->IsSharedFunctionInfo()) { |
| 390 Handle<SharedFunctionInfo> | 391 Handle<SharedFunctionInfo> |
| 391 function_info(SharedFunctionInfo::cast(result)); | 392 function_info(SharedFunctionInfo::cast(result)); |
| 392 if (generation != 0) { | 393 if (generation != 0) { |
| 393 Put(source, context, function_info); | 394 Put(source, context, function_info); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 if (!IsEnabled()) { | 499 if (!IsEnabled()) { |
| 499 return Handle<SharedFunctionInfo>::null(); | 500 return Handle<SharedFunctionInfo>::null(); |
| 500 } | 501 } |
| 501 | 502 |
| 502 return script.Lookup(source, name, line_offset, column_offset); | 503 return script.Lookup(source, name, line_offset, column_offset); |
| 503 } | 504 } |
| 504 | 505 |
| 505 | 506 |
| 506 Handle<SharedFunctionInfo> CompilationCache::LookupEval(Handle<String> source, | 507 Handle<SharedFunctionInfo> CompilationCache::LookupEval(Handle<String> source, |
| 507 Handle<Context> context, | 508 Handle<Context> context, |
| 508 bool is_global) { | 509 bool is_global, |
| 510 bool is_strict) { |
| 509 if (!IsEnabled()) { | 511 if (!IsEnabled()) { |
| 510 return Handle<SharedFunctionInfo>::null(); | 512 return Handle<SharedFunctionInfo>::null(); |
| 511 } | 513 } |
| 512 | 514 |
| 513 Handle<SharedFunctionInfo> result; | 515 Handle<SharedFunctionInfo> result; |
| 514 if (is_global) { | 516 if (is_global) { |
| 515 result = eval_global.Lookup(source, context); | 517 result = eval_global.Lookup(source, context, is_strict); |
| 516 } else { | 518 } else { |
| 517 result = eval_contextual.Lookup(source, context); | 519 result = eval_contextual.Lookup(source, context, is_strict); |
| 518 } | 520 } |
| 519 return result; | 521 return result; |
| 520 } | 522 } |
| 521 | 523 |
| 522 | 524 |
| 523 Handle<FixedArray> CompilationCache::LookupRegExp(Handle<String> source, | 525 Handle<FixedArray> CompilationCache::LookupRegExp(Handle<String> source, |
| 524 JSRegExp::Flags flags) { | 526 JSRegExp::Flags flags) { |
| 525 if (!IsEnabled()) { | 527 if (!IsEnabled()) { |
| 526 return Handle<FixedArray>::null(); | 528 return Handle<FixedArray>::null(); |
| 527 } | 529 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 } | 642 } |
| 641 | 643 |
| 642 | 644 |
| 643 void CompilationCache::Disable() { | 645 void CompilationCache::Disable() { |
| 644 enabled = false; | 646 enabled = false; |
| 645 Clear(); | 647 Clear(); |
| 646 } | 648 } |
| 647 | 649 |
| 648 | 650 |
| 649 } } // namespace v8::internal | 651 } } // namespace v8::internal |
| OLD | NEW |