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

Side by Side Diff: src/liveedit.cc

Issue 6621042: Ensure the result is used for the remaining calls to SetElement... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | « src/handles.h ('k') | 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 29 matching lines...) Expand all
40 #include "scopeinfo.h" 40 #include "scopeinfo.h"
41 #include "scopes.h" 41 #include "scopes.h"
42 42
43 namespace v8 { 43 namespace v8 {
44 namespace internal { 44 namespace internal {
45 45
46 46
47 #ifdef ENABLE_DEBUGGER_SUPPORT 47 #ifdef ENABLE_DEBUGGER_SUPPORT
48 48
49 49
50 void SetElementNonStrict(Handle<JSObject> object,
51 uint32_t index,
52 Handle<Object> value) {
53 // Ignore return value from SetElement. It can only be a failure if there
54 // are element setters causing exceptions and the debugger context has none
55 // of these.
56 Handle<Object> no_failure;
57 no_failure = SetElement(object, index, value, kNonStrictMode);
58 ASSERT(!no_failure.is_null());
59 USE(no_failure);
60 }
61
50 // A simple implementation of dynamic programming algorithm. It solves 62 // A simple implementation of dynamic programming algorithm. It solves
51 // the problem of finding the difference of 2 arrays. It uses a table of results 63 // the problem of finding the difference of 2 arrays. It uses a table of results
52 // of subproblems. Each cell contains a number together with 2-bit flag 64 // of subproblems. Each cell contains a number together with 2-bit flag
53 // that helps building the chunk list. 65 // that helps building the chunk list.
54 class Differencer { 66 class Differencer {
55 public: 67 public:
56 explicit Differencer(Comparator::Input* input) 68 explicit Differencer(Comparator::Input* input)
57 : input_(input), len1_(input->getLength1()), len2_(input->getLength2()) { 69 : input_(input), len1_(input->getLength1()), len2_(input->getLength2()) {
58 buffer_ = NewArray<int>(len1_ * len2_); 70 buffer_ = NewArray<int>(len1_ * len2_);
59 } 71 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 class CompareOutputArrayWriter { 291 class CompareOutputArrayWriter {
280 public: 292 public:
281 CompareOutputArrayWriter() 293 CompareOutputArrayWriter()
282 : array_(Factory::NewJSArray(10)), current_size_(0) {} 294 : array_(Factory::NewJSArray(10)), current_size_(0) {}
283 295
284 Handle<JSArray> GetResult() { 296 Handle<JSArray> GetResult() {
285 return array_; 297 return array_;
286 } 298 }
287 299
288 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { 300 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) {
289 SetElement(array_, 301 SetElementNonStrict(array_,
290 current_size_, 302 current_size_,
291 Handle<Object>(Smi::FromInt(char_pos1)), 303 Handle<Object>(Smi::FromInt(char_pos1)));
292 kNonStrictMode); 304 SetElementNonStrict(array_,
293 SetElement(array_, 305 current_size_ + 1,
294 current_size_ + 1, 306 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)));
295 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)), 307 SetElementNonStrict(array_,
296 kNonStrictMode); 308 current_size_ + 2,
297 SetElement(array_, 309 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)));
298 current_size_ + 2,
299 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)),
300 kNonStrictMode);
301 current_size_ += 3; 310 current_size_ += 3;
302 } 311 }
303 312
304 private: 313 private:
305 Handle<JSArray> array_; 314 Handle<JSArray> array_;
306 int current_size_; 315 int current_size_;
307 }; 316 };
308 317
309 318
310 // Represents 2 strings as 2 arrays of tokens. 319 // Represents 2 strings as 2 arrays of tokens.
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 return S(array_handle); 554 return S(array_handle);
546 } 555 }
547 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { 556 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) {
548 } 557 }
549 Handle<JSArray> GetJSArray() { 558 Handle<JSArray> GetJSArray() {
550 return array_; 559 return array_;
551 } 560 }
552 561
553 protected: 562 protected:
554 void SetField(int field_position, Handle<Object> value) { 563 void SetField(int field_position, Handle<Object> value) {
555 SetElement(array_, field_position, value, kNonStrictMode); 564 SetElementNonStrict(array_, field_position, value);
556 } 565 }
557 void SetSmiValueField(int field_position, int value) { 566 void SetSmiValueField(int field_position, int value) {
558 SetElement(array_, 567 SetElementNonStrict(array_,
559 field_position, 568 field_position,
560 Handle<Smi>(Smi::FromInt(value)), 569 Handle<Smi>(Smi::FromInt(value)));
561 kNonStrictMode);
562 } 570 }
563 Object* GetField(int field_position) { 571 Object* GetField(int field_position) {
564 return array_->GetElementNoExceptionThrown(field_position); 572 return array_->GetElementNoExceptionThrown(field_position);
565 } 573 }
566 int GetSmiValueField(int field_position) { 574 int GetSmiValueField(int field_position) {
567 Object* res = GetField(field_position); 575 Object* res = GetField(field_position);
568 return Smi::cast(res)->value(); 576 return Smi::cast(res)->value();
569 } 577 }
570 578
571 private: 579 private:
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 result_ = Factory::NewJSArray(10); 698 result_ = Factory::NewJSArray(10);
691 } 699 }
692 700
693 void FunctionStarted(FunctionLiteral* fun) { 701 void FunctionStarted(FunctionLiteral* fun) {
694 HandleScope scope; 702 HandleScope scope;
695 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); 703 FunctionInfoWrapper info = FunctionInfoWrapper::Create();
696 info.SetInitialProperties(fun->name(), fun->start_position(), 704 info.SetInitialProperties(fun->name(), fun->start_position(),
697 fun->end_position(), fun->num_parameters(), 705 fun->end_position(), fun->num_parameters(),
698 current_parent_index_); 706 current_parent_index_);
699 current_parent_index_ = len_; 707 current_parent_index_ = len_;
700 SetElement(result_, len_, info.GetJSArray(), kNonStrictMode); 708 SetElementNonStrict(result_, len_, info.GetJSArray());
701 len_++; 709 len_++;
702 } 710 }
703 711
704 void FunctionDone() { 712 void FunctionDone() {
705 HandleScope scope; 713 HandleScope scope;
706 FunctionInfoWrapper info = 714 FunctionInfoWrapper info =
707 FunctionInfoWrapper::cast( 715 FunctionInfoWrapper::cast(
708 result_->GetElementNoExceptionThrown(current_parent_index_)); 716 result_->GetElementNoExceptionThrown(current_parent_index_));
709 current_parent_index_ = info.GetParentIndex(); 717 current_parent_index_ = info.GetParentIndex();
710 } 718 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 for (int k = 1; k < j; k++) { 778 for (int k = 1; k < j; k++) {
771 int l = k; 779 int l = k;
772 for (int m = k + 1; m < j; m++) { 780 for (int m = k + 1; m < j; m++) {
773 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { 781 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) {
774 l = m; 782 l = m;
775 } 783 }
776 } 784 }
777 list[k] = list[l]; 785 list[k] = list[l];
778 } 786 }
779 for (int i = 0; i < j; i++) { 787 for (int i = 0; i < j; i++) {
780 SetElement(scope_info_list, scope_info_length, 788 SetElementNonStrict(scope_info_list,
781 list[i]->name(), kNonStrictMode); 789 scope_info_length,
790 list[i]->name());
782 scope_info_length++; 791 scope_info_length++;
783 SetElement(scope_info_list, scope_info_length, 792 SetElementNonStrict(
784 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())), 793 scope_info_list,
785 kNonStrictMode); 794 scope_info_length,
795 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())));
786 scope_info_length++; 796 scope_info_length++;
787 } 797 }
788 SetElement(scope_info_list, scope_info_length, 798 SetElementNonStrict(scope_info_list,
789 Handle<Object>(Heap::null_value()), kNonStrictMode); 799 scope_info_length,
800 Handle<Object>(Heap::null_value()));
790 scope_info_length++; 801 scope_info_length++;
791 802
792 outer_scope = outer_scope->outer_scope(); 803 outer_scope = outer_scope->outer_scope();
793 } while (outer_scope != NULL); 804 } while (outer_scope != NULL);
794 805
795 return *scope_info_list; 806 return *scope_info_list;
796 } 807 }
797 808
798 Handle<JSArray> result_; 809 Handle<JSArray> result_;
799 int len_; 810 int len_;
(...skipping 22 matching lines...) Expand all
822 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { 833 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
823 HandleScope scope; 834 HandleScope scope;
824 int len = Smi::cast(array->length())->value(); 835 int len = Smi::cast(array->length())->value();
825 for (int i = 0; i < len; i++) { 836 for (int i = 0; i < len; i++) {
826 Handle<SharedFunctionInfo> info( 837 Handle<SharedFunctionInfo> info(
827 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); 838 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i)));
828 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); 839 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create();
829 Handle<String> name_handle(String::cast(info->name())); 840 Handle<String> name_handle(String::cast(info->name()));
830 info_wrapper.SetProperties(name_handle, info->start_position(), 841 info_wrapper.SetProperties(name_handle, info->start_position(),
831 info->end_position(), info); 842 info->end_position(), info);
832 SetElement(array, i, info_wrapper.GetJSArray(), kNonStrictMode); 843 SetElementNonStrict(array, i, info_wrapper.GetJSArray());
833 } 844 }
834 } 845 }
835 846
836 847
837 // Visitor that collects all references to a particular code object, 848 // Visitor that collects all references to a particular code object,
838 // including "CODE_TARGET" references in other code objects. 849 // including "CODE_TARGET" references in other code objects.
839 // It works in context of ZoneScope. 850 // It works in context of ZoneScope.
840 class ReferenceCollectorVisitor : public ObjectVisitor { 851 class ReferenceCollectorVisitor : public ObjectVisitor {
841 public: 852 public:
842 explicit ReferenceCollectorVisitor(Code* original) 853 explicit ReferenceCollectorVisitor(Code* original)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); 1331 JSFunction::cast(JavaScriptFrame::cast(frame)->function()));
1321 1332
1322 int len = Smi::cast(shared_info_array->length())->value(); 1333 int len = Smi::cast(shared_info_array->length())->value();
1323 for (int i = 0; i < len; i++) { 1334 for (int i = 0; i < len; i++) {
1324 JSValue* wrapper = 1335 JSValue* wrapper =
1325 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); 1336 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i));
1326 Handle<SharedFunctionInfo> shared( 1337 Handle<SharedFunctionInfo> shared(
1327 SharedFunctionInfo::cast(wrapper->value())); 1338 SharedFunctionInfo::cast(wrapper->value()));
1328 1339
1329 if (function->shared() == *shared || IsInlined(*function, *shared)) { 1340 if (function->shared() == *shared || IsInlined(*function, *shared)) {
1330 SetElement(result, i, Handle<Smi>(Smi::FromInt(status)), kNonStrictMode); 1341 SetElementNonStrict(result, i, Handle<Smi>(Smi::FromInt(status)));
1331 return true; 1342 return true;
1332 } 1343 }
1333 } 1344 }
1334 return false; 1345 return false;
1335 } 1346 }
1336 1347
1337 1348
1338 // Iterates over handler chain and removes all elements that are inside 1349 // Iterates over handler chain and removes all elements that are inside
1339 // frames being dropped. 1350 // frames being dropped.
1340 static bool FixTryCatchHandler(StackFrame* top_frame, 1351 static bool FixTryCatchHandler(StackFrame* top_frame,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 } 1536 }
1526 Debug::FramesHaveBeenDropped(new_id, drop_mode, 1537 Debug::FramesHaveBeenDropped(new_id, drop_mode,
1527 restarter_frame_function_pointer); 1538 restarter_frame_function_pointer);
1528 1539
1529 // Replace "blocked on active" with "replaced on active" status. 1540 // Replace "blocked on active" with "replaced on active" status.
1530 for (int i = 0; i < array_len; i++) { 1541 for (int i = 0; i < array_len; i++) {
1531 if (result->GetElement(i) == 1542 if (result->GetElement(i) ==
1532 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { 1543 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
1533 Handle<Object> replaced( 1544 Handle<Object> replaced(
1534 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); 1545 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK));
1535 SetElement(result, i, replaced, kNonStrictMode); 1546 SetElementNonStrict(result, i, replaced);
1536 } 1547 }
1537 } 1548 }
1538 return NULL; 1549 return NULL;
1539 } 1550 }
1540 1551
1541 1552
1542 class InactiveThreadActivationsChecker : public ThreadVisitor { 1553 class InactiveThreadActivationsChecker : public ThreadVisitor {
1543 public: 1554 public:
1544 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, 1555 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array,
1545 Handle<JSArray> result) 1556 Handle<JSArray> result)
(...skipping 19 matching lines...) Expand all
1565 1576
1566 1577
1567 Handle<JSArray> LiveEdit::CheckAndDropActivations( 1578 Handle<JSArray> LiveEdit::CheckAndDropActivations(
1568 Handle<JSArray> shared_info_array, bool do_drop) { 1579 Handle<JSArray> shared_info_array, bool do_drop) {
1569 int len = Smi::cast(shared_info_array->length())->value(); 1580 int len = Smi::cast(shared_info_array->length())->value();
1570 1581
1571 Handle<JSArray> result = Factory::NewJSArray(len); 1582 Handle<JSArray> result = Factory::NewJSArray(len);
1572 1583
1573 // Fill the default values. 1584 // Fill the default values.
1574 for (int i = 0; i < len; i++) { 1585 for (int i = 0; i < len; i++) {
1575 SetElement(result, i, 1586 SetElementNonStrict(
1576 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)), 1587 result,
1577 kNonStrictMode); 1588 i,
1589 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)));
1578 } 1590 }
1579 1591
1580 1592
1581 // First check inactive threads. Fail if some functions are blocked there. 1593 // First check inactive threads. Fail if some functions are blocked there.
1582 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, 1594 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array,
1583 result); 1595 result);
1584 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); 1596 ThreadManager::IterateArchivedThreads(&inactive_threads_checker);
1585 if (inactive_threads_checker.HasBlockedFunctions()) { 1597 if (inactive_threads_checker.HasBlockedFunctions()) {
1586 return result; 1598 return result;
1587 } 1599 }
1588 1600
1589 // Try to drop activations from the current stack. 1601 // Try to drop activations from the current stack.
1590 const char* error_message = 1602 const char* error_message =
1591 DropActivationsInActiveThread(shared_info_array, result, do_drop); 1603 DropActivationsInActiveThread(shared_info_array, result, do_drop);
1592 if (error_message != NULL) { 1604 if (error_message != NULL) {
1593 // Add error message as an array extra element. 1605 // Add error message as an array extra element.
1594 Vector<const char> vector_message(error_message, StrLength(error_message)); 1606 Vector<const char> vector_message(error_message, StrLength(error_message));
1595 Handle<String> str = Factory::NewStringFromAscii(vector_message); 1607 Handle<String> str = Factory::NewStringFromAscii(vector_message);
1596 SetElement(result, len, str, kNonStrictMode); 1608 SetElementNonStrict(result, len, str);
1597 } 1609 }
1598 return result; 1610 return result;
1599 } 1611 }
1600 1612
1601 1613
1602 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { 1614 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) {
1603 if (active_function_info_listener != NULL) { 1615 if (active_function_info_listener != NULL) {
1604 active_function_info_listener->FunctionStarted(fun); 1616 active_function_info_listener->FunctionStarted(fun);
1605 } 1617 }
1606 } 1618 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 1666
1655 bool LiveEditFunctionTracker::IsActive() { 1667 bool LiveEditFunctionTracker::IsActive() {
1656 return false; 1668 return false;
1657 } 1669 }
1658 1670
1659 #endif // ENABLE_DEBUGGER_SUPPORT 1671 #endif // ENABLE_DEBUGGER_SUPPORT
1660 1672
1661 1673
1662 1674
1663 } } // namespace v8::internal 1675 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698