OLD | NEW |
---|---|
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 case JS_DATA_VIEW_TYPE: | 127 case JS_DATA_VIEW_TYPE: |
128 return CheckForName(name, isolate->factory()->byte_length_string(), | 128 return CheckForName(name, isolate->factory()->byte_length_string(), |
129 JSDataView::kByteLengthOffset, object_offset) || | 129 JSDataView::kByteLengthOffset, object_offset) || |
130 CheckForName(name, isolate->factory()->byte_offset_string(), | 130 CheckForName(name, isolate->factory()->byte_offset_string(), |
131 JSDataView::kByteOffsetOffset, object_offset); | 131 JSDataView::kByteOffsetOffset, object_offset); |
132 default: | 132 default: |
133 return false; | 133 return false; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 MUST_USE_RESULT static MaybeHandle<Object> ReplaceAccessorWithDataProperty( | 137 namespace { |
138 Isolate* isolate, Handle<JSObject> receiver, Handle<JSObject> holder, | 138 |
139 MUST_USE_RESULT MaybeHandle<Object> ReplaceAccessorWithDataProperty( | |
140 Isolate* isolate, Handle<Object> receiver, Handle<JSObject> holder, | |
139 Handle<Name> name, Handle<Object> value) { | 141 Handle<Name> name, Handle<Object> value) { |
140 LookupIterator it(receiver, name, holder, | 142 LookupIterator it(receiver, name, holder, |
141 LookupIterator::OWN_SKIP_INTERCEPTOR); | 143 LookupIterator::OWN_SKIP_INTERCEPTOR); |
142 // Skip any access checks we might hit. This accessor should never hit in a | 144 // Skip any access checks we might hit. This accessor should never hit in a |
143 // situation where the caller does not have access. | 145 // situation where the caller does not have access. |
144 if (it.state() == LookupIterator::ACCESS_CHECK) { | 146 if (it.state() == LookupIterator::ACCESS_CHECK) { |
145 CHECK(it.HasAccess()); | 147 CHECK(it.HasAccess()); |
146 it.Next(); | 148 it.Next(); |
147 } | 149 } |
148 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); | 150 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
149 it.ReconfigureDataProperty(value, it.property_attributes()); | 151 it.ReconfigureDataProperty(value, it.property_attributes()); |
150 return value; | 152 return value; |
151 } | 153 } |
152 | 154 |
155 } // namespace | |
156 | |
153 void Accessors::ReconfigureToDataProperty( | 157 void Accessors::ReconfigureToDataProperty( |
154 v8::Local<v8::Name> key, v8::Local<v8::Value> val, | 158 v8::Local<v8::Name> key, v8::Local<v8::Value> val, |
155 const v8::PropertyCallbackInfo<void>& info) { | 159 const v8::PropertyCallbackInfo<void>& info) { |
156 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 160 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
157 HandleScope scope(isolate); | 161 HandleScope scope(isolate); |
158 Handle<JSObject> receiver = | 162 Handle<Object> receiver = Utils::OpenHandle(*info.This()); |
jochen (gone - plz use gerrit)
2016/05/09 08:56:26
since this is set through the external API, receiv
| |
159 Handle<JSObject>::cast(Utils::OpenHandle(*info.This())); | |
160 Handle<JSObject> holder = | 163 Handle<JSObject> holder = |
161 Handle<JSObject>::cast(Utils::OpenHandle(*info.Holder())); | 164 Handle<JSObject>::cast(Utils::OpenHandle(*info.Holder())); |
162 Handle<Name> name = Utils::OpenHandle(*key); | 165 Handle<Name> name = Utils::OpenHandle(*key); |
163 Handle<Object> value = Utils::OpenHandle(*val); | 166 Handle<Object> value = Utils::OpenHandle(*val); |
164 MaybeHandle<Object> result = | 167 MaybeHandle<Object> result = |
165 ReplaceAccessorWithDataProperty(isolate, receiver, holder, name, value); | 168 ReplaceAccessorWithDataProperty(isolate, receiver, holder, name, value); |
166 if (result.is_null()) isolate->OptionalRescheduleException(false); | 169 if (result.is_null()) isolate->OptionalRescheduleException(false); |
167 } | 170 } |
168 | 171 |
169 // | 172 // |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 } | 209 } |
207 | 210 |
208 | 211 |
209 void Accessors::ArrayLengthSetter( | 212 void Accessors::ArrayLengthSetter( |
210 v8::Local<v8::Name> name, | 213 v8::Local<v8::Name> name, |
211 v8::Local<v8::Value> val, | 214 v8::Local<v8::Value> val, |
212 const v8::PropertyCallbackInfo<void>& info) { | 215 const v8::PropertyCallbackInfo<void>& info) { |
213 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 216 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
214 HandleScope scope(isolate); | 217 HandleScope scope(isolate); |
215 | 218 |
216 Handle<JSReceiver> object = Utils::OpenHandle(*info.This()); | 219 Handle<JSReceiver> object = Utils::OpenHandle(*info.Holder()); |
217 Handle<JSArray> array = Handle<JSArray>::cast(object); | 220 Handle<JSArray> array = Handle<JSArray>::cast(object); |
218 Handle<Object> length_obj = Utils::OpenHandle(*val); | 221 Handle<Object> length_obj = Utils::OpenHandle(*val); |
219 | 222 |
220 uint32_t length = 0; | 223 uint32_t length = 0; |
221 if (!JSArray::AnythingToArrayLength(isolate, length_obj, &length)) { | 224 if (!JSArray::AnythingToArrayLength(isolate, length_obj, &length)) { |
222 isolate->OptionalRescheduleException(false); | 225 isolate->OptionalRescheduleException(false); |
223 return; | 226 return; |
224 } | 227 } |
225 | 228 |
226 JSArray::SetLength(array, length); | 229 JSArray::SetLength(array, length); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 // Accessors::ScriptColumnOffset | 291 // Accessors::ScriptColumnOffset |
289 // | 292 // |
290 | 293 |
291 | 294 |
292 void Accessors::ScriptColumnOffsetGetter( | 295 void Accessors::ScriptColumnOffsetGetter( |
293 v8::Local<v8::Name> name, | 296 v8::Local<v8::Name> name, |
294 const v8::PropertyCallbackInfo<v8::Value>& info) { | 297 const v8::PropertyCallbackInfo<v8::Value>& info) { |
295 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 298 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
296 DisallowHeapAllocation no_allocation; | 299 DisallowHeapAllocation no_allocation; |
297 HandleScope scope(isolate); | 300 HandleScope scope(isolate); |
298 Object* object = *Utils::OpenHandle(*info.This()); | 301 Object* object = *Utils::OpenHandle(*info.Holder()); |
299 Object* res = Smi::FromInt( | 302 Object* res = Smi::FromInt( |
300 Script::cast(JSValue::cast(object)->value())->column_offset()); | 303 Script::cast(JSValue::cast(object)->value())->column_offset()); |
301 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 304 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
302 } | 305 } |
303 | 306 |
304 | 307 |
305 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( | 308 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( |
306 Isolate* isolate, PropertyAttributes attributes) { | 309 Isolate* isolate, PropertyAttributes attributes) { |
307 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 310 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
308 STATIC_CHAR_VECTOR("column_offset"))); | 311 STATIC_CHAR_VECTOR("column_offset"))); |
309 return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr, | 312 return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr, |
310 attributes); | 313 attributes); |
311 } | 314 } |
312 | 315 |
313 | 316 |
314 // | 317 // |
315 // Accessors::ScriptId | 318 // Accessors::ScriptId |
316 // | 319 // |
317 | 320 |
318 | 321 |
319 void Accessors::ScriptIdGetter( | 322 void Accessors::ScriptIdGetter( |
320 v8::Local<v8::Name> name, | 323 v8::Local<v8::Name> name, |
321 const v8::PropertyCallbackInfo<v8::Value>& info) { | 324 const v8::PropertyCallbackInfo<v8::Value>& info) { |
322 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 325 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
323 DisallowHeapAllocation no_allocation; | 326 DisallowHeapAllocation no_allocation; |
324 HandleScope scope(isolate); | 327 HandleScope scope(isolate); |
325 Object* object = *Utils::OpenHandle(*info.This()); | 328 Object* object = *Utils::OpenHandle(*info.Holder()); |
326 Object* id = Smi::FromInt(Script::cast(JSValue::cast(object)->value())->id()); | 329 Object* id = Smi::FromInt(Script::cast(JSValue::cast(object)->value())->id()); |
327 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); | 330 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); |
328 } | 331 } |
329 | 332 |
330 | 333 |
331 Handle<AccessorInfo> Accessors::ScriptIdInfo( | 334 Handle<AccessorInfo> Accessors::ScriptIdInfo( |
332 Isolate* isolate, PropertyAttributes attributes) { | 335 Isolate* isolate, PropertyAttributes attributes) { |
333 Handle<String> name( | 336 Handle<String> name( |
334 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); | 337 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); |
335 return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes); | 338 return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes); |
336 } | 339 } |
337 | 340 |
338 | 341 |
339 // | 342 // |
340 // Accessors::ScriptName | 343 // Accessors::ScriptName |
341 // | 344 // |
342 | 345 |
343 | 346 |
344 void Accessors::ScriptNameGetter( | 347 void Accessors::ScriptNameGetter( |
345 v8::Local<v8::Name> name, | 348 v8::Local<v8::Name> name, |
346 const v8::PropertyCallbackInfo<v8::Value>& info) { | 349 const v8::PropertyCallbackInfo<v8::Value>& info) { |
347 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 350 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
348 DisallowHeapAllocation no_allocation; | 351 DisallowHeapAllocation no_allocation; |
349 HandleScope scope(isolate); | 352 HandleScope scope(isolate); |
350 Object* object = *Utils::OpenHandle(*info.This()); | 353 Object* object = *Utils::OpenHandle(*info.Holder()); |
351 Object* source = Script::cast(JSValue::cast(object)->value())->name(); | 354 Object* source = Script::cast(JSValue::cast(object)->value())->name(); |
352 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 355 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
353 } | 356 } |
354 | 357 |
355 | 358 |
356 Handle<AccessorInfo> Accessors::ScriptNameInfo( | 359 Handle<AccessorInfo> Accessors::ScriptNameInfo( |
357 Isolate* isolate, PropertyAttributes attributes) { | 360 Isolate* isolate, PropertyAttributes attributes) { |
358 return MakeAccessor(isolate, isolate->factory()->name_string(), | 361 return MakeAccessor(isolate, isolate->factory()->name_string(), |
359 &ScriptNameGetter, nullptr, attributes); | 362 &ScriptNameGetter, nullptr, attributes); |
360 } | 363 } |
361 | 364 |
362 | 365 |
363 // | 366 // |
364 // Accessors::ScriptSource | 367 // Accessors::ScriptSource |
365 // | 368 // |
366 | 369 |
367 | 370 |
368 void Accessors::ScriptSourceGetter( | 371 void Accessors::ScriptSourceGetter( |
369 v8::Local<v8::Name> name, | 372 v8::Local<v8::Name> name, |
370 const v8::PropertyCallbackInfo<v8::Value>& info) { | 373 const v8::PropertyCallbackInfo<v8::Value>& info) { |
371 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 374 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
372 DisallowHeapAllocation no_allocation; | 375 DisallowHeapAllocation no_allocation; |
373 HandleScope scope(isolate); | 376 HandleScope scope(isolate); |
374 Object* object = *Utils::OpenHandle(*info.This()); | 377 Object* object = *Utils::OpenHandle(*info.Holder()); |
375 Object* source = Script::cast(JSValue::cast(object)->value())->source(); | 378 Object* source = Script::cast(JSValue::cast(object)->value())->source(); |
376 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 379 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
377 } | 380 } |
378 | 381 |
379 | 382 |
380 Handle<AccessorInfo> Accessors::ScriptSourceInfo( | 383 Handle<AccessorInfo> Accessors::ScriptSourceInfo( |
381 Isolate* isolate, PropertyAttributes attributes) { | 384 Isolate* isolate, PropertyAttributes attributes) { |
382 return MakeAccessor(isolate, isolate->factory()->source_string(), | 385 return MakeAccessor(isolate, isolate->factory()->source_string(), |
383 &ScriptSourceGetter, nullptr, attributes); | 386 &ScriptSourceGetter, nullptr, attributes); |
384 } | 387 } |
385 | 388 |
386 | 389 |
387 // | 390 // |
388 // Accessors::ScriptLineOffset | 391 // Accessors::ScriptLineOffset |
389 // | 392 // |
390 | 393 |
391 | 394 |
392 void Accessors::ScriptLineOffsetGetter( | 395 void Accessors::ScriptLineOffsetGetter( |
393 v8::Local<v8::Name> name, | 396 v8::Local<v8::Name> name, |
394 const v8::PropertyCallbackInfo<v8::Value>& info) { | 397 const v8::PropertyCallbackInfo<v8::Value>& info) { |
395 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 398 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
396 DisallowHeapAllocation no_allocation; | 399 DisallowHeapAllocation no_allocation; |
397 HandleScope scope(isolate); | 400 HandleScope scope(isolate); |
398 Object* object = *Utils::OpenHandle(*info.This()); | 401 Object* object = *Utils::OpenHandle(*info.Holder()); |
399 Object* res = | 402 Object* res = |
400 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->line_offset()); | 403 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->line_offset()); |
401 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 404 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
402 } | 405 } |
403 | 406 |
404 | 407 |
405 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( | 408 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( |
406 Isolate* isolate, PropertyAttributes attributes) { | 409 Isolate* isolate, PropertyAttributes attributes) { |
407 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 410 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
408 STATIC_CHAR_VECTOR("line_offset"))); | 411 STATIC_CHAR_VECTOR("line_offset"))); |
409 return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr, | 412 return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr, |
410 attributes); | 413 attributes); |
411 } | 414 } |
412 | 415 |
413 | 416 |
414 // | 417 // |
415 // Accessors::ScriptType | 418 // Accessors::ScriptType |
416 // | 419 // |
417 | 420 |
418 | 421 |
419 void Accessors::ScriptTypeGetter( | 422 void Accessors::ScriptTypeGetter( |
420 v8::Local<v8::Name> name, | 423 v8::Local<v8::Name> name, |
421 const v8::PropertyCallbackInfo<v8::Value>& info) { | 424 const v8::PropertyCallbackInfo<v8::Value>& info) { |
422 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 425 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
423 DisallowHeapAllocation no_allocation; | 426 DisallowHeapAllocation no_allocation; |
424 HandleScope scope(isolate); | 427 HandleScope scope(isolate); |
425 Object* object = *Utils::OpenHandle(*info.This()); | 428 Object* object = *Utils::OpenHandle(*info.Holder()); |
426 Object* res = | 429 Object* res = |
427 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->type()); | 430 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->type()); |
428 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 431 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
429 } | 432 } |
430 | 433 |
431 | 434 |
432 Handle<AccessorInfo> Accessors::ScriptTypeInfo( | 435 Handle<AccessorInfo> Accessors::ScriptTypeInfo( |
433 Isolate* isolate, PropertyAttributes attributes) { | 436 Isolate* isolate, PropertyAttributes attributes) { |
434 Handle<String> name( | 437 Handle<String> name( |
435 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); | 438 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); |
436 return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes); | 439 return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes); |
437 } | 440 } |
438 | 441 |
439 | 442 |
440 // | 443 // |
441 // Accessors::ScriptCompilationType | 444 // Accessors::ScriptCompilationType |
442 // | 445 // |
443 | 446 |
444 | 447 |
445 void Accessors::ScriptCompilationTypeGetter( | 448 void Accessors::ScriptCompilationTypeGetter( |
446 v8::Local<v8::Name> name, | 449 v8::Local<v8::Name> name, |
447 const v8::PropertyCallbackInfo<v8::Value>& info) { | 450 const v8::PropertyCallbackInfo<v8::Value>& info) { |
448 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 451 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
449 DisallowHeapAllocation no_allocation; | 452 DisallowHeapAllocation no_allocation; |
450 HandleScope scope(isolate); | 453 HandleScope scope(isolate); |
451 Object* object = *Utils::OpenHandle(*info.This()); | 454 Object* object = *Utils::OpenHandle(*info.Holder()); |
452 Object* res = Smi::FromInt( | 455 Object* res = Smi::FromInt( |
453 Script::cast(JSValue::cast(object)->value())->compilation_type()); | 456 Script::cast(JSValue::cast(object)->value())->compilation_type()); |
454 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 457 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
455 } | 458 } |
456 | 459 |
457 | 460 |
458 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( | 461 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( |
459 Isolate* isolate, PropertyAttributes attributes) { | 462 Isolate* isolate, PropertyAttributes attributes) { |
460 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 463 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
461 STATIC_CHAR_VECTOR("compilation_type"))); | 464 STATIC_CHAR_VECTOR("compilation_type"))); |
462 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr, | 465 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr, |
463 attributes); | 466 attributes); |
464 } | 467 } |
465 | 468 |
466 | 469 |
467 // | 470 // |
468 // Accessors::ScriptGetLineEnds | 471 // Accessors::ScriptGetLineEnds |
469 // | 472 // |
470 | 473 |
471 | 474 |
472 void Accessors::ScriptLineEndsGetter( | 475 void Accessors::ScriptLineEndsGetter( |
473 v8::Local<v8::Name> name, | 476 v8::Local<v8::Name> name, |
474 const v8::PropertyCallbackInfo<v8::Value>& info) { | 477 const v8::PropertyCallbackInfo<v8::Value>& info) { |
475 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 478 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
476 HandleScope scope(isolate); | 479 HandleScope scope(isolate); |
477 Handle<Object> object = Utils::OpenHandle(*info.This()); | 480 Handle<Object> object = Utils::OpenHandle(*info.Holder()); |
478 Handle<Script> script( | 481 Handle<Script> script( |
479 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 482 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
480 Script::InitLineEnds(script); | 483 Script::InitLineEnds(script); |
481 DCHECK(script->line_ends()->IsFixedArray()); | 484 DCHECK(script->line_ends()->IsFixedArray()); |
482 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 485 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
483 // We do not want anyone to modify this array from JS. | 486 // We do not want anyone to modify this array from JS. |
484 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() || | 487 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() || |
485 line_ends->map() == isolate->heap()->fixed_cow_array_map()); | 488 line_ends->map() == isolate->heap()->fixed_cow_array_map()); |
486 Handle<JSArray> js_array = | 489 Handle<JSArray> js_array = |
487 isolate->factory()->NewJSArrayWithElements(line_ends); | 490 isolate->factory()->NewJSArrayWithElements(line_ends); |
(...skipping 14 matching lines...) Expand all Loading... | |
502 // Accessors::ScriptSourceUrl | 505 // Accessors::ScriptSourceUrl |
503 // | 506 // |
504 | 507 |
505 | 508 |
506 void Accessors::ScriptSourceUrlGetter( | 509 void Accessors::ScriptSourceUrlGetter( |
507 v8::Local<v8::Name> name, | 510 v8::Local<v8::Name> name, |
508 const v8::PropertyCallbackInfo<v8::Value>& info) { | 511 const v8::PropertyCallbackInfo<v8::Value>& info) { |
509 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 512 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
510 DisallowHeapAllocation no_allocation; | 513 DisallowHeapAllocation no_allocation; |
511 HandleScope scope(isolate); | 514 HandleScope scope(isolate); |
512 Object* object = *Utils::OpenHandle(*info.This()); | 515 Object* object = *Utils::OpenHandle(*info.Holder()); |
513 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); | 516 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); |
514 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 517 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
515 } | 518 } |
516 | 519 |
517 | 520 |
518 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( | 521 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( |
519 Isolate* isolate, PropertyAttributes attributes) { | 522 Isolate* isolate, PropertyAttributes attributes) { |
520 return MakeAccessor(isolate, isolate->factory()->source_url_string(), | 523 return MakeAccessor(isolate, isolate->factory()->source_url_string(), |
521 &ScriptSourceUrlGetter, nullptr, attributes); | 524 &ScriptSourceUrlGetter, nullptr, attributes); |
522 } | 525 } |
523 | 526 |
524 | 527 |
525 // | 528 // |
526 // Accessors::ScriptSourceMappingUrl | 529 // Accessors::ScriptSourceMappingUrl |
527 // | 530 // |
528 | 531 |
529 | 532 |
530 void Accessors::ScriptSourceMappingUrlGetter( | 533 void Accessors::ScriptSourceMappingUrlGetter( |
531 v8::Local<v8::Name> name, | 534 v8::Local<v8::Name> name, |
532 const v8::PropertyCallbackInfo<v8::Value>& info) { | 535 const v8::PropertyCallbackInfo<v8::Value>& info) { |
533 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 536 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
534 DisallowHeapAllocation no_allocation; | 537 DisallowHeapAllocation no_allocation; |
535 HandleScope scope(isolate); | 538 HandleScope scope(isolate); |
536 Object* object = *Utils::OpenHandle(*info.This()); | 539 Object* object = *Utils::OpenHandle(*info.Holder()); |
537 Object* url = | 540 Object* url = |
538 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); | 541 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); |
539 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 542 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
540 } | 543 } |
541 | 544 |
542 | 545 |
543 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( | 546 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( |
544 Isolate* isolate, PropertyAttributes attributes) { | 547 Isolate* isolate, PropertyAttributes attributes) { |
545 return MakeAccessor(isolate, isolate->factory()->source_mapping_url_string(), | 548 return MakeAccessor(isolate, isolate->factory()->source_mapping_url_string(), |
546 &ScriptSourceMappingUrlGetter, nullptr, attributes); | 549 &ScriptSourceMappingUrlGetter, nullptr, attributes); |
547 } | 550 } |
548 | 551 |
549 | 552 |
550 // | 553 // |
551 // Accessors::ScriptIsEmbedderDebugScript | 554 // Accessors::ScriptIsEmbedderDebugScript |
552 // | 555 // |
553 | 556 |
554 | 557 |
555 void Accessors::ScriptIsEmbedderDebugScriptGetter( | 558 void Accessors::ScriptIsEmbedderDebugScriptGetter( |
556 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 559 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
557 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 560 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
558 DisallowHeapAllocation no_allocation; | 561 DisallowHeapAllocation no_allocation; |
559 HandleScope scope(isolate); | 562 HandleScope scope(isolate); |
560 Object* object = *Utils::OpenHandle(*info.This()); | 563 Object* object = *Utils::OpenHandle(*info.Holder()); |
561 bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value()) | 564 bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value()) |
562 ->origin_options() | 565 ->origin_options() |
563 .IsEmbedderDebugScript(); | 566 .IsEmbedderDebugScript(); |
564 Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script); | 567 Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script); |
565 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 568 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
566 } | 569 } |
567 | 570 |
568 | 571 |
569 Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo( | 572 Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo( |
570 Isolate* isolate, PropertyAttributes attributes) { | 573 Isolate* isolate, PropertyAttributes attributes) { |
571 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 574 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
572 STATIC_CHAR_VECTOR("is_debugger_script"))); | 575 STATIC_CHAR_VECTOR("is_debugger_script"))); |
573 return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter, | 576 return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter, |
574 nullptr, attributes); | 577 nullptr, attributes); |
575 } | 578 } |
576 | 579 |
577 | 580 |
578 // | 581 // |
579 // Accessors::ScriptGetContextData | 582 // Accessors::ScriptGetContextData |
580 // | 583 // |
581 | 584 |
582 | 585 |
583 void Accessors::ScriptContextDataGetter( | 586 void Accessors::ScriptContextDataGetter( |
584 v8::Local<v8::Name> name, | 587 v8::Local<v8::Name> name, |
585 const v8::PropertyCallbackInfo<v8::Value>& info) { | 588 const v8::PropertyCallbackInfo<v8::Value>& info) { |
586 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 589 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
587 DisallowHeapAllocation no_allocation; | 590 DisallowHeapAllocation no_allocation; |
588 HandleScope scope(isolate); | 591 HandleScope scope(isolate); |
589 Object* object = *Utils::OpenHandle(*info.This()); | 592 Object* object = *Utils::OpenHandle(*info.Holder()); |
590 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); | 593 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); |
591 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 594 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
592 } | 595 } |
593 | 596 |
594 | 597 |
595 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( | 598 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( |
596 Isolate* isolate, PropertyAttributes attributes) { | 599 Isolate* isolate, PropertyAttributes attributes) { |
597 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 600 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
598 STATIC_CHAR_VECTOR("context_data"))); | 601 STATIC_CHAR_VECTOR("context_data"))); |
599 return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr, | 602 return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr, |
600 attributes); | 603 attributes); |
601 } | 604 } |
602 | 605 |
603 | 606 |
604 // | 607 // |
605 // Accessors::ScriptGetEvalFromScript | 608 // Accessors::ScriptGetEvalFromScript |
606 // | 609 // |
607 | 610 |
608 | 611 |
609 void Accessors::ScriptEvalFromScriptGetter( | 612 void Accessors::ScriptEvalFromScriptGetter( |
610 v8::Local<v8::Name> name, | 613 v8::Local<v8::Name> name, |
611 const v8::PropertyCallbackInfo<v8::Value>& info) { | 614 const v8::PropertyCallbackInfo<v8::Value>& info) { |
612 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 615 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
613 HandleScope scope(isolate); | 616 HandleScope scope(isolate); |
614 Handle<Object> object = Utils::OpenHandle(*info.This()); | 617 Handle<Object> object = Utils::OpenHandle(*info.Holder()); |
615 Handle<Script> script( | 618 Handle<Script> script( |
616 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 619 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
617 Handle<Object> result = isolate->factory()->undefined_value(); | 620 Handle<Object> result = isolate->factory()->undefined_value(); |
618 if (!script->eval_from_shared()->IsUndefined()) { | 621 if (!script->eval_from_shared()->IsUndefined()) { |
619 Handle<SharedFunctionInfo> eval_from_shared( | 622 Handle<SharedFunctionInfo> eval_from_shared( |
620 SharedFunctionInfo::cast(script->eval_from_shared())); | 623 SharedFunctionInfo::cast(script->eval_from_shared())); |
621 if (eval_from_shared->script()->IsScript()) { | 624 if (eval_from_shared->script()->IsScript()) { |
622 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); | 625 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); |
623 result = Script::GetWrapper(eval_from_script); | 626 result = Script::GetWrapper(eval_from_script); |
624 } | 627 } |
(...skipping 15 matching lines...) Expand all Loading... | |
640 // | 643 // |
641 // Accessors::ScriptGetEvalFromScriptPosition | 644 // Accessors::ScriptGetEvalFromScriptPosition |
642 // | 645 // |
643 | 646 |
644 | 647 |
645 void Accessors::ScriptEvalFromScriptPositionGetter( | 648 void Accessors::ScriptEvalFromScriptPositionGetter( |
646 v8::Local<v8::Name> name, | 649 v8::Local<v8::Name> name, |
647 const v8::PropertyCallbackInfo<v8::Value>& info) { | 650 const v8::PropertyCallbackInfo<v8::Value>& info) { |
648 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 651 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
649 HandleScope scope(isolate); | 652 HandleScope scope(isolate); |
650 Handle<Object> object = Utils::OpenHandle(*info.This()); | 653 Handle<Object> object = Utils::OpenHandle(*info.Holder()); |
651 Handle<Script> script( | 654 Handle<Script> script( |
652 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 655 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
653 Handle<Object> result = isolate->factory()->undefined_value(); | 656 Handle<Object> result = isolate->factory()->undefined_value(); |
654 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { | 657 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { |
655 result = Handle<Object>(Smi::FromInt(script->GetEvalPosition()), isolate); | 658 result = Handle<Object>(Smi::FromInt(script->GetEvalPosition()), isolate); |
656 } | 659 } |
657 info.GetReturnValue().Set(Utils::ToLocal(result)); | 660 info.GetReturnValue().Set(Utils::ToLocal(result)); |
658 } | 661 } |
659 | 662 |
660 | 663 |
661 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( | 664 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( |
662 Isolate* isolate, PropertyAttributes attributes) { | 665 Isolate* isolate, PropertyAttributes attributes) { |
663 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 666 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
664 STATIC_CHAR_VECTOR("eval_from_script_position"))); | 667 STATIC_CHAR_VECTOR("eval_from_script_position"))); |
665 return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter, | 668 return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter, |
666 nullptr, attributes); | 669 nullptr, attributes); |
667 } | 670 } |
668 | 671 |
669 | 672 |
670 // | 673 // |
671 // Accessors::ScriptGetEvalFromFunctionName | 674 // Accessors::ScriptGetEvalFromFunctionName |
672 // | 675 // |
673 | 676 |
674 | 677 |
675 void Accessors::ScriptEvalFromFunctionNameGetter( | 678 void Accessors::ScriptEvalFromFunctionNameGetter( |
676 v8::Local<v8::Name> name, | 679 v8::Local<v8::Name> name, |
677 const v8::PropertyCallbackInfo<v8::Value>& info) { | 680 const v8::PropertyCallbackInfo<v8::Value>& info) { |
678 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 681 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
679 HandleScope scope(isolate); | 682 HandleScope scope(isolate); |
680 Handle<Object> object = Utils::OpenHandle(*info.This()); | 683 Handle<Object> object = Utils::OpenHandle(*info.Holder()); |
681 Handle<Script> script( | 684 Handle<Script> script( |
682 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 685 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
683 Handle<Object> result; | 686 Handle<Object> result; |
684 Handle<SharedFunctionInfo> shared( | 687 Handle<SharedFunctionInfo> shared( |
685 SharedFunctionInfo::cast(script->eval_from_shared())); | 688 SharedFunctionInfo::cast(script->eval_from_shared())); |
686 // Find the name of the function calling eval. | 689 // Find the name of the function calling eval. |
687 if (!shared->name()->IsUndefined()) { | 690 if (!shared->name()->IsUndefined()) { |
688 result = Handle<Object>(shared->name(), isolate); | 691 result = Handle<Object>(shared->name(), isolate); |
689 } else { | 692 } else { |
690 result = Handle<Object>(shared->inferred_name(), isolate); | 693 result = Handle<Object>(shared->inferred_name(), isolate); |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1205 Isolate* isolate = name->GetIsolate(); | 1208 Isolate* isolate = name->GetIsolate(); |
1206 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, | 1209 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, |
1207 &ModuleSetExport, attributes); | 1210 &ModuleSetExport, attributes); |
1208 info->set_data(Smi::FromInt(index)); | 1211 info->set_data(Smi::FromInt(index)); |
1209 return info; | 1212 return info; |
1210 } | 1213 } |
1211 | 1214 |
1212 | 1215 |
1213 } // namespace internal | 1216 } // namespace internal |
1214 } // namespace v8 | 1217 } // namespace v8 |
OLD | NEW |