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

Side by Side Diff: src/api.cc

Issue 155685: Make sure we don't crash if NewProxy returns an empty handle (only... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 return pointer; 2473 return pointer;
2474 } 2474 }
2475 2475
2476 // Read from uninitialized field. 2476 // Read from uninitialized field.
2477 if (!pointer->IsProxy()) { 2477 if (!pointer->IsProxy()) {
2478 // Play safe even if it's something unexpected. 2478 // Play safe even if it's something unexpected.
2479 ASSERT(pointer->IsUndefined()); 2479 ASSERT(pointer->IsUndefined());
2480 return NULL; 2480 return NULL;
2481 } 2481 }
2482 2482
2483 // Unaligned native pointer 2483 // Unaligned native pointer.
2484 return reinterpret_cast<void*>(i::Proxy::cast(pointer)->proxy()); 2484 return reinterpret_cast<void*>(i::Proxy::cast(pointer)->proxy());
2485 } 2485 }
2486 2486
2487 2487
2488 void v8::Object::SetPointerInInternalField(int index, void* value) { 2488 void v8::Object::SetPointerInInternalField(int index, void* value) {
2489 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 2489 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
2490 i::Object* as_object = reinterpret_cast<i::Object*>(value); 2490 i::Object* as_object = reinterpret_cast<i::Object*>(value);
2491 if (as_object->IsSmi()) { 2491 if (as_object->IsSmi()) {
2492 // Aligned pointer, store as is. 2492 // Aligned pointer, store as is.
2493 obj->SetInternalField(index, as_object); 2493 obj->SetInternalField(index, as_object);
2494 } else { 2494 } else {
2495 // Currently internal fields are used by DOM wrappers which 2495 // Currently internal fields are used by DOM wrappers which only
2496 // only get GCed by the mark-sweep collector, 2496 // get garbage collected by the mark-sweep collector, so we
2497 // so let's put proxy into old space. 2497 // pretenure the proxy.
2498 i::Proxy* proxy = *i::Factory::NewProxy(reinterpret_cast<i::Address>(value), 2498 i::Handle<i::Proxy> proxy =
2499 i::TENURED); 2499 i::Factory::NewProxy(reinterpret_cast<i::Address>(value), i::TENURED);
2500 obj->SetInternalField(index, proxy); 2500 if (!proxy.is_null()) obj->SetInternalField(index, *proxy);
2501 } 2501 }
2502 } 2502 }
2503 2503
2504 2504
2505 // --- E n v i r o n m e n t --- 2505 // --- E n v i r o n m e n t ---
2506 2506
2507 bool v8::V8::Initialize() { 2507 bool v8::V8::Initialize() {
2508 if (i::V8::IsRunning()) return true; 2508 if (i::V8::IsRunning()) return true;
2509 ENTER_V8; 2509 ENTER_V8;
2510 HandleScope scope; 2510 HandleScope scope;
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
3563 reinterpret_cast<HandleScopeImplementer*>(storage); 3563 reinterpret_cast<HandleScopeImplementer*>(storage);
3564 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 3564 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3565 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 3565 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3566 &thread_local->handle_scope_data_; 3566 &thread_local->handle_scope_data_;
3567 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 3567 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3568 3568
3569 return storage + ArchiveSpacePerThread(); 3569 return storage + ArchiveSpacePerThread();
3570 } 3570 }
3571 3571
3572 } } // namespace v8::internal 3572 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698