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

Side by Side Diff: src/isolate.cc

Issue 14403015: Disallow dereferencing deferred handles when generating optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 500
501 void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) { 501 void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) {
502 for (DeferredHandles* deferred = deferred_handles_head_; 502 for (DeferredHandles* deferred = deferred_handles_head_;
503 deferred != NULL; 503 deferred != NULL;
504 deferred = deferred->next_) { 504 deferred = deferred->next_) {
505 deferred->Iterate(visitor); 505 deferred->Iterate(visitor);
506 } 506 }
507 } 507 }
508 508
509 509
510 #ifdef DEBUG
511 bool Isolate::IsDeferredHandle(Object** handle) {
512 // Each DeferredHandles instance keeps the handles to one job in the
513 // parallel recompilation queue, containing a list of blocks. Each block
514 // contains kHandleBlockSize handles except for the first block, which may
515 // not be fully filled.
516 // We iterate through all the blocks to see whether the argument handle
517 // belongs to one of the blocks. If so, it is deferred.
518 for (DeferredHandles* deferred = deferred_handles_head_;
519 deferred != NULL;
520 deferred = deferred->next_) {
521 List<Object**>* blocks = &deferred->blocks_;
522 if (blocks->first() <= handle &&
523 handle < deferred->first_block_limit_) {
524 return true;
525 }
526 for (int i = 1; i < blocks->length(); i++) {
527 if (blocks->at(i) <= handle &&
528 handle < blocks->at(i) + kHandleBlockSize) {
529 return true;
530 }
531 }
mvstanton 2013/04/23 08:58:50 Why can't the check of the first block in the list
Yang 2013/04/23 09:19:09 Works. Done.
532 }
533 return false;
534 }
535 #endif // DEBUG
536
537
510 void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) { 538 void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) {
511 // The ARM simulator has a separate JS stack. We therefore register 539 // The ARM simulator has a separate JS stack. We therefore register
512 // the C++ try catch handler with the simulator and get back an 540 // the C++ try catch handler with the simulator and get back an
513 // address that can be used for comparisons with addresses into the 541 // address that can be used for comparisons with addresses into the
514 // JS stack. When running without the simulator, the address 542 // JS stack. When running without the simulator, the address
515 // returned will be the address of the C++ try catch handler itself. 543 // returned will be the address of the C++ try catch handler itself.
516 Address address = reinterpret_cast<Address>( 544 Address address = reinterpret_cast<Address>(
517 SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that))); 545 SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that)));
518 thread_local_top()->set_try_catch_handler_address(address); 546 thread_local_top()->set_try_catch_handler_address(address);
519 } 547 }
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 simulator_i_cache_ = NULL; 1778 simulator_i_cache_ = NULL;
1751 simulator_redirection_ = NULL; 1779 simulator_redirection_ = NULL;
1752 #endif 1780 #endif
1753 1781
1754 #ifdef DEBUG 1782 #ifdef DEBUG
1755 // heap_histograms_ initializes itself. 1783 // heap_histograms_ initializes itself.
1756 memset(&js_spill_information_, 0, sizeof(js_spill_information_)); 1784 memset(&js_spill_information_, 0, sizeof(js_spill_information_));
1757 memset(code_kind_statistics_, 0, 1785 memset(code_kind_statistics_, 0,
1758 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS); 1786 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS);
1759 1787
1760 allow_compiler_thread_handle_deref_ = true; 1788 compiler_thread_handle_deref_state_ = HandleDereferenceGuard::ALLOW;
1761 allow_execution_thread_handle_deref_ = true; 1789 execution_thread_handle_deref_state_ = HandleDereferenceGuard::ALLOW;
1762 #endif 1790 #endif
1763 1791
1764 #ifdef ENABLE_DEBUGGER_SUPPORT 1792 #ifdef ENABLE_DEBUGGER_SUPPORT
1765 debug_ = NULL; 1793 debug_ = NULL;
1766 debugger_ = NULL; 1794 debugger_ = NULL;
1767 #endif 1795 #endif
1768 1796
1769 handle_scope_data_.Initialize(); 1797 handle_scope_data_.Initialize();
1770 1798
1771 #define ISOLATE_INIT_EXECUTE(type, name, initial_value) \ 1799 #define ISOLATE_INIT_EXECUTE(type, name, initial_value) \
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 if (deferred->next_ != NULL) { 2400 if (deferred->next_ != NULL) {
2373 deferred->next_->previous_ = deferred->previous_; 2401 deferred->next_->previous_ = deferred->previous_;
2374 } 2402 }
2375 if (deferred->previous_ != NULL) { 2403 if (deferred->previous_ != NULL) {
2376 deferred->previous_->next_ = deferred->next_; 2404 deferred->previous_->next_ = deferred->next_;
2377 } 2405 }
2378 } 2406 }
2379 2407
2380 2408
2381 #ifdef DEBUG 2409 #ifdef DEBUG
2382 bool Isolate::AllowHandleDereference() { 2410 HandleDereferenceGuard::State Isolate::HandleDereferenceGuardState() {
2383 if (allow_execution_thread_handle_deref_ && 2411 if (execution_thread_handle_deref_state_ == HandleDereferenceGuard::ALLOW &&
2384 allow_compiler_thread_handle_deref_) { 2412 compiler_thread_handle_deref_state_ == HandleDereferenceGuard::ALLOW) {
2385 // Short-cut to avoid polling thread id. 2413 // Short-cut to avoid polling thread id.
2386 return true; 2414 return HandleDereferenceGuard::ALLOW;
2387 } 2415 }
2388 if (FLAG_parallel_recompilation && 2416 if (FLAG_parallel_recompilation &&
2389 optimizing_compiler_thread()->IsOptimizerThread()) { 2417 optimizing_compiler_thread()->IsOptimizerThread()) {
2390 return allow_compiler_thread_handle_deref_; 2418 return compiler_thread_handle_deref_state_;
2391 } else { 2419 } else {
2392 return allow_execution_thread_handle_deref_; 2420 return execution_thread_handle_deref_state_;
2393 } 2421 }
2394 } 2422 }
2395 2423
2396 2424
2397 void Isolate::SetAllowHandleDereference(bool allow) { 2425 void Isolate::SetHandleDereferenceGuardState(
2426 HandleDereferenceGuard::State state) {
2398 if (FLAG_parallel_recompilation && 2427 if (FLAG_parallel_recompilation &&
2399 optimizing_compiler_thread()->IsOptimizerThread()) { 2428 optimizing_compiler_thread()->IsOptimizerThread()) {
2400 allow_compiler_thread_handle_deref_ = allow; 2429 compiler_thread_handle_deref_state_ = state;
2401 } else { 2430 } else {
2402 allow_execution_thread_handle_deref_ = allow; 2431 execution_thread_handle_deref_state_ = state;
2403 } 2432 }
2404 } 2433 }
2405 #endif 2434 #endif
2406 2435
2407 2436
2408 HStatistics* Isolate::GetHStatistics() { 2437 HStatistics* Isolate::GetHStatistics() {
2409 if (hstatistics() == NULL) set_hstatistics(new HStatistics()); 2438 if (hstatistics() == NULL) set_hstatistics(new HStatistics());
2410 return hstatistics(); 2439 return hstatistics();
2411 } 2440 }
2412 2441
(...skipping 12 matching lines...) Expand all
2425 2454
2426 #ifdef DEBUG 2455 #ifdef DEBUG
2427 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2456 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2428 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2457 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2429 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2458 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2430 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2459 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2431 #undef ISOLATE_FIELD_OFFSET 2460 #undef ISOLATE_FIELD_OFFSET
2432 #endif 2461 #endif
2433 2462
2434 } } // namespace v8::internal 2463 } } // namespace v8::internal
OLDNEW
« src/ia32/lithium-codegen-ia32.cc ('K') | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698