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

Side by Side Diff: src/api.cc

Issue 2490903002: Simplify accesses to Script::line_ends (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 8862 matching lines...) Expand 10 before | Expand all | Expand 10 after
8873 8873
8874 int DebugInterface::Script::LineOffset() const { 8874 int DebugInterface::Script::LineOffset() const {
8875 return Utils::OpenHandle(this)->line_offset(); 8875 return Utils::OpenHandle(this)->line_offset();
8876 } 8876 }
8877 8877
8878 int DebugInterface::Script::ColumnOffset() const { 8878 int DebugInterface::Script::ColumnOffset() const {
8879 return Utils::OpenHandle(this)->column_offset(); 8879 return Utils::OpenHandle(this)->column_offset();
8880 } 8880 }
8881 8881
8882 std::vector<int> DebugInterface::Script::LineEnds() const { 8882 std::vector<int> DebugInterface::Script::LineEnds() const {
8883 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8883 i::Handle<i::Script> script = Utils::OpenHandle(this);
8884 i::Isolate* isolate = script->GetIsolate();
8884 i::HandleScope scope(isolate); 8885 i::HandleScope scope(isolate);
8885 i::Script::InitLineEnds(Utils::OpenHandle(this)); 8886 i::Script::InitLineEnds(script);
8886 i::Handle<i::Object> line_ends_obj(Utils::OpenHandle(this)->line_ends(), 8887 CHECK(script->line_ends()->IsFixedArray());
8887 isolate);
8888 std::vector<int> result; 8888 std::vector<int> result;
8889 if (!line_ends_obj->IsFixedArray()) return result; 8889 i::Handle<i::FixedArray> line_ends(i::FixedArray::cast(script->line_ends()));
8890 i::Handle<i::FixedArray> line_ends =
8891 i::Handle<i::FixedArray>::cast(line_ends_obj);
8892 for (int i = 0; i < line_ends->length(); ++i) { 8890 for (int i = 0; i < line_ends->length(); ++i) {
8893 i::Handle<i::Object> line_end = i::FixedArray::get(*line_ends, i, isolate); 8891 i::Smi* line_end = i::Smi::cast(line_ends->get(i));
8894 if (line_end->IsSmi()) { 8892 result.push_back(line_end->value());
Yang 2016/11/09 09:29:18 since we already know the resulting size of the ve
8895 result.push_back(i::Handle<i::Smi>::cast(line_end)->value());
8896 } else {
8897 result.push_back(0);
8898 }
8899 } 8893 }
8900 return result; 8894 return result;
8901 } 8895 }
8902 8896
8903 MaybeLocal<String> DebugInterface::Script::Name() const { 8897 MaybeLocal<String> DebugInterface::Script::Name() const {
8904 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8898 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8905 i::HandleScope handle_scope(isolate); 8899 i::HandleScope handle_scope(isolate);
8906 i::Handle<i::Script> script = Utils::OpenHandle(this); 8900 i::Handle<i::Script> script = Utils::OpenHandle(this);
8907 i::Handle<i::Object> value(script->name(), isolate); 8901 i::Handle<i::Object> value(script->name(), isolate);
8908 if (!value->IsString()) return MaybeLocal<String>(); 8902 if (!value->IsString()) return MaybeLocal<String>();
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
9770 Address callback_address = 9764 Address callback_address =
9771 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9765 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9772 VMState<EXTERNAL> state(isolate); 9766 VMState<EXTERNAL> state(isolate);
9773 ExternalCallbackScope call_scope(isolate, callback_address); 9767 ExternalCallbackScope call_scope(isolate, callback_address);
9774 callback(info); 9768 callback(info);
9775 } 9769 }
9776 9770
9777 9771
9778 } // namespace internal 9772 } // namespace internal
9779 } // namespace v8 9773 } // namespace v8
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698