| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 567 |
| 568 | 568 |
| 569 bool SetResourceConstraints(ResourceConstraints* constraints) { | 569 bool SetResourceConstraints(ResourceConstraints* constraints) { |
| 570 i::Isolate* isolate = EnterIsolateIfNeeded(); | 570 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 571 | 571 |
| 572 int young_space_size = constraints->max_young_space_size(); | 572 int young_space_size = constraints->max_young_space_size(); |
| 573 int old_gen_size = constraints->max_old_space_size(); | 573 int old_gen_size = constraints->max_old_space_size(); |
| 574 int max_executable_size = constraints->max_executable_size(); | 574 int max_executable_size = constraints->max_executable_size(); |
| 575 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 575 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { |
| 576 // After initialization it's too late to change Heap constraints. | 576 // After initialization it's too late to change Heap constraints. |
| 577 ASSERT(!isolate->IsInitialized()); | 577 // TODO(rmcilroy): fix this assert. |
| 578 // ASSERT(!isolate->IsInitialized()); |
| 578 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 579 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
| 579 old_gen_size, | 580 old_gen_size, |
| 580 max_executable_size); | 581 max_executable_size); |
| 581 if (!result) return false; | 582 if (!result) return false; |
| 582 } | 583 } |
| 583 if (constraints->stack_limit() != NULL) { | 584 if (constraints->stack_limit() != NULL) { |
| 584 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 585 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
| 585 isolate->stack_guard()->SetStackLimit(limit); | 586 isolate->stack_guard()->SetStackLimit(limit); |
| 586 } | 587 } |
| 587 return true; | 588 return true; |
| (...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3519 return false); | 3520 return false); |
| 3520 return i::JSReceiver::HasLocalProperty( | 3521 return i::JSReceiver::HasLocalProperty( |
| 3521 Utils::OpenHandle(this), Utils::OpenHandle(*key)); | 3522 Utils::OpenHandle(this), Utils::OpenHandle(*key)); |
| 3522 } | 3523 } |
| 3523 | 3524 |
| 3524 | 3525 |
| 3525 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 3526 bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
| 3526 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3527 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3527 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", | 3528 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", |
| 3528 return false); | 3529 return false); |
| 3529 return Utils::OpenHandle(this)->HasRealNamedProperty( | 3530 return i::JSObject::HasRealNamedProperty(Utils::OpenHandle(this), |
| 3530 isolate, | 3531 Utils::OpenHandle(*key)); |
| 3531 *Utils::OpenHandle(*key)); | |
| 3532 } | 3532 } |
| 3533 | 3533 |
| 3534 | 3534 |
| 3535 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 3535 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
| 3536 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3536 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3537 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", | 3537 ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", |
| 3538 return false); | 3538 return false); |
| 3539 return Utils::OpenHandle(this)->HasRealElementProperty(isolate, index); | 3539 return i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index); |
| 3540 } | 3540 } |
| 3541 | 3541 |
| 3542 | 3542 |
| 3543 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { | 3543 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { |
| 3544 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3544 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3545 ON_BAILOUT(isolate, | 3545 ON_BAILOUT(isolate, |
| 3546 "v8::Object::HasRealNamedCallbackProperty()", | 3546 "v8::Object::HasRealNamedCallbackProperty()", |
| 3547 return false); | 3547 return false); |
| 3548 ENTER_V8(isolate); | 3548 ENTER_V8(isolate); |
| 3549 return Utils::OpenHandle(this)->HasRealNamedCallbackProperty( | 3549 return i::JSObject::HasRealNamedCallbackProperty(Utils::OpenHandle(this), |
| 3550 isolate, | 3550 Utils::OpenHandle(*key)); |
| 3551 *Utils::OpenHandle(*key)); | |
| 3552 } | 3551 } |
| 3553 | 3552 |
| 3554 | 3553 |
| 3555 bool v8::Object::HasNamedLookupInterceptor() { | 3554 bool v8::Object::HasNamedLookupInterceptor() { |
| 3556 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3555 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3557 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", | 3556 ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", |
| 3558 return false); | 3557 return false); |
| 3559 return Utils::OpenHandle(this)->HasNamedInterceptor(); | 3558 return Utils::OpenHandle(this)->HasNamedInterceptor(); |
| 3560 } | 3559 } |
| 3561 | 3560 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4105 } | 4104 } |
| 4106 | 4105 |
| 4107 | 4106 |
| 4108 Handle<Value> Function::GetInferredName() const { | 4107 Handle<Value> Function::GetInferredName() const { |
| 4109 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4108 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4110 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), | 4109 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), |
| 4111 func->GetIsolate())); | 4110 func->GetIsolate())); |
| 4112 } | 4111 } |
| 4113 | 4112 |
| 4114 | 4113 |
| 4114 Handle<Value> Function::GetDisplayName() const { |
| 4115 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 4116 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()", |
| 4117 return ToApiHandle<Primitive>( |
| 4118 isolate->factory()->undefined_value())); |
| 4119 ENTER_V8(isolate); |
| 4120 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4121 i::Handle<i::String> property_name = |
| 4122 isolate->factory()->InternalizeOneByteString( |
| 4123 STATIC_ASCII_VECTOR("displayName")); |
| 4124 i::LookupResult lookup(isolate); |
| 4125 func->LookupRealNamedProperty(*property_name, &lookup); |
| 4126 if (lookup.IsFound()) { |
| 4127 i::Object* value = lookup.GetLazyValue(); |
| 4128 if (value && value->IsString()) { |
| 4129 i::String* name = i::String::cast(value); |
| 4130 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name)); |
| 4131 } |
| 4132 } |
| 4133 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); |
| 4134 } |
| 4135 |
| 4136 |
| 4115 ScriptOrigin Function::GetScriptOrigin() const { | 4137 ScriptOrigin Function::GetScriptOrigin() const { |
| 4116 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4138 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4117 if (func->shared()->script()->IsScript()) { | 4139 if (func->shared()->script()->IsScript()) { |
| 4118 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4140 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
| 4119 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script); | 4141 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script); |
| 4120 v8::ScriptOrigin origin( | 4142 v8::ScriptOrigin origin( |
| 4121 Utils::ToLocal(scriptName), | 4143 Utils::ToLocal(scriptName), |
| 4122 v8::Integer::New(script->line_offset()->value()), | 4144 v8::Integer::New(script->line_offset()->value()), |
| 4123 v8::Integer::New(script->column_offset()->value())); | 4145 v8::Integer::New(script->column_offset()->value())); |
| 4124 return origin; | 4146 return origin; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4143 int Function::GetScriptColumnNumber() const { | 4165 int Function::GetScriptColumnNumber() const { |
| 4144 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4166 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4145 if (func->shared()->script()->IsScript()) { | 4167 if (func->shared()->script()->IsScript()) { |
| 4146 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4168 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
| 4147 return i::GetScriptColumnNumber(script, func->shared()->start_position()); | 4169 return i::GetScriptColumnNumber(script, func->shared()->start_position()); |
| 4148 } | 4170 } |
| 4149 return kLineOffsetNotFound; | 4171 return kLineOffsetNotFound; |
| 4150 } | 4172 } |
| 4151 | 4173 |
| 4152 | 4174 |
| 4175 bool Function::IsBuiltin() const { |
| 4176 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4177 return func->IsBuiltin(); |
| 4178 } |
| 4179 |
| 4180 |
| 4153 Handle<Value> Function::GetScriptId() const { | 4181 Handle<Value> Function::GetScriptId() const { |
| 4154 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4182 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4155 i::Isolate* isolate = func->GetIsolate(); | 4183 i::Isolate* isolate = func->GetIsolate(); |
| 4156 if (!func->shared()->script()->IsScript()) { | 4184 if (!func->shared()->script()->IsScript()) { |
| 4157 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 4185 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| 4158 } | 4186 } |
| 4159 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4187 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
| 4160 return Utils::ToLocal(i::Handle<i::Object>(script->id(), isolate)); | 4188 return Utils::ToLocal(i::Handle<i::Object>(script->id(), isolate)); |
| 4161 } | 4189 } |
| 4162 | 4190 |
| (...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6343 // to deal more gracefully with out of memory situations. | 6371 // to deal more gracefully with out of memory situations. |
| 6344 if (value.IsEmpty()) { | 6372 if (value.IsEmpty()) { |
| 6345 isolate->ScheduleThrow(isolate->heap()->undefined_value()); | 6373 isolate->ScheduleThrow(isolate->heap()->undefined_value()); |
| 6346 } else { | 6374 } else { |
| 6347 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); | 6375 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); |
| 6348 } | 6376 } |
| 6349 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 6377 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| 6350 } | 6378 } |
| 6351 | 6379 |
| 6352 | 6380 |
| 6353 void Isolate::SetObjectGroupId(const Persistent<Value>& object, | 6381 void Isolate::SetObjectGroupId(internal::Object** object, UniqueId id) { |
| 6354 UniqueId id) { | |
| 6355 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); | 6382 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6356 internal_isolate->global_handles()->SetObjectGroupId( | 6383 internal_isolate->global_handles()->SetObjectGroupId( |
| 6357 Utils::OpenPersistent(object).location(), | 6384 v8::internal::Handle<v8::internal::Object>(object).location(), |
| 6358 id); | 6385 id); |
| 6359 } | 6386 } |
| 6360 | 6387 |
| 6361 | 6388 |
| 6362 void Isolate::SetReferenceFromGroup(UniqueId id, | 6389 void Isolate::SetReferenceFromGroup(UniqueId id, internal::Object** object) { |
| 6363 const Persistent<Value>& object) { | |
| 6364 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); | 6390 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6365 internal_isolate->global_handles()->SetReferenceFromGroup( | 6391 internal_isolate->global_handles()->SetReferenceFromGroup( |
| 6366 id, | 6392 id, |
| 6367 Utils::OpenPersistent(object).location()); | 6393 v8::internal::Handle<v8::internal::Object>(object).location()); |
| 6368 } | 6394 } |
| 6369 | 6395 |
| 6370 | 6396 |
| 6371 void Isolate::SetReference(const Persistent<Object>& parent, | 6397 void Isolate::SetReference(internal::Object** parent, |
| 6372 const Persistent<Value>& child) { | 6398 internal::Object** child) { |
| 6373 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); | 6399 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6374 i::Object** parent_location = Utils::OpenPersistent(parent).location(); | 6400 i::Object** parent_location = |
| 6401 v8::internal::Handle<v8::internal::Object>(parent).location(); |
| 6375 internal_isolate->global_handles()->SetReference( | 6402 internal_isolate->global_handles()->SetReference( |
| 6376 reinterpret_cast<i::HeapObject**>(parent_location), | 6403 reinterpret_cast<i::HeapObject**>(parent_location), |
| 6377 Utils::OpenPersistent(child).location()); | 6404 v8::internal::Handle<v8::internal::Object>(child).location()); |
| 6378 } | 6405 } |
| 6379 | 6406 |
| 6380 | 6407 |
| 6381 void Isolate::AddGCPrologueCallback(GCPrologueCallback callback, | 6408 void Isolate::AddGCPrologueCallback(GCPrologueCallback callback, |
| 6382 GCType gc_type) { | 6409 GCType gc_type) { |
| 6383 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6410 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 6384 isolate->heap()->AddGCPrologueCallback(callback, gc_type); | 6411 isolate->heap()->AddGCPrologueCallback(callback, gc_type); |
| 6385 } | 6412 } |
| 6386 | 6413 |
| 6387 | 6414 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6921 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( | 6948 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( |
| 6922 node->entry()->resource_name())); | 6949 node->entry()->resource_name())); |
| 6923 } | 6950 } |
| 6924 | 6951 |
| 6925 | 6952 |
| 6926 int CpuProfileNode::GetLineNumber() const { | 6953 int CpuProfileNode::GetLineNumber() const { |
| 6927 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); | 6954 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); |
| 6928 } | 6955 } |
| 6929 | 6956 |
| 6930 | 6957 |
| 6958 int CpuProfileNode::GetColumnNumber() const { |
| 6959 return reinterpret_cast<const i::ProfileNode*>(this)-> |
| 6960 entry()->column_number(); |
| 6961 } |
| 6962 |
| 6963 |
| 6931 const char* CpuProfileNode::GetBailoutReason() const { | 6964 const char* CpuProfileNode::GetBailoutReason() const { |
| 6932 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6965 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 6933 return node->entry()->bailout_reason(); | 6966 return node->entry()->bailout_reason(); |
| 6934 } | 6967 } |
| 6935 | 6968 |
| 6936 | 6969 |
| 6937 unsigned CpuProfileNode::GetHitCount() const { | 6970 unsigned CpuProfileNode::GetHitCount() const { |
| 6938 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); | 6971 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); |
| 6939 } | 6972 } |
| 6940 | 6973 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7287 GetMemorySizeUsedByProfiler(); | 7320 GetMemorySizeUsedByProfiler(); |
| 7288 } | 7321 } |
| 7289 | 7322 |
| 7290 | 7323 |
| 7291 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 7324 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
| 7292 RetainedObjectInfo* info) { | 7325 RetainedObjectInfo* info) { |
| 7293 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); | 7326 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); |
| 7294 } | 7327 } |
| 7295 | 7328 |
| 7296 | 7329 |
| 7330 void HeapProfiler::StartRecordingHeapAllocations() { |
| 7331 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapAllocationsRecording(); |
| 7332 } |
| 7333 |
| 7334 |
| 7335 void HeapProfiler::StopRecordingHeapAllocations() { |
| 7336 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapAllocationsRecording(); |
| 7337 } |
| 7338 |
| 7339 |
| 7297 v8::Testing::StressType internal::Testing::stress_type_ = | 7340 v8::Testing::StressType internal::Testing::stress_type_ = |
| 7298 v8::Testing::kStressTypeOpt; | 7341 v8::Testing::kStressTypeOpt; |
| 7299 | 7342 |
| 7300 | 7343 |
| 7301 void Testing::SetStressRunType(Testing::StressType type) { | 7344 void Testing::SetStressRunType(Testing::StressType type) { |
| 7302 internal::Testing::set_stress_type(type); | 7345 internal::Testing::set_stress_type(type); |
| 7303 } | 7346 } |
| 7304 | 7347 |
| 7305 | 7348 |
| 7306 int Testing::GetStressRuns() { | 7349 int Testing::GetStressRuns() { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7528 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7571 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7529 Address callback_address = | 7572 Address callback_address = |
| 7530 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7573 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7531 VMState<EXTERNAL> state(isolate); | 7574 VMState<EXTERNAL> state(isolate); |
| 7532 ExternalCallbackScope call_scope(isolate, callback_address); | 7575 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7533 callback(info); | 7576 callback(info); |
| 7534 } | 7577 } |
| 7535 | 7578 |
| 7536 | 7579 |
| 7537 } } // namespace v8::internal | 7580 } } // namespace v8::internal |
| OLD | NEW |