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

Side by Side Diff: src/accessors.cc

Issue 2490903002: Simplify accesses to Script::line_ends (Closed)
Patch Set: Address comments 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.h ('k') | src/api.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/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( 462 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo(
463 Isolate* isolate, PropertyAttributes attributes) { 463 Isolate* isolate, PropertyAttributes attributes) {
464 Handle<String> name(isolate->factory()->InternalizeOneByteString( 464 Handle<String> name(isolate->factory()->InternalizeOneByteString(
465 STATIC_CHAR_VECTOR("compilation_type"))); 465 STATIC_CHAR_VECTOR("compilation_type")));
466 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr, 466 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr,
467 attributes); 467 attributes);
468 } 468 }
469 469
470 470
471 // 471 //
472 // Accessors::ScriptGetLineEnds
473 //
474
475
476 void Accessors::ScriptLineEndsGetter(
477 v8::Local<v8::Name> name,
478 const v8::PropertyCallbackInfo<v8::Value>& info) {
479 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
480 HandleScope scope(isolate);
481 Handle<Object> object = Utils::OpenHandle(*info.Holder());
482 Handle<Script> script(
483 Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
484 Script::InitLineEnds(script);
485 DCHECK(script->line_ends()->IsFixedArray());
486 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
487 // We do not want anyone to modify this array from JS.
488 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() ||
489 line_ends->map() == isolate->heap()->fixed_cow_array_map());
490 Handle<JSArray> js_array =
491 isolate->factory()->NewJSArrayWithElements(line_ends);
492 info.GetReturnValue().Set(Utils::ToLocal(js_array));
493 }
494
495
496 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo(
497 Isolate* isolate, PropertyAttributes attributes) {
498 Handle<String> name(isolate->factory()->InternalizeOneByteString(
499 STATIC_CHAR_VECTOR("line_ends")));
500 return MakeAccessor(isolate, name, &ScriptLineEndsGetter, nullptr,
501 attributes);
502 }
503
504
505 //
506 // Accessors::ScriptSourceUrl 472 // Accessors::ScriptSourceUrl
507 // 473 //
508 474
509 475
510 void Accessors::ScriptSourceUrlGetter( 476 void Accessors::ScriptSourceUrlGetter(
511 v8::Local<v8::Name> name, 477 v8::Local<v8::Name> name,
512 const v8::PropertyCallbackInfo<v8::Value>& info) { 478 const v8::PropertyCallbackInfo<v8::Value>& info) {
513 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 479 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
514 DisallowHeapAllocation no_allocation; 480 DisallowHeapAllocation no_allocation;
515 HandleScope scope(isolate); 481 HandleScope scope(isolate);
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, 1251 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate,
1286 PropertyAttributes attributes) { 1252 PropertyAttributes attributes) {
1287 Handle<AccessorInfo> info = 1253 Handle<AccessorInfo> info =
1288 MakeAccessor(isolate, isolate->factory()->stack_string(), 1254 MakeAccessor(isolate, isolate->factory()->stack_string(),
1289 &ErrorStackGetter, &ErrorStackSetter, attributes); 1255 &ErrorStackGetter, &ErrorStackSetter, attributes);
1290 return info; 1256 return info;
1291 } 1257 }
1292 1258
1293 } // namespace internal 1259 } // namespace internal
1294 } // namespace v8 1260 } // namespace v8
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698