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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 #ifdef DEBUG | 141 #ifdef DEBUG |
142 // Calculate the result using a full stack frame iterator and check | 142 // Calculate the result using a full stack frame iterator and check |
143 // that the state of the stack is as we assume it to be in the | 143 // that the state of the stack is as we assume it to be in the |
144 // code below. | 144 // code below. |
145 StackFrameIterator it; | 145 StackFrameIterator it; |
146 ASSERT(it.frame()->is_exit()); | 146 ASSERT(it.frame()->is_exit()); |
147 it.Advance(); | 147 it.Advance(); |
148 StackFrame* frame = it.frame(); | 148 StackFrame* frame = it.frame(); |
149 bool reference_result = frame->is_construct(); | 149 bool reference_result = frame->is_construct(); |
150 #endif | 150 #endif |
151 Address fp = Top::c_entry_fp(Isolate::Current()->thread_local_top()); | 151 Address fp = Isolate::c_entry_fp(Isolate::Current()->thread_local_top()); |
152 // Because we know fp points to an exit frame we can use the relevant | 152 // Because we know fp points to an exit frame we can use the relevant |
153 // part of ExitFrame::ComputeCallerState directly. | 153 // part of ExitFrame::ComputeCallerState directly. |
154 const int kCallerOffset = ExitFrameConstants::kCallerFPOffset; | 154 const int kCallerOffset = ExitFrameConstants::kCallerFPOffset; |
155 Address caller_fp = Memory::Address_at(fp + kCallerOffset); | 155 Address caller_fp = Memory::Address_at(fp + kCallerOffset); |
156 // This inlines the part of StackFrame::ComputeType that grabs the | 156 // This inlines the part of StackFrame::ComputeType that grabs the |
157 // type of the current frame. Note that StackFrame::ComputeType | 157 // type of the current frame. Note that StackFrame::ComputeType |
158 // has been specialized for each architecture so if any one of them | 158 // has been specialized for each architecture so if any one of them |
159 // changes this code has to be changed as well. | 159 // changes this code has to be changed as well. |
160 const int kMarkerOffset = StandardFrameConstants::kMarkerOffset; | 160 const int kMarkerOffset = StandardFrameConstants::kMarkerOffset; |
161 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); | 161 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); |
(...skipping 19 matching lines...) Expand all Loading... |
181 | 181 |
182 BUILTIN(ArrayCodeGeneric) { | 182 BUILTIN(ArrayCodeGeneric) { |
183 Counters::array_function_runtime.Increment(); | 183 Counters::array_function_runtime.Increment(); |
184 | 184 |
185 JSArray* array; | 185 JSArray* array; |
186 if (CalledAsConstructor()) { | 186 if (CalledAsConstructor()) { |
187 array = JSArray::cast(*args.receiver()); | 187 array = JSArray::cast(*args.receiver()); |
188 } else { | 188 } else { |
189 // Allocate the JS Array | 189 // Allocate the JS Array |
190 JSFunction* constructor = | 190 JSFunction* constructor = |
191 Top::context()->global_context()->array_function(); | 191 Isolate::Current()->context()->global_context()->array_function(); |
192 Object* obj = HEAP->AllocateJSObject(constructor); | 192 Object* obj = HEAP->AllocateJSObject(constructor); |
193 if (obj->IsFailure()) return obj; | 193 if (obj->IsFailure()) return obj; |
194 array = JSArray::cast(obj); | 194 array = JSArray::cast(obj); |
195 } | 195 } |
196 | 196 |
197 // 'array' now contains the JSArray we should initialize. | 197 // 'array' now contains the JSArray we should initialize. |
198 | 198 |
199 // Optimize the case where there is one argument and the argument is a | 199 // Optimize the case where there is one argument and the argument is a |
200 // small smi. | 200 // small smi. |
201 if (args.length() == 2) { | 201 if (args.length() == 2) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // Set length and elements on the array. | 237 // Set length and elements on the array. |
238 array->set_elements(FixedArray::cast(obj)); | 238 array->set_elements(FixedArray::cast(obj)); |
239 array->set_length(len); | 239 array->set_length(len); |
240 | 240 |
241 return array; | 241 return array; |
242 } | 242 } |
243 | 243 |
244 | 244 |
245 static Object* AllocateJSArray() { | 245 static Object* AllocateJSArray() { |
246 JSFunction* array_function = | 246 JSFunction* array_function = |
247 Top::context()->global_context()->array_function(); | 247 Isolate::Current()->context()->global_context()->array_function(); |
248 Object* result = HEAP->AllocateJSObject(array_function); | 248 Object* result = HEAP->AllocateJSObject(array_function); |
249 if (result->IsFailure()) return result; | 249 if (result->IsFailure()) return result; |
250 return result; | 250 return result; |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 static Object* AllocateEmptyJSArray() { | 254 static Object* AllocateEmptyJSArray() { |
255 Object* result = AllocateJSArray(); | 255 Object* result = AllocateJSArray(); |
256 if (result->IsFailure()) return result; | 256 if (result->IsFailure()) return result; |
257 JSArray* result_array = JSArray::cast(result); | 257 JSArray* result_array = JSArray::cast(result); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 *elements = FixedArray::cast(elms); | 363 *elements = FixedArray::cast(elms); |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
367 | 367 |
368 static bool IsFastElementMovingAllowed(Object* receiver, | 368 static bool IsFastElementMovingAllowed(Object* receiver, |
369 FixedArray** elements) { | 369 FixedArray** elements) { |
370 if (!IsJSArrayWithFastElements(receiver, elements)) return false; | 370 if (!IsJSArrayWithFastElements(receiver, elements)) return false; |
371 | 371 |
372 Context* global_context = Top::context()->global_context(); | 372 Context* global_context = Isolate::Current()->context()->global_context(); |
373 JSObject* array_proto = | 373 JSObject* array_proto = |
374 JSObject::cast(global_context->array_function()->prototype()); | 374 JSObject::cast(global_context->array_function()->prototype()); |
375 if (JSArray::cast(receiver)->GetPrototype() != array_proto) return false; | 375 if (JSArray::cast(receiver)->GetPrototype() != array_proto) return false; |
376 return ArrayPrototypeHasNoElements(global_context, array_proto); | 376 return ArrayPrototypeHasNoElements(global_context, array_proto); |
377 } | 377 } |
378 | 378 |
379 | 379 |
380 static Object* CallJsBuiltin(const char* name, | 380 static Object* CallJsBuiltin(const char* name, |
381 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { | 381 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { |
382 HandleScope handleScope; | 382 HandleScope handleScope; |
383 | 383 |
384 Handle<Object> js_builtin = | 384 Handle<Object> js_builtin = |
385 GetProperty(Handle<JSObject>(Top::global_context()->builtins()), | 385 GetProperty(Handle<JSObject>( |
386 name); | 386 Isolate::Current()->global_context()->builtins()), |
| 387 name); |
387 ASSERT(js_builtin->IsJSFunction()); | 388 ASSERT(js_builtin->IsJSFunction()); |
388 Handle<JSFunction> function(Handle<JSFunction>::cast(js_builtin)); | 389 Handle<JSFunction> function(Handle<JSFunction>::cast(js_builtin)); |
389 ScopedVector<Object**> argv(args.length() - 1); | 390 ScopedVector<Object**> argv(args.length() - 1); |
390 int n_args = args.length() - 1; | 391 int n_args = args.length() - 1; |
391 for (int i = 0; i < n_args; i++) { | 392 for (int i = 0; i < n_args; i++) { |
392 argv[i] = args.at<Object>(i + 1).location(); | 393 argv[i] = args.at<Object>(i + 1).location(); |
393 } | 394 } |
394 bool pending_exception = false; | 395 bool pending_exception = false; |
395 Handle<Object> result = Execution::Call(function, | 396 Handle<Object> result = Execution::Call(function, |
396 args.receiver(), | 397 args.receiver(), |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 } | 783 } |
783 | 784 |
784 // Set the length. | 785 // Set the length. |
785 array->set_length(Smi::FromInt(new_length)); | 786 array->set_length(Smi::FromInt(new_length)); |
786 | 787 |
787 return result_array; | 788 return result_array; |
788 } | 789 } |
789 | 790 |
790 | 791 |
791 BUILTIN(ArrayConcat) { | 792 BUILTIN(ArrayConcat) { |
792 Context* global_context = Top::context()->global_context(); | 793 Context* global_context = Isolate::Current()->context()->global_context(); |
793 JSObject* array_proto = | 794 JSObject* array_proto = |
794 JSObject::cast(global_context->array_function()->prototype()); | 795 JSObject::cast(global_context->array_function()->prototype()); |
795 if (!ArrayPrototypeHasNoElements(global_context, array_proto)) { | 796 if (!ArrayPrototypeHasNoElements(global_context, array_proto)) { |
796 return CallJsBuiltin("ArrayConcat", args); | 797 return CallJsBuiltin("ArrayConcat", args); |
797 } | 798 } |
798 | 799 |
799 // Iterate through all the arguments performing checks | 800 // Iterate through all the arguments performing checks |
800 // and calculating total length. | 801 // and calculating total length. |
801 int n_arguments = args.length(); | 802 int n_arguments = args.length(); |
802 int result_len = 0; | 803 int result_len = 0; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 HandleScope scope; | 917 HandleScope scope; |
917 Handle<JSFunction> function = args.called_function(); | 918 Handle<JSFunction> function = args.called_function(); |
918 ASSERT(function->shared()->IsApiFunction()); | 919 ASSERT(function->shared()->IsApiFunction()); |
919 | 920 |
920 FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data(); | 921 FunctionTemplateInfo* fun_data = function->shared()->get_api_func_data(); |
921 if (is_construct) { | 922 if (is_construct) { |
922 Handle<FunctionTemplateInfo> desc(fun_data); | 923 Handle<FunctionTemplateInfo> desc(fun_data); |
923 bool pending_exception = false; | 924 bool pending_exception = false; |
924 Factory::ConfigureInstance(desc, Handle<JSObject>::cast(args.receiver()), | 925 Factory::ConfigureInstance(desc, Handle<JSObject>::cast(args.receiver()), |
925 &pending_exception); | 926 &pending_exception); |
926 ASSERT(Top::has_pending_exception() == pending_exception); | 927 ASSERT(Isolate::Current()->has_pending_exception() == pending_exception); |
927 if (pending_exception) return Failure::Exception(); | 928 if (pending_exception) return Failure::Exception(); |
928 fun_data = *desc; | 929 fun_data = *desc; |
929 } | 930 } |
930 | 931 |
931 Object* raw_holder = TypeCheck(args.length(), &args[0], fun_data); | 932 Object* raw_holder = TypeCheck(args.length(), &args[0], fun_data); |
932 | 933 |
933 if (raw_holder->IsNull()) { | 934 if (raw_holder->IsNull()) { |
934 // This function cannot be called with the given receiver. Abort! | 935 // This function cannot be called with the given receiver. Abort! |
935 Handle<Object> obj = | 936 Handle<Object> obj = |
936 Factory::NewTypeError("illegal_invocation", HandleVector(&function, 1)); | 937 Factory::NewTypeError("illegal_invocation", HandleVector(&function, 1)); |
937 return Top::Throw(*obj); | 938 return Isolate::Current()->Throw(*obj); |
938 } | 939 } |
939 | 940 |
940 Object* raw_call_data = fun_data->call_code(); | 941 Object* raw_call_data = fun_data->call_code(); |
941 if (!raw_call_data->IsUndefined()) { | 942 if (!raw_call_data->IsUndefined()) { |
942 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 943 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
943 Object* callback_obj = call_data->callback(); | 944 Object* callback_obj = call_data->callback(); |
944 v8::InvocationCallback callback = | 945 v8::InvocationCallback callback = |
945 v8::ToCData<v8::InvocationCallback>(callback_obj); | 946 v8::ToCData<v8::InvocationCallback>(callback_obj); |
946 Object* data_obj = call_data->data(); | 947 Object* data_obj = call_data->data(); |
947 Object* result; | 948 Object* result; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 if (entry->contains(pc)) { | 1515 if (entry->contains(pc)) { |
1515 return names_[i]; | 1516 return names_[i]; |
1516 } | 1517 } |
1517 } | 1518 } |
1518 } | 1519 } |
1519 return NULL; | 1520 return NULL; |
1520 } | 1521 } |
1521 | 1522 |
1522 | 1523 |
1523 } } // namespace v8::internal | 1524 } } // namespace v8::internal |
OLD | NEW |