Chromium Code Reviews| 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" |
| 11 #include "src/factory.h" | 11 #include "src/factory.h" |
| 12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
| 13 #include "src/isolate-inl.h" | 13 #include "src/isolate-inl.h" |
| 14 #include "src/list-inl.h" | 14 #include "src/list-inl.h" |
| 15 #include "src/messages.h" | 15 #include "src/messages.h" |
| 16 #include "src/property-details.h" | 16 #include "src/property-details.h" |
| 17 #include "src/prototype.h" | 17 #include "src/prototype.h" |
| 18 | 18 |
| 19 namespace v8 { | 19 namespace v8 { |
| 20 namespace internal { | 20 namespace internal { |
| 21 | 21 |
| 22 Handle<AccessorInfo> Accessors::MakeAccessor( | 22 Handle<AccessorInfo> Accessors::MakeAccessor( |
| 23 Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter, | 23 Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter, |
| 24 AccessorNameBooleanSetterCallback setter, PropertyAttributes attributes) { | 24 AccessorNameBooleanSetterCallback setter, PropertyAttributes attributes, |
| 25 bool replace_on_access) { | |
| 25 Factory* factory = isolate->factory(); | 26 Factory* factory = isolate->factory(); |
| 26 Handle<AccessorInfo> info = factory->NewAccessorInfo(); | 27 Handle<AccessorInfo> info = factory->NewAccessorInfo(); |
| 27 info->set_property_attributes(attributes); | 28 info->set_property_attributes(attributes); |
| 28 info->set_all_can_read(false); | 29 info->set_all_can_read(false); |
| 29 info->set_all_can_write(false); | 30 info->set_all_can_write(false); |
| 30 info->set_is_special_data_property(true); | 31 info->set_is_special_data_property(true); |
| 31 info->set_is_sloppy(false); | 32 info->set_is_sloppy(false); |
| 33 info->set_replace_on_access(replace_on_access); | |
| 34 DCHECK_IMPLIES(replace_on_access, setter == nullptr); | |
| 32 name = factory->InternalizeName(name); | 35 name = factory->InternalizeName(name); |
| 33 info->set_name(*name); | 36 info->set_name(*name); |
| 34 Handle<Object> get = v8::FromCData(isolate, getter); | 37 Handle<Object> get = v8::FromCData(isolate, getter); |
| 35 if (setter == nullptr) setter = &ReconfigureToDataProperty; | 38 if (setter == nullptr) setter = &ReconfigureToDataProperty; |
| 36 Handle<Object> set = v8::FromCData(isolate, setter); | 39 Handle<Object> set = v8::FromCData(isolate, setter); |
| 37 info->set_getter(*get); | 40 info->set_getter(*get); |
| 38 info->set_setter(*set); | 41 info->set_setter(*set); |
| 39 Address redirected = info->redirected_getter(); | 42 Address redirected = info->redirected_getter(); |
| 40 if (redirected != nullptr) { | 43 if (redirected != nullptr) { |
| 41 Handle<Object> js_get = v8::FromCData(isolate, redirected); | 44 Handle<Object> js_get = v8::FromCData(isolate, redirected); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 HandleScope scope(isolate); | 134 HandleScope scope(isolate); |
| 132 Object* result = isolate->native_context()->array_values_iterator(); | 135 Object* result = isolate->native_context()->array_values_iterator(); |
| 133 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 136 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
| 134 } | 137 } |
| 135 | 138 |
| 136 | 139 |
| 137 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( | 140 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( |
| 138 Isolate* isolate, PropertyAttributes attributes) { | 141 Isolate* isolate, PropertyAttributes attributes) { |
| 139 Handle<Name> name = isolate->factory()->iterator_symbol(); | 142 Handle<Name> name = isolate->factory()->iterator_symbol(); |
| 140 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, nullptr, | 143 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, nullptr, |
| 141 attributes); | 144 attributes, true); |
| 142 } | 145 } |
| 143 | 146 |
| 144 | 147 |
| 145 // | 148 // |
| 146 // Accessors::ArrayLength | 149 // Accessors::ArrayLength |
| 147 // | 150 // |
| 148 | 151 |
| 149 | 152 |
| 150 void Accessors::ArrayLengthGetter( | 153 void Accessors::ArrayLengthGetter( |
| 151 v8::Local<v8::Name> name, | 154 v8::Local<v8::Name> name, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 info.GetReturnValue().Set(false); | 195 info.GetReturnValue().Set(false); |
| 193 } | 196 } |
| 194 } else { | 197 } else { |
| 195 info.GetReturnValue().Set(true); | 198 info.GetReturnValue().Set(true); |
| 196 } | 199 } |
| 197 } | 200 } |
| 198 | 201 |
| 199 | 202 |
| 200 Handle<AccessorInfo> Accessors::ArrayLengthInfo( | 203 Handle<AccessorInfo> Accessors::ArrayLengthInfo( |
| 201 Isolate* isolate, PropertyAttributes attributes) { | 204 Isolate* isolate, PropertyAttributes attributes) { |
| 202 return MakeAccessor(isolate, | 205 return MakeAccessor(isolate, isolate->factory()->length_string(), |
| 203 isolate->factory()->length_string(), | 206 &ArrayLengthGetter, &ArrayLengthSetter, attributes, |
| 204 &ArrayLengthGetter, | 207 false); |
| 205 &ArrayLengthSetter, | |
| 206 attributes); | |
| 207 } | 208 } |
| 208 | 209 |
| 209 // | 210 // |
| 210 // Accessors::ModuleNamespaceEntry | 211 // Accessors::ModuleNamespaceEntry |
| 211 // | 212 // |
| 212 | 213 |
| 213 void Accessors::ModuleNamespaceEntryGetter( | 214 void Accessors::ModuleNamespaceEntryGetter( |
| 214 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 215 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 215 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 216 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 216 HandleScope scope(isolate); | 217 HandleScope scope(isolate); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 240 i::Object::TypeOf(isolate, holder), holder)); | 241 i::Object::TypeOf(isolate, holder), holder)); |
| 241 isolate->OptionalRescheduleException(false); | 242 isolate->OptionalRescheduleException(false); |
| 242 } else { | 243 } else { |
| 243 info.GetReturnValue().Set(false); | 244 info.GetReturnValue().Set(false); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 | 247 |
| 247 Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo( | 248 Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo( |
| 248 Isolate* isolate, Handle<String> name, PropertyAttributes attributes) { | 249 Isolate* isolate, Handle<String> name, PropertyAttributes attributes) { |
| 249 return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter, | 250 return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter, |
| 250 &ModuleNamespaceEntrySetter, attributes); | 251 &ModuleNamespaceEntrySetter, attributes, false); |
| 251 } | 252 } |
| 252 | 253 |
| 253 | 254 |
| 254 // | 255 // |
| 255 // Accessors::StringLength | 256 // Accessors::StringLength |
| 256 // | 257 // |
| 257 | 258 |
| 258 void Accessors::StringLengthGetter( | 259 void Accessors::StringLengthGetter( |
| 259 v8::Local<v8::Name> name, | 260 v8::Local<v8::Name> name, |
| 260 const v8::PropertyCallbackInfo<v8::Value>& info) { | 261 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 276 value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); | 277 value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); |
| 277 } | 278 } |
| 278 Object* result = Smi::FromInt(String::cast(value)->length()); | 279 Object* result = Smi::FromInt(String::cast(value)->length()); |
| 279 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 280 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
| 280 } | 281 } |
| 281 | 282 |
| 282 | 283 |
| 283 Handle<AccessorInfo> Accessors::StringLengthInfo( | 284 Handle<AccessorInfo> Accessors::StringLengthInfo( |
| 284 Isolate* isolate, PropertyAttributes attributes) { | 285 Isolate* isolate, PropertyAttributes attributes) { |
| 285 return MakeAccessor(isolate, isolate->factory()->length_string(), | 286 return MakeAccessor(isolate, isolate->factory()->length_string(), |
| 286 &StringLengthGetter, nullptr, attributes); | 287 &StringLengthGetter, nullptr, attributes, false); |
| 287 } | 288 } |
| 288 | 289 |
| 289 | 290 |
| 290 // | 291 // |
| 291 // Accessors::ScriptColumnOffset | 292 // Accessors::ScriptColumnOffset |
| 292 // | 293 // |
| 293 | 294 |
| 294 | 295 |
| 295 void Accessors::ScriptColumnOffsetGetter( | 296 void Accessors::ScriptColumnOffsetGetter( |
| 296 v8::Local<v8::Name> name, | 297 v8::Local<v8::Name> name, |
| 297 const v8::PropertyCallbackInfo<v8::Value>& info) { | 298 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 298 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 299 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 299 DisallowHeapAllocation no_allocation; | 300 DisallowHeapAllocation no_allocation; |
| 300 HandleScope scope(isolate); | 301 HandleScope scope(isolate); |
| 301 Object* object = *Utils::OpenHandle(*info.Holder()); | 302 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 302 Object* res = Smi::FromInt( | 303 Object* res = Smi::FromInt( |
| 303 Script::cast(JSValue::cast(object)->value())->column_offset()); | 304 Script::cast(JSValue::cast(object)->value())->column_offset()); |
| 304 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 305 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 305 } | 306 } |
| 306 | 307 |
| 307 | 308 |
| 308 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( | 309 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( |
| 309 Isolate* isolate, PropertyAttributes attributes) { | 310 Isolate* isolate, PropertyAttributes attributes) { |
| 310 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 311 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 311 STATIC_CHAR_VECTOR("column_offset"))); | 312 STATIC_CHAR_VECTOR("column_offset"))); |
| 312 return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr, | 313 return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr, |
| 313 attributes); | 314 attributes, false); |
| 314 } | 315 } |
| 315 | 316 |
| 316 | 317 |
| 317 // | 318 // |
| 318 // Accessors::ScriptId | 319 // Accessors::ScriptId |
| 319 // | 320 // |
| 320 | 321 |
| 321 | 322 |
| 322 void Accessors::ScriptIdGetter( | 323 void Accessors::ScriptIdGetter( |
| 323 v8::Local<v8::Name> name, | 324 v8::Local<v8::Name> name, |
| 324 const v8::PropertyCallbackInfo<v8::Value>& info) { | 325 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 325 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 326 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 326 DisallowHeapAllocation no_allocation; | 327 DisallowHeapAllocation no_allocation; |
| 327 HandleScope scope(isolate); | 328 HandleScope scope(isolate); |
| 328 Object* object = *Utils::OpenHandle(*info.Holder()); | 329 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 329 Object* id = Smi::FromInt(Script::cast(JSValue::cast(object)->value())->id()); | 330 Object* id = Smi::FromInt(Script::cast(JSValue::cast(object)->value())->id()); |
| 330 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); | 331 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); |
| 331 } | 332 } |
| 332 | 333 |
| 333 | 334 |
| 334 Handle<AccessorInfo> Accessors::ScriptIdInfo( | 335 Handle<AccessorInfo> Accessors::ScriptIdInfo( |
| 335 Isolate* isolate, PropertyAttributes attributes) { | 336 Isolate* isolate, PropertyAttributes attributes) { |
| 336 Handle<String> name( | 337 Handle<String> name( |
| 337 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); | 338 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); |
| 338 return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes); | 339 return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes, |
| 340 false); | |
| 339 } | 341 } |
| 340 | 342 |
| 341 | 343 |
| 342 // | 344 // |
| 343 // Accessors::ScriptName | 345 // Accessors::ScriptName |
| 344 // | 346 // |
| 345 | 347 |
| 346 | 348 |
| 347 void Accessors::ScriptNameGetter( | 349 void Accessors::ScriptNameGetter( |
| 348 v8::Local<v8::Name> name, | 350 v8::Local<v8::Name> name, |
| 349 const v8::PropertyCallbackInfo<v8::Value>& info) { | 351 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 350 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 352 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 351 DisallowHeapAllocation no_allocation; | 353 DisallowHeapAllocation no_allocation; |
| 352 HandleScope scope(isolate); | 354 HandleScope scope(isolate); |
| 353 Object* object = *Utils::OpenHandle(*info.Holder()); | 355 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 354 Object* source = Script::cast(JSValue::cast(object)->value())->name(); | 356 Object* source = Script::cast(JSValue::cast(object)->value())->name(); |
| 355 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 357 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
| 356 } | 358 } |
| 357 | 359 |
| 358 | 360 |
| 359 Handle<AccessorInfo> Accessors::ScriptNameInfo( | 361 Handle<AccessorInfo> Accessors::ScriptNameInfo( |
| 360 Isolate* isolate, PropertyAttributes attributes) { | 362 Isolate* isolate, PropertyAttributes attributes) { |
| 361 return MakeAccessor(isolate, isolate->factory()->name_string(), | 363 return MakeAccessor(isolate, isolate->factory()->name_string(), |
| 362 &ScriptNameGetter, nullptr, attributes); | 364 &ScriptNameGetter, nullptr, attributes, false); |
| 363 } | 365 } |
| 364 | 366 |
| 365 | 367 |
| 366 // | 368 // |
| 367 // Accessors::ScriptSource | 369 // Accessors::ScriptSource |
| 368 // | 370 // |
| 369 | 371 |
| 370 | 372 |
| 371 void Accessors::ScriptSourceGetter( | 373 void Accessors::ScriptSourceGetter( |
| 372 v8::Local<v8::Name> name, | 374 v8::Local<v8::Name> name, |
| 373 const v8::PropertyCallbackInfo<v8::Value>& info) { | 375 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 374 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 376 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 375 DisallowHeapAllocation no_allocation; | 377 DisallowHeapAllocation no_allocation; |
| 376 HandleScope scope(isolate); | 378 HandleScope scope(isolate); |
| 377 Object* object = *Utils::OpenHandle(*info.Holder()); | 379 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 378 Object* source = Script::cast(JSValue::cast(object)->value())->source(); | 380 Object* source = Script::cast(JSValue::cast(object)->value())->source(); |
| 379 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 381 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
| 380 } | 382 } |
| 381 | 383 |
| 382 | 384 |
| 383 Handle<AccessorInfo> Accessors::ScriptSourceInfo( | 385 Handle<AccessorInfo> Accessors::ScriptSourceInfo( |
| 384 Isolate* isolate, PropertyAttributes attributes) { | 386 Isolate* isolate, PropertyAttributes attributes) { |
| 385 return MakeAccessor(isolate, isolate->factory()->source_string(), | 387 return MakeAccessor(isolate, isolate->factory()->source_string(), |
| 386 &ScriptSourceGetter, nullptr, attributes); | 388 &ScriptSourceGetter, nullptr, attributes, false); |
| 387 } | 389 } |
| 388 | 390 |
| 389 | 391 |
| 390 // | 392 // |
| 391 // Accessors::ScriptLineOffset | 393 // Accessors::ScriptLineOffset |
| 392 // | 394 // |
| 393 | 395 |
| 394 | 396 |
| 395 void Accessors::ScriptLineOffsetGetter( | 397 void Accessors::ScriptLineOffsetGetter( |
| 396 v8::Local<v8::Name> name, | 398 v8::Local<v8::Name> name, |
| 397 const v8::PropertyCallbackInfo<v8::Value>& info) { | 399 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 398 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 400 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 399 DisallowHeapAllocation no_allocation; | 401 DisallowHeapAllocation no_allocation; |
| 400 HandleScope scope(isolate); | 402 HandleScope scope(isolate); |
| 401 Object* object = *Utils::OpenHandle(*info.Holder()); | 403 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 402 Object* res = | 404 Object* res = |
| 403 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->line_offset()); | 405 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->line_offset()); |
| 404 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 406 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 405 } | 407 } |
| 406 | 408 |
| 407 | 409 |
| 408 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( | 410 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( |
| 409 Isolate* isolate, PropertyAttributes attributes) { | 411 Isolate* isolate, PropertyAttributes attributes) { |
| 410 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 412 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 411 STATIC_CHAR_VECTOR("line_offset"))); | 413 STATIC_CHAR_VECTOR("line_offset"))); |
| 412 return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr, | 414 return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr, |
| 413 attributes); | 415 attributes, false); |
| 414 } | 416 } |
| 415 | 417 |
| 416 | 418 |
| 417 // | 419 // |
| 418 // Accessors::ScriptType | 420 // Accessors::ScriptType |
| 419 // | 421 // |
| 420 | 422 |
| 421 | 423 |
| 422 void Accessors::ScriptTypeGetter( | 424 void Accessors::ScriptTypeGetter( |
| 423 v8::Local<v8::Name> name, | 425 v8::Local<v8::Name> name, |
| 424 const v8::PropertyCallbackInfo<v8::Value>& info) { | 426 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 425 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 427 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 426 DisallowHeapAllocation no_allocation; | 428 DisallowHeapAllocation no_allocation; |
| 427 HandleScope scope(isolate); | 429 HandleScope scope(isolate); |
| 428 Object* object = *Utils::OpenHandle(*info.Holder()); | 430 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 429 Object* res = | 431 Object* res = |
| 430 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->type()); | 432 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->type()); |
| 431 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 433 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 432 } | 434 } |
| 433 | 435 |
| 434 | 436 |
| 435 Handle<AccessorInfo> Accessors::ScriptTypeInfo( | 437 Handle<AccessorInfo> Accessors::ScriptTypeInfo( |
| 436 Isolate* isolate, PropertyAttributes attributes) { | 438 Isolate* isolate, PropertyAttributes attributes) { |
| 437 Handle<String> name( | 439 Handle<String> name( |
| 438 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); | 440 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); |
| 439 return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes); | 441 return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes, |
| 442 false); | |
| 440 } | 443 } |
| 441 | 444 |
| 442 | 445 |
| 443 // | 446 // |
| 444 // Accessors::ScriptCompilationType | 447 // Accessors::ScriptCompilationType |
| 445 // | 448 // |
| 446 | 449 |
| 447 | 450 |
| 448 void Accessors::ScriptCompilationTypeGetter( | 451 void Accessors::ScriptCompilationTypeGetter( |
| 449 v8::Local<v8::Name> name, | 452 v8::Local<v8::Name> name, |
| 450 const v8::PropertyCallbackInfo<v8::Value>& info) { | 453 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 451 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 454 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 452 DisallowHeapAllocation no_allocation; | 455 DisallowHeapAllocation no_allocation; |
| 453 HandleScope scope(isolate); | 456 HandleScope scope(isolate); |
| 454 Object* object = *Utils::OpenHandle(*info.Holder()); | 457 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 455 Object* res = Smi::FromInt( | 458 Object* res = Smi::FromInt( |
| 456 Script::cast(JSValue::cast(object)->value())->compilation_type()); | 459 Script::cast(JSValue::cast(object)->value())->compilation_type()); |
| 457 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 460 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 458 } | 461 } |
| 459 | 462 |
| 460 | 463 |
| 461 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( | 464 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( |
| 462 Isolate* isolate, PropertyAttributes attributes) { | 465 Isolate* isolate, PropertyAttributes attributes) { |
| 463 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 466 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 464 STATIC_CHAR_VECTOR("compilation_type"))); | 467 STATIC_CHAR_VECTOR("compilation_type"))); |
| 465 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr, | 468 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr, |
| 466 attributes); | 469 attributes, false); |
| 467 } | 470 } |
| 468 | 471 |
| 469 | 472 |
| 470 // | 473 // |
| 471 // Accessors::ScriptGetLineEnds | 474 // Accessors::ScriptGetLineEnds |
| 472 // | 475 // |
| 473 | 476 |
| 474 | 477 |
| 475 void Accessors::ScriptLineEndsGetter( | 478 void Accessors::ScriptLineEndsGetter( |
| 476 v8::Local<v8::Name> name, | 479 v8::Local<v8::Name> name, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 489 Handle<JSArray> js_array = | 492 Handle<JSArray> js_array = |
| 490 isolate->factory()->NewJSArrayWithElements(line_ends); | 493 isolate->factory()->NewJSArrayWithElements(line_ends); |
| 491 info.GetReturnValue().Set(Utils::ToLocal(js_array)); | 494 info.GetReturnValue().Set(Utils::ToLocal(js_array)); |
| 492 } | 495 } |
| 493 | 496 |
| 494 | 497 |
| 495 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo( | 498 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo( |
| 496 Isolate* isolate, PropertyAttributes attributes) { | 499 Isolate* isolate, PropertyAttributes attributes) { |
| 497 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 500 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 498 STATIC_CHAR_VECTOR("line_ends"))); | 501 STATIC_CHAR_VECTOR("line_ends"))); |
| 499 return MakeAccessor(isolate, name, &ScriptLineEndsGetter, nullptr, | 502 return MakeAccessor(isolate, name, &ScriptLineEndsGetter, nullptr, attributes, |
| 500 attributes); | 503 false); |
| 501 } | 504 } |
| 502 | 505 |
| 503 | 506 |
| 504 // | 507 // |
| 505 // Accessors::ScriptSourceUrl | 508 // Accessors::ScriptSourceUrl |
| 506 // | 509 // |
| 507 | 510 |
| 508 | 511 |
| 509 void Accessors::ScriptSourceUrlGetter( | 512 void Accessors::ScriptSourceUrlGetter( |
| 510 v8::Local<v8::Name> name, | 513 v8::Local<v8::Name> name, |
| 511 const v8::PropertyCallbackInfo<v8::Value>& info) { | 514 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 512 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 515 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 513 DisallowHeapAllocation no_allocation; | 516 DisallowHeapAllocation no_allocation; |
| 514 HandleScope scope(isolate); | 517 HandleScope scope(isolate); |
| 515 Object* object = *Utils::OpenHandle(*info.Holder()); | 518 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 516 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); | 519 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); |
| 517 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 520 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
| 518 } | 521 } |
| 519 | 522 |
| 520 | 523 |
| 521 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( | 524 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( |
| 522 Isolate* isolate, PropertyAttributes attributes) { | 525 Isolate* isolate, PropertyAttributes attributes) { |
| 523 return MakeAccessor(isolate, isolate->factory()->source_url_string(), | 526 return MakeAccessor(isolate, isolate->factory()->source_url_string(), |
| 524 &ScriptSourceUrlGetter, nullptr, attributes); | 527 &ScriptSourceUrlGetter, nullptr, attributes, false); |
| 525 } | 528 } |
| 526 | 529 |
| 527 | 530 |
| 528 // | 531 // |
| 529 // Accessors::ScriptSourceMappingUrl | 532 // Accessors::ScriptSourceMappingUrl |
| 530 // | 533 // |
| 531 | 534 |
| 532 | 535 |
| 533 void Accessors::ScriptSourceMappingUrlGetter( | 536 void Accessors::ScriptSourceMappingUrlGetter( |
| 534 v8::Local<v8::Name> name, | 537 v8::Local<v8::Name> name, |
| 535 const v8::PropertyCallbackInfo<v8::Value>& info) { | 538 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 536 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 539 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 537 DisallowHeapAllocation no_allocation; | 540 DisallowHeapAllocation no_allocation; |
| 538 HandleScope scope(isolate); | 541 HandleScope scope(isolate); |
| 539 Object* object = *Utils::OpenHandle(*info.Holder()); | 542 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 540 Object* url = | 543 Object* url = |
| 541 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); | 544 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); |
| 542 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 545 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
| 543 } | 546 } |
| 544 | 547 |
| 545 | 548 |
| 546 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( | 549 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( |
| 547 Isolate* isolate, PropertyAttributes attributes) { | 550 Isolate* isolate, PropertyAttributes attributes) { |
| 548 return MakeAccessor(isolate, isolate->factory()->source_mapping_url_string(), | 551 return MakeAccessor(isolate, isolate->factory()->source_mapping_url_string(), |
| 549 &ScriptSourceMappingUrlGetter, nullptr, attributes); | 552 &ScriptSourceMappingUrlGetter, nullptr, attributes, |
| 553 false); | |
| 550 } | 554 } |
| 551 | 555 |
| 552 | 556 |
| 553 // | 557 // |
| 554 // Accessors::ScriptIsEmbedderDebugScript | 558 // Accessors::ScriptIsEmbedderDebugScript |
| 555 // | 559 // |
| 556 | 560 |
| 557 | 561 |
| 558 void Accessors::ScriptIsEmbedderDebugScriptGetter( | 562 void Accessors::ScriptIsEmbedderDebugScriptGetter( |
| 559 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 563 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 560 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 564 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 561 DisallowHeapAllocation no_allocation; | 565 DisallowHeapAllocation no_allocation; |
| 562 HandleScope scope(isolate); | 566 HandleScope scope(isolate); |
| 563 Object* object = *Utils::OpenHandle(*info.Holder()); | 567 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 564 bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value()) | 568 bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value()) |
| 565 ->origin_options() | 569 ->origin_options() |
| 566 .IsEmbedderDebugScript(); | 570 .IsEmbedderDebugScript(); |
| 567 Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script); | 571 Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script); |
| 568 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 572 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 569 } | 573 } |
| 570 | 574 |
| 571 | 575 |
| 572 Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo( | 576 Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo( |
| 573 Isolate* isolate, PropertyAttributes attributes) { | 577 Isolate* isolate, PropertyAttributes attributes) { |
| 574 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 578 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 575 STATIC_CHAR_VECTOR("is_debugger_script"))); | 579 STATIC_CHAR_VECTOR("is_debugger_script"))); |
| 576 return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter, | 580 return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter, |
| 577 nullptr, attributes); | 581 nullptr, attributes, false); |
| 578 } | 582 } |
| 579 | 583 |
| 580 | 584 |
| 581 // | 585 // |
| 582 // Accessors::ScriptGetContextData | 586 // Accessors::ScriptGetContextData |
| 583 // | 587 // |
| 584 | 588 |
| 585 | 589 |
| 586 void Accessors::ScriptContextDataGetter( | 590 void Accessors::ScriptContextDataGetter( |
| 587 v8::Local<v8::Name> name, | 591 v8::Local<v8::Name> name, |
| 588 const v8::PropertyCallbackInfo<v8::Value>& info) { | 592 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 589 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 593 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 590 DisallowHeapAllocation no_allocation; | 594 DisallowHeapAllocation no_allocation; |
| 591 HandleScope scope(isolate); | 595 HandleScope scope(isolate); |
| 592 Object* object = *Utils::OpenHandle(*info.Holder()); | 596 Object* object = *Utils::OpenHandle(*info.Holder()); |
| 593 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); | 597 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); |
| 594 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 598 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 595 } | 599 } |
| 596 | 600 |
| 597 | 601 |
| 598 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( | 602 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( |
| 599 Isolate* isolate, PropertyAttributes attributes) { | 603 Isolate* isolate, PropertyAttributes attributes) { |
| 600 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 604 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 601 STATIC_CHAR_VECTOR("context_data"))); | 605 STATIC_CHAR_VECTOR("context_data"))); |
| 602 return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr, | 606 return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr, |
| 603 attributes); | 607 attributes, false); |
| 604 } | 608 } |
| 605 | 609 |
| 606 | 610 |
| 607 // | 611 // |
| 608 // Accessors::ScriptGetEvalFromScript | 612 // Accessors::ScriptGetEvalFromScript |
| 609 // | 613 // |
| 610 | 614 |
| 611 | 615 |
| 612 void Accessors::ScriptEvalFromScriptGetter( | 616 void Accessors::ScriptEvalFromScriptGetter( |
| 613 v8::Local<v8::Name> name, | 617 v8::Local<v8::Name> name, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 629 | 633 |
| 630 info.GetReturnValue().Set(Utils::ToLocal(result)); | 634 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 631 } | 635 } |
| 632 | 636 |
| 633 | 637 |
| 634 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo( | 638 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo( |
| 635 Isolate* isolate, PropertyAttributes attributes) { | 639 Isolate* isolate, PropertyAttributes attributes) { |
| 636 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 640 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 637 STATIC_CHAR_VECTOR("eval_from_script"))); | 641 STATIC_CHAR_VECTOR("eval_from_script"))); |
| 638 return MakeAccessor(isolate, name, &ScriptEvalFromScriptGetter, nullptr, | 642 return MakeAccessor(isolate, name, &ScriptEvalFromScriptGetter, nullptr, |
| 639 attributes); | 643 attributes, false); |
| 640 } | 644 } |
| 641 | 645 |
| 642 | 646 |
| 643 // | 647 // |
| 644 // Accessors::ScriptGetEvalFromScriptPosition | 648 // Accessors::ScriptGetEvalFromScriptPosition |
| 645 // | 649 // |
| 646 | 650 |
| 647 | 651 |
| 648 void Accessors::ScriptEvalFromScriptPositionGetter( | 652 void Accessors::ScriptEvalFromScriptPositionGetter( |
| 649 v8::Local<v8::Name> name, | 653 v8::Local<v8::Name> name, |
| 650 const v8::PropertyCallbackInfo<v8::Value>& info) { | 654 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 651 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 655 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 652 HandleScope scope(isolate); | 656 HandleScope scope(isolate); |
| 653 Handle<Object> object = Utils::OpenHandle(*info.Holder()); | 657 Handle<Object> object = Utils::OpenHandle(*info.Holder()); |
| 654 Handle<Script> script( | 658 Handle<Script> script( |
| 655 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 659 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
| 656 Handle<Object> result = isolate->factory()->undefined_value(); | 660 Handle<Object> result = isolate->factory()->undefined_value(); |
| 657 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { | 661 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { |
| 658 result = Handle<Object>(Smi::FromInt(script->GetEvalPosition()), isolate); | 662 result = Handle<Object>(Smi::FromInt(script->GetEvalPosition()), isolate); |
| 659 } | 663 } |
| 660 info.GetReturnValue().Set(Utils::ToLocal(result)); | 664 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 661 } | 665 } |
| 662 | 666 |
| 663 | 667 |
| 664 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( | 668 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( |
| 665 Isolate* isolate, PropertyAttributes attributes) { | 669 Isolate* isolate, PropertyAttributes attributes) { |
| 666 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 670 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 667 STATIC_CHAR_VECTOR("eval_from_script_position"))); | 671 STATIC_CHAR_VECTOR("eval_from_script_position"))); |
| 668 return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter, | 672 return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter, |
| 669 nullptr, attributes); | 673 nullptr, attributes, false); |
| 670 } | 674 } |
| 671 | 675 |
| 672 | 676 |
| 673 // | 677 // |
| 674 // Accessors::ScriptGetEvalFromFunctionName | 678 // Accessors::ScriptGetEvalFromFunctionName |
| 675 // | 679 // |
| 676 | 680 |
| 677 | 681 |
| 678 void Accessors::ScriptEvalFromFunctionNameGetter( | 682 void Accessors::ScriptEvalFromFunctionNameGetter( |
| 679 v8::Local<v8::Name> name, | 683 v8::Local<v8::Name> name, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 696 } | 700 } |
| 697 info.GetReturnValue().Set(Utils::ToLocal(result)); | 701 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 698 } | 702 } |
| 699 | 703 |
| 700 | 704 |
| 701 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo( | 705 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo( |
| 702 Isolate* isolate, PropertyAttributes attributes) { | 706 Isolate* isolate, PropertyAttributes attributes) { |
| 703 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 707 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 704 STATIC_CHAR_VECTOR("eval_from_function_name"))); | 708 STATIC_CHAR_VECTOR("eval_from_function_name"))); |
| 705 return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, nullptr, | 709 return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, nullptr, |
| 706 attributes); | 710 attributes, false); |
| 707 } | 711 } |
| 708 | 712 |
| 709 | 713 |
| 710 // | 714 // |
| 711 // Accessors::FunctionPrototype | 715 // Accessors::FunctionPrototype |
| 712 // | 716 // |
| 713 | 717 |
| 714 static Handle<Object> GetFunctionPrototype(Isolate* isolate, | 718 static Handle<Object> GetFunctionPrototype(Isolate* isolate, |
| 715 Handle<JSFunction> function) { | 719 Handle<JSFunction> function) { |
| 716 if (!function->has_prototype()) { | 720 if (!function->has_prototype()) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 if (SetFunctionPrototype(isolate, object, value).is_null()) { | 765 if (SetFunctionPrototype(isolate, object, value).is_null()) { |
| 762 isolate->OptionalRescheduleException(false); | 766 isolate->OptionalRescheduleException(false); |
| 763 } else { | 767 } else { |
| 764 info.GetReturnValue().Set(true); | 768 info.GetReturnValue().Set(true); |
| 765 } | 769 } |
| 766 } | 770 } |
| 767 | 771 |
| 768 | 772 |
| 769 Handle<AccessorInfo> Accessors::FunctionPrototypeInfo( | 773 Handle<AccessorInfo> Accessors::FunctionPrototypeInfo( |
| 770 Isolate* isolate, PropertyAttributes attributes) { | 774 Isolate* isolate, PropertyAttributes attributes) { |
| 771 return MakeAccessor(isolate, | 775 return MakeAccessor(isolate, isolate->factory()->prototype_string(), |
| 772 isolate->factory()->prototype_string(), | 776 &FunctionPrototypeGetter, &FunctionPrototypeSetter, |
| 773 &FunctionPrototypeGetter, | 777 attributes, false); |
| 774 &FunctionPrototypeSetter, | |
| 775 attributes); | |
| 776 } | 778 } |
| 777 | 779 |
| 778 | 780 |
| 779 // | 781 // |
| 780 // Accessors::FunctionLength | 782 // Accessors::FunctionLength |
| 781 // | 783 // |
| 782 | 784 |
| 783 | 785 |
| 784 void Accessors::FunctionLengthGetter( | 786 void Accessors::FunctionLengthGetter( |
| 785 v8::Local<v8::Name> name, | 787 v8::Local<v8::Name> name, |
| 786 const v8::PropertyCallbackInfo<v8::Value>& info) { | 788 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 787 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 789 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 788 HandleScope scope(isolate); | 790 HandleScope scope(isolate); |
| 789 Handle<JSFunction> function = | 791 Handle<JSFunction> function = |
| 790 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 792 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
| 791 Handle<Object> result; | 793 Handle<Object> result; |
| 792 if (!JSFunction::GetLength(isolate, function).ToHandle(&result)) { | 794 if (!JSFunction::GetLength(isolate, function).ToHandle(&result)) { |
| 793 result = handle(Smi::kZero, isolate); | 795 result = handle(Smi::kZero, isolate); |
| 794 isolate->OptionalRescheduleException(false); | 796 isolate->OptionalRescheduleException(false); |
| 795 } | 797 } |
| 796 | 798 |
| 797 info.GetReturnValue().Set(Utils::ToLocal(result)); | 799 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 798 } | 800 } |
| 799 | 801 |
| 800 Handle<AccessorInfo> Accessors::FunctionLengthInfo( | 802 Handle<AccessorInfo> Accessors::FunctionLengthInfo( |
| 801 Isolate* isolate, PropertyAttributes attributes) { | 803 Isolate* isolate, PropertyAttributes attributes) { |
| 802 return MakeAccessor(isolate, isolate->factory()->length_string(), | 804 return MakeAccessor(isolate, isolate->factory()->length_string(), |
| 803 &FunctionLengthGetter, &ReconfigureToDataProperty, | 805 &FunctionLengthGetter, nullptr, attributes, true); |
|
Toon Verwaest
2016/10/28 14:05:21
This technically all works, but it won't give good
| |
| 804 attributes); | |
| 805 } | 806 } |
| 806 | 807 |
| 807 | 808 |
| 808 // | 809 // |
| 809 // Accessors::FunctionName | 810 // Accessors::FunctionName |
| 810 // | 811 // |
| 811 | 812 |
| 812 | 813 |
| 813 void Accessors::FunctionNameGetter( | 814 void Accessors::FunctionNameGetter( |
| 814 v8::Local<v8::Name> name, | 815 v8::Local<v8::Name> name, |
| 815 const v8::PropertyCallbackInfo<v8::Value>& info) { | 816 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 816 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 817 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 817 HandleScope scope(isolate); | 818 HandleScope scope(isolate); |
| 818 Handle<JSFunction> function = | 819 Handle<JSFunction> function = |
| 819 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 820 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
| 820 Handle<Object> result = JSFunction::GetName(isolate, function); | 821 Handle<Object> result = JSFunction::GetName(isolate, function); |
| 821 info.GetReturnValue().Set(Utils::ToLocal(result)); | 822 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 822 } | 823 } |
| 823 | 824 |
| 824 Handle<AccessorInfo> Accessors::FunctionNameInfo( | 825 Handle<AccessorInfo> Accessors::FunctionNameInfo( |
| 825 Isolate* isolate, PropertyAttributes attributes) { | 826 Isolate* isolate, PropertyAttributes attributes) { |
| 826 return MakeAccessor(isolate, isolate->factory()->name_string(), | 827 return MakeAccessor(isolate, isolate->factory()->name_string(), |
| 827 &FunctionNameGetter, &ReconfigureToDataProperty, | 828 &FunctionNameGetter, nullptr, attributes, true); |
| 828 attributes); | |
| 829 } | 829 } |
| 830 | 830 |
| 831 | 831 |
| 832 // | 832 // |
| 833 // Accessors::FunctionArguments | 833 // Accessors::FunctionArguments |
| 834 // | 834 // |
| 835 | 835 |
| 836 | 836 |
| 837 static Handle<Object> ArgumentsForInlinedFunction( | 837 static Handle<Object> ArgumentsForInlinedFunction( |
| 838 JavaScriptFrame* frame, | 838 JavaScriptFrame* frame, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 965 function->shared()->native() | 965 function->shared()->native() |
| 966 ? Handle<Object>::cast(isolate->factory()->null_value()) | 966 ? Handle<Object>::cast(isolate->factory()->null_value()) |
| 967 : GetFunctionArguments(isolate, function); | 967 : GetFunctionArguments(isolate, function); |
| 968 info.GetReturnValue().Set(Utils::ToLocal(result)); | 968 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 969 } | 969 } |
| 970 | 970 |
| 971 | 971 |
| 972 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( | 972 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( |
| 973 Isolate* isolate, PropertyAttributes attributes) { | 973 Isolate* isolate, PropertyAttributes attributes) { |
| 974 return MakeAccessor(isolate, isolate->factory()->arguments_string(), | 974 return MakeAccessor(isolate, isolate->factory()->arguments_string(), |
| 975 &FunctionArgumentsGetter, nullptr, attributes); | 975 &FunctionArgumentsGetter, nullptr, attributes, false); |
| 976 } | 976 } |
| 977 | 977 |
| 978 | 978 |
| 979 // | 979 // |
| 980 // Accessors::FunctionCaller | 980 // Accessors::FunctionCaller |
| 981 // | 981 // |
| 982 | 982 |
| 983 | 983 |
| 984 static inline bool AllowAccessToFunction(Context* current_context, | 984 static inline bool AllowAccessToFunction(Context* current_context, |
| 985 JSFunction* function) { | 985 JSFunction* function) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1098 } else { | 1098 } else { |
| 1099 result = isolate->factory()->null_value(); | 1099 result = isolate->factory()->null_value(); |
| 1100 } | 1100 } |
| 1101 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1101 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 | 1104 |
| 1105 Handle<AccessorInfo> Accessors::FunctionCallerInfo( | 1105 Handle<AccessorInfo> Accessors::FunctionCallerInfo( |
| 1106 Isolate* isolate, PropertyAttributes attributes) { | 1106 Isolate* isolate, PropertyAttributes attributes) { |
| 1107 return MakeAccessor(isolate, isolate->factory()->caller_string(), | 1107 return MakeAccessor(isolate, isolate->factory()->caller_string(), |
| 1108 &FunctionCallerGetter, nullptr, attributes); | 1108 &FunctionCallerGetter, nullptr, attributes, false); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 | 1111 |
| 1112 // | 1112 // |
| 1113 // Accessors::BoundFunctionLength | 1113 // Accessors::BoundFunctionLength |
| 1114 // | 1114 // |
| 1115 | 1115 |
| 1116 void Accessors::BoundFunctionLengthGetter( | 1116 void Accessors::BoundFunctionLengthGetter( |
| 1117 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 1117 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1118 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1118 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1135 int bound_length = function->bound_arguments()->length(); | 1135 int bound_length = function->bound_arguments()->length(); |
| 1136 int length = Max(0, target_length->value() - bound_length); | 1136 int length = Max(0, target_length->value() - bound_length); |
| 1137 | 1137 |
| 1138 Handle<Object> result(Smi::FromInt(length), isolate); | 1138 Handle<Object> result(Smi::FromInt(length), isolate); |
| 1139 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1139 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 Handle<AccessorInfo> Accessors::BoundFunctionLengthInfo( | 1142 Handle<AccessorInfo> Accessors::BoundFunctionLengthInfo( |
| 1143 Isolate* isolate, PropertyAttributes attributes) { | 1143 Isolate* isolate, PropertyAttributes attributes) { |
| 1144 return MakeAccessor(isolate, isolate->factory()->length_string(), | 1144 return MakeAccessor(isolate, isolate->factory()->length_string(), |
| 1145 &BoundFunctionLengthGetter, &ReconfigureToDataProperty, | 1145 &BoundFunctionLengthGetter, nullptr, attributes, true); |
| 1146 attributes); | |
| 1147 } | 1146 } |
| 1148 | 1147 |
| 1149 // | 1148 // |
| 1150 // Accessors::BoundFunctionName | 1149 // Accessors::BoundFunctionName |
| 1151 // | 1150 // |
| 1152 | 1151 |
| 1153 void Accessors::BoundFunctionNameGetter( | 1152 void Accessors::BoundFunctionNameGetter( |
| 1154 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 1153 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1155 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1154 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1156 RuntimeCallTimerScope timer( | 1155 RuntimeCallTimerScope timer( |
| 1157 isolate, &RuntimeCallStats::AccessorNameGetterCallback_BoundFunctionName); | 1156 isolate, &RuntimeCallStats::AccessorNameGetterCallback_BoundFunctionName); |
| 1158 HandleScope scope(isolate); | 1157 HandleScope scope(isolate); |
| 1159 Handle<JSBoundFunction> function = | 1158 Handle<JSBoundFunction> function = |
| 1160 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); | 1159 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); |
| 1161 Handle<Object> result; | 1160 Handle<Object> result; |
| 1162 if (!JSBoundFunction::GetName(isolate, function).ToHandle(&result)) { | 1161 if (!JSBoundFunction::GetName(isolate, function).ToHandle(&result)) { |
| 1163 isolate->OptionalRescheduleException(false); | 1162 isolate->OptionalRescheduleException(false); |
| 1164 return; | 1163 return; |
| 1165 } | 1164 } |
| 1166 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1165 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 1167 } | 1166 } |
| 1168 | 1167 |
| 1169 Handle<AccessorInfo> Accessors::BoundFunctionNameInfo( | 1168 Handle<AccessorInfo> Accessors::BoundFunctionNameInfo( |
| 1170 Isolate* isolate, PropertyAttributes attributes) { | 1169 Isolate* isolate, PropertyAttributes attributes) { |
| 1171 return MakeAccessor(isolate, isolate->factory()->name_string(), | 1170 return MakeAccessor(isolate, isolate->factory()->name_string(), |
| 1172 &BoundFunctionNameGetter, &ReconfigureToDataProperty, | 1171 &BoundFunctionNameGetter, nullptr, attributes, true); |
| 1173 attributes); | |
| 1174 } | 1172 } |
| 1175 | 1173 |
| 1176 // | 1174 // |
| 1177 // Accessors::ErrorStack | 1175 // Accessors::ErrorStack |
| 1178 // | 1176 // |
| 1179 | 1177 |
| 1180 namespace { | 1178 namespace { |
| 1181 | 1179 |
| 1182 MaybeHandle<JSReceiver> ClearInternalStackTrace(Isolate* isolate, | 1180 MaybeHandle<JSReceiver> ClearInternalStackTrace(Isolate* isolate, |
| 1183 Handle<JSObject> error) { | 1181 Handle<JSObject> error) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 ClearInternalStackTrace(isolate, obj); | 1276 ClearInternalStackTrace(isolate, obj); |
| 1279 } | 1277 } |
| 1280 | 1278 |
| 1281 Accessors::ReconfigureToDataProperty(name, val, info); | 1279 Accessors::ReconfigureToDataProperty(name, val, info); |
| 1282 } | 1280 } |
| 1283 | 1281 |
| 1284 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, | 1282 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, |
| 1285 PropertyAttributes attributes) { | 1283 PropertyAttributes attributes) { |
| 1286 Handle<AccessorInfo> info = | 1284 Handle<AccessorInfo> info = |
| 1287 MakeAccessor(isolate, isolate->factory()->stack_string(), | 1285 MakeAccessor(isolate, isolate->factory()->stack_string(), |
| 1288 &ErrorStackGetter, &ErrorStackSetter, attributes); | 1286 &ErrorStackGetter, &ErrorStackSetter, attributes, false); |
| 1289 return info; | 1287 return info; |
| 1290 } | 1288 } |
| 1291 | 1289 |
| 1292 } // namespace internal | 1290 } // namespace internal |
| 1293 } // namespace v8 | 1291 } // namespace v8 |
| OLD | NEW |