OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 ASSERT(args.length() == 1); | 313 ASSERT(args.length() == 1); |
314 Object* arg = args[0]; | 314 Object* arg = args[0]; |
315 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 315 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
316 return Heap::ToBoolean(result); | 316 return Heap::ToBoolean(result); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 static Object* Runtime_GetTemplateField(Arguments args) { | 320 static Object* Runtime_GetTemplateField(Arguments args) { |
321 ASSERT(args.length() == 2); | 321 ASSERT(args.length() == 2); |
322 CONVERT_CHECKED(HeapObject, templ, args[0]); | 322 CONVERT_CHECKED(HeapObject, templ, args[0]); |
323 RUNTIME_ASSERT(templ->IsStruct()); | |
324 CONVERT_CHECKED(Smi, field, args[1]); | 323 CONVERT_CHECKED(Smi, field, args[1]); |
325 return HeapObject::GetHeapObjectField(templ, field->value()); | 324 int index = field->value(); |
| 325 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
| 326 InstanceType type = templ->map()->instance_type(); |
| 327 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
| 328 type == OBJECT_TEMPLATE_INFO_TYPE); |
| 329 RUNTIME_ASSERT(offset > 0); |
| 330 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
| 331 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
| 332 } else { |
| 333 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
| 334 } |
| 335 return *HeapObject::RawField(templ, offset); |
326 } | 336 } |
327 | 337 |
328 | 338 |
329 static Object* ThrowRedeclarationError(const char* type, Handle<String> name) { | 339 static Object* ThrowRedeclarationError(const char* type, Handle<String> name) { |
330 HandleScope scope; | 340 HandleScope scope; |
331 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); | 341 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); |
332 Handle<Object> args[2] = { type_handle, name }; | 342 Handle<Object> args[2] = { type_handle, name }; |
333 Handle<Object> error = | 343 Handle<Object> error = |
334 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); | 344 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); |
335 return Top::Throw(*error); | 345 return Top::Throw(*error); |
(...skipping 5434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5770 | 5780 |
5771 void Runtime::PerformGC(Object* result) { | 5781 void Runtime::PerformGC(Object* result) { |
5772 Failure* failure = Failure::cast(result); | 5782 Failure* failure = Failure::cast(result); |
5773 // Try to do a garbage collection; ignore it if it fails. The C | 5783 // Try to do a garbage collection; ignore it if it fails. The C |
5774 // entry stub will throw an out-of-memory exception in that case. | 5784 // entry stub will throw an out-of-memory exception in that case. |
5775 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); | 5785 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); |
5776 } | 5786 } |
5777 | 5787 |
5778 | 5788 |
5779 } } // namespace v8::internal | 5789 } } // namespace v8::internal |
OLD | NEW |